From c79610bd79292fc793eb0b850a57171a4e408aae Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 24 Nov 2024 09:50:20 -0500 Subject: [PATCH] Add a test for update notifications --- visions/server/src/core.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/visions/server/src/core.rs b/visions/server/src/core.rs index d5bcaf0..d157a65 100644 --- a/visions/server/src/core.rs +++ b/visions/server/src/core.rs @@ -208,4 +208,23 @@ mod test { assert_eq!(background_image, Some(AssetId::from("asset_1"))); }); } + + #[tokio::test] + async fn it_sends_notices_to_clients_on_tabletop_change() { + let core = test_core(); + let client_id = core.register_client(); + let mut receiver = core.connect_client(client_id); + + assert_matches!(core.set_background_image(AssetId::from("asset_1")), Ok(())); + match receiver.recv().await { + Some(Message::UpdateTabletop(Tabletop { + background_color, + background_image, + })) => { + assert_eq!(background_color, DEFAULT_BACKGROUND_COLOR); + assert_eq!(background_image, Some(AssetId::from("asset_1"))); + } + None => panic!("receiver did not get a message"), + } + } }