aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/tests
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-03-19 21:35:47 +0000
committermat <git@matdoes.dev>2025-03-19 21:35:47 +0000
commit75efbc83fdc4a47f880e95259a339d41839af01a (patch)
treeee5ddeb328fc126ef04adb8006f13513acb48d60 /azalea-client/tests
parentca2e0b3922da74799be812e5a534a20d611fce1a (diff)
downloadazalea-drasl-75efbc83fdc4a47f880e95259a339d41839af01a.tar.xz
make SendPacketEvent a bevy trigger
Diffstat (limited to 'azalea-client/tests')
-rw-r--r--azalea-client/tests/receive_start_config_packet.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/azalea-client/tests/receive_start_config_packet.rs b/azalea-client/tests/receive_start_config_packet.rs
new file mode 100644
index 00000000..36762966
--- /dev/null
+++ b/azalea-client/tests/receive_start_config_packet.rs
@@ -0,0 +1,37 @@
+use azalea_client::{InConfigState, packet::game::SendPacketEvent, test_simulation::*};
+use azalea_core::resource_location::ResourceLocation;
+use azalea_protocol::packets::{ConnectionProtocol, game::ClientboundStartConfiguration};
+use azalea_registry::DimensionType;
+use azalea_world::InstanceName;
+use bevy_ecs::event::Events;
+use bevy_log::tracing_subscriber;
+
+#[test]
+fn test_receive_start_config_packet() {
+ let _ = tracing_subscriber::fmt::try_init();
+
+ let mut simulation = Simulation::new(ConnectionProtocol::Game);
+ simulation.receive_packet(make_basic_login_packet(
+ DimensionType::new_raw(0),
+ ResourceLocation::new("minecraft:overworld"),
+ ));
+ simulation.tick();
+ assert!(simulation.has_component::<InstanceName>());
+ simulation.tick();
+
+ // we shouldn't be using the `SendPacketEvent` event directly, we should be
+ // using the trigger instead
+ simulation.with_resource_mut::<Events<SendPacketEvent>>(|send_packet_events| {
+ assert_eq!(send_packet_events.len(), 0);
+ });
+
+ simulation.receive_packet(ClientboundStartConfiguration);
+
+ simulation.tick();
+ assert!(simulation.has_component::<InConfigState>());
+
+ // check again just in case
+ simulation.with_resource_mut::<Events<SendPacketEvent>>(|send_packet_events| {
+ assert_eq!(send_packet_events.len(), 0);
+ });
+}