// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>

use super::*;

#[ test ]
fn defaults()
{
	let s = spinner();
	assert_eq!( s.phase, 0.0 );
	assert_eq!( s.size, 0.0 ); // 0.0 → follows the widget-scaling mode
	assert_eq!( s.stroke_w, theme::STROKE_W );
}

#[ test ]
fn builders_apply()
{
	let s = spinner().phase( 0.42 ).size( 64.0 ).stroke_width( 5.0 );
	assert_eq!( s.phase, 0.42 );
	assert_eq!( s.size, 64.0 );
	assert_eq!( s.stroke_w, 5.0 );
}

#[ test ]
fn preferred_size_clamps_to_max_width()
{
	let s = spinner().size( 100.0 );
	let canvas = crate::render::Canvas::new( 412, 900 );
	assert_eq!( s.preferred_size( 40.0, &canvas ), ( 40.0, 40.0 ) );
	assert_eq!( s.preferred_size( 200.0, &canvas ), ( 100.0, 100.0 ) );
}

#[ test ]
fn preferred_size_is_square()
{
	let s = spinner();
	let ( w, h ) = s.preferred_size( 999.0, &crate::render::Canvas::new( 412, 900 ) );
	assert_eq!( w, h );
}
