Skip to content

Commit 5ea4467

Browse files
committedNov 29, 2015
update broken tests
1 parent e936ca0 commit 5ea4467

File tree

3 files changed

+19
-230
lines changed

3 files changed

+19
-230
lines changed
 

‎test/game_test.js

+18-21
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Game', function(){
3636

3737
it("should set result", function(){
3838
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"}]);
4040

4141
var siuying = game.players[0];
4242
expect(siuying.result).to.equal("WON");
@@ -54,8 +54,8 @@ describe('Game', function(){
5454
it("should return true when game has ended", function(){
5555
game.addEvent(["tag_change", {type: "player_id", name: "siuying", player_id: 1}]);
5656
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"}])
5959
expect(game.isCompleted()).to.equal(true);
6060
})
6161
});
@@ -66,31 +66,28 @@ describe('Game', function(){
6666
game.addEvent(["tag_change", {type: "player_id", name: "siuying", player_id: 1}]);
6767
game.addEvent(["tag_change", {type: "player_id", name: "cho", player_id: 2}]);
6868
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"}]);
7173

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
8582
});
8683

8784
describe("filename", function(){
8885
it("should return filename", function(){
89-
game.mode = "ranked";
9086
game.addEvent(["tag_change", {type: "player_id", name: "siuying", player_id: 1}]);
9187
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");
9491
});
9592
});
9693
});

‎test/parser_test.js

-208
This file was deleted.

‎test/zone_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Zone', function(){
2424
it('should parse friendly card zone change', function(){
2525
line = "D 19:52:05.0011970 ZoneChangeList.ProcessChanges() - id=1 local=False [id=37 cardId= type=INVALID zone=DECK zonePos=0 player=2] zone from -> FRIENDLY DECK"
2626
result = parser.parseLine(Zone.parsers, line);
27-
expect(result).to.deep.equal(["zone_change", {"card_id": "", "from_zone": "OPPOSING DECK", "id": 25, "player_id": 1, "to_zone": "OPPOSING HAND"}]);
27+
expect(result).to.deep.equal(["zone_change", {"card_id": "", "from_zone": "", "id": 37, "player_id": 2, "to_zone": "FRIENDLY DECK"}]);
2828

2929
line = "D 19:55:11.4950970 ZoneChangeList.ProcessChanges() - id=33 local=False [name=Northshire Cleric id=61 zone=HAND zonePos=0 cardId=CS2_235 player=2] zone from FRIENDLY DECK -> FRIENDLY HAND"
3030
result = parser.parseLine(Zone.parsers, line);

0 commit comments

Comments
 (0)