Skip to content

Commit 13c59fc

Browse files
committed
Add new failing StructureSpawn test
1 parent 294d76a commit 13c59fc

File tree

1 file changed

+45
-0
lines changed
  • src/websocket/types/room/objects

1 file changed

+45
-0
lines changed

src/websocket/types/room/objects/spawn.rs

+45
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,51 @@ mod test {
6868

6969
use super::{SpawningCreep, StructureSpawn};
7070

71+
#[test]
72+
fn parse_empty_spawn() {
73+
let json = json!({
74+
"_id": "5f0236153187fd5e3dfa814a",
75+
"hits": 5000,
76+
"hitsMax": 5000,
77+
"name": "Spawn1",
78+
"notifyWhenAttacked": true,
79+
"off": false,
80+
"room": "W41N48",
81+
"spawning": null,
82+
"store": {
83+
"energy": 300
84+
},
85+
"storeCapacityResource": {
86+
"energy": 300
87+
},
88+
"type": "spawn",
89+
"user": "57874d42d0ae911e3bd15bbc",
90+
"x": 26,
91+
"y": 28
92+
});
93+
94+
let mut obj = StructureSpawn::deserialize(json).unwrap();
95+
96+
assert_eq!(
97+
obj,
98+
StructureSpawn {
99+
id: "5f0236153187fd5e3dfa814a".to_owned(),
100+
room: RoomName::new("W31N48").unwrap(),
101+
x: 26,
102+
y: 28,
103+
energy: 300,
104+
energy_capacity: 300,
105+
hits: 5000,
106+
hits_max: 5000,
107+
name: "Spawn1".to_owned(),
108+
notify_when_attacked: true,
109+
disabled: false,
110+
spawning: None,
111+
user: "57874d42d0ae911e3bd15bbc".to_owned(),
112+
}
113+
);
114+
}
115+
71116
#[test]
72117
fn parse_spawn_and_update() {
73118
let json = json!({

0 commit comments

Comments
 (0)