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

use super::*;

#[ derive( Clone, Debug, PartialEq, Eq ) ]
enum Msg { Dismiss }

#[ test ]
fn defaults()
{
	let t: Toast<Msg> = toast( "Saved" );
	assert_eq!( t.message, "Saved" );
	assert_eq!( t.duration, Duration::from_secs( 2 ) );
	assert!( t.on_dismiss.is_none() );
}

#[ test ]
fn duration_builder_clamps_negative()
{
	let t: Toast<Msg> = toast( "x" ).duration( -1.0 );
	assert_eq!( t.duration_value(), Duration::ZERO );
}

#[ test ]
fn on_dismiss_stored()
{
	let t = toast( "x" ).on_dismiss( Msg::Dismiss );
	assert_eq!( t.on_dismiss, Some( Msg::Dismiss ) );
}

#[ test ]
fn overlay_uses_stable_id()
{
	let a: OverlaySpec<Msg> = toast( "x" ).id( WidgetId( "toast/a" ) ).overlay();
	let b: OverlaySpec<Msg> = toast( "y" ).id( WidgetId( "toast/a" ) ).overlay();
	assert_eq!( a.id, b.id, "same WidgetId must yield same OverlayId" );
	let c: OverlaySpec<Msg> = toast( "x" ).id( WidgetId( "toast/b" ) ).overlay();
	assert_ne!( a.id, c.id, "different WidgetIds must yield different OverlayIds" );
}

#[ test ]
fn overlay_is_layer_shell_not_xdg_popup()
{
	let o: OverlaySpec<Msg> = toast( "x" ).overlay();
	assert!( o.anchor_widget_id.is_none() );
	assert_eq!( o.layer, Layer::Overlay );
}
