@@ -36,7 +36,7 @@ describe('Game', function(){
36
36
37
37
it ( "should set result" , function ( ) {
38
38
game . addEvent ( [ "tag_change" , { type : "player_id" , name : "siuying" , player_id : 1 } ] ) ;
39
- game . addEvent ( [ "tag_change" , { type : "game_over " , name : "siuying" , state : "WON" } ] ) ;
39
+ game . addEvent ( [ "tag_change" , { type : "playstate " , name : "siuying" , state : "WON" } ] ) ;
40
40
41
41
var siuying = game . players [ 0 ] ;
42
42
expect ( siuying . result ) . to . equal ( "WON" ) ;
@@ -54,8 +54,8 @@ describe('Game', function(){
54
54
it ( "should return true when game has ended" , function ( ) {
55
55
game . addEvent ( [ "tag_change" , { type : "player_id" , name : "siuying" , player_id : 1 } ] ) ;
56
56
game . addEvent ( [ "tag_change" , { type : "player_id" , name : "cho" , player_id : 2 } ] ) ;
57
- game . addEvent ( [ "tag_change" , { type : "game_over " , name : "siuying" , state : "WON" } ] )
58
- game . addEvent ( [ "tag_change" , { type : "game_over " , name : "cho" , state : "LOST" } ] )
57
+ game . addEvent ( [ "tag_change" , { type : "playstate " , name : "siuying" , state : "WON" } ] )
58
+ game . addEvent ( [ "tag_change" , { type : "playstate " , name : "cho" , state : "LOST" } ] )
59
59
expect ( game . isCompleted ( ) ) . to . equal ( true ) ;
60
60
} )
61
61
} ) ;
@@ -66,31 +66,28 @@ describe('Game', function(){
66
66
game . addEvent ( [ "tag_change" , { type : "player_id" , name : "siuying" , player_id : 1 } ] ) ;
67
67
game . addEvent ( [ "tag_change" , { type : "player_id" , name : "cho" , player_id : 2 } ] ) ;
68
68
game . addEvent ( [ "tag_change" , { type : "first_player" , name : "siuying" } ] ) ;
69
- game . addEvent ( [ "tag_change" , { type : "game_over" , name : "siuying" , state : "WON" } ] )
70
- game . addEvent ( [ "tag_change" , { type : "game_over" , name : "cho" , state : "LOST" } ] )
69
+ game . addEvent ( [ "tag_change" , { type : "playstate" , name : "siuying" , state : "WON" } ] )
70
+ game . addEvent ( [ "tag_change" , { type : "playstate" , name : "cho" , state : "LOST" } ] )
71
+ game . addEvent ( [ "tag_change" , { type : "game_start" } ] ) ;
72
+ game . addEvent ( [ "tag_change" , { type : "game_over" } ] ) ;
71
73
72
- expect ( game . toObject ( ) ) . to . deep . equal ( {
73
- mode : "ranked" ,
74
- players : [
75
- { id : 1 , name : "siuying" , first_player : true , result : "WON" } ,
76
- { id : 2 , name : "cho" , first_player : false , result : "LOST" }
77
- ] ,
78
- events : [ [ "tag_change" , { type : "player_id" , name : "siuying" , player_id : 1 } ] ,
79
- [ "tag_change" , { type : "player_id" , name : "cho" , player_id : 2 } ] ,
80
- [ "tag_change" , { type : "first_player" , name : "siuying" } ] ,
81
- [ "tag_change" , { type : "game_over" , name : "siuying" , state : "WON" } ] ,
82
- [ "tag_change" , { type : "game_over" , name : "cho" , state : "LOST" } ]
83
- ]
84
- } ) ;
74
+ var gameObj = game . toObject ( )
75
+ expect ( gameObj . players ) . to . deep . equal ( [
76
+ { id : 1 , name : "siuying" , first_player : true , result : "WON" } ,
77
+ { id : 2 , name : "cho" , first_player : false , result : "LOST" }
78
+ ] )
79
+ expect ( gameObj . events ) . to . exists
80
+ expect ( gameObj . gameStartTime ) . to . exists
81
+ expect ( gameObj . gameEndTime ) . to . exists
85
82
} ) ;
86
83
87
84
describe ( "filename" , function ( ) {
88
85
it ( "should return filename" , function ( ) {
89
- game . mode = "ranked" ;
90
86
game . addEvent ( [ "tag_change" , { type : "player_id" , name : "siuying" , player_id : 1 } ] ) ;
91
87
game . addEvent ( [ "tag_change" , { type : "player_id" , name : "cho.foo bar baz!" , player_id : 2 } ] ) ;
92
- game . addEvent ( [ "tag_change" , { type : "game_start" , timestamp : 1419332929 } ] ) ;
93
- expect ( game . filename ( ) ) . to . equal ( "1419332929_ranked_siuying_v_cho-foo-bar-baz" ) ;
88
+ game . addEvent ( [ "tag_change" , { type : "game_start" } ] ) ;
89
+ game . gameStartTime = new Date ( 1419332929 )
90
+ expect ( game . filename ( ) ) . to . equal ( "1419332929_siuying_v_cho-foo-bar-baz" ) ;
94
91
} ) ;
95
92
} ) ;
96
93
} ) ;
0 commit comments