File tree 1 file changed +45
-0
lines changed
src/websocket/types/room/objects
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,51 @@ mod test {
68
68
69
69
use super :: { SpawningCreep , StructureSpawn } ;
70
70
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
+
71
116
#[ test]
72
117
fn parse_spawn_and_update ( ) {
73
118
let json = json ! ( {
You can’t perform that action at this time.
0 commit comments