Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar committed May 15, 2012
1 parent 9dd1920 commit 78799e4
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions test/unit/gameSpec.js
Expand Up @@ -29,12 +29,13 @@ describe('Game', function() {


beforeEach(function() {
// this is messy because Game constructor is non-deterministic - it should be refactored
tile1a = game.grid[0][0];

// this is weird because Game constructor is non-deterministic, this should be refactored
if (tile1a.title === game.grid[0][1].title) {
tile1b = game.grid[0][1];
tile2a = game.grid[1][0];
tile2b = game.grid[1][1];
} else {
tile2a = game.grid[0][1];

Expand All @@ -56,14 +57,6 @@ describe('Game', function() {
});


xit('should update the image name when a tile is flipped', function() {
expect(tile1a.imgName()).toBe('back');

game.flipTile(tile1a);
expect(tile1a.imgName()).not.toBe('back');
});


it('should turn back first two cards when miss and third card is flipped', function() {
game.flipTile(tile1a);
game.flipTile(tile2a);
Expand Down Expand Up @@ -102,5 +95,28 @@ describe('Game', function() {
expect(tile2b.flipped).toBe(true);
expect(game.unmatchedPairs).toBe(0);
});


it('should keep the message model up to date during the game', function() {
expect(game.message).toBe(Game.MESSAGE_CLICK);

game.flipTile(tile1a);
expect(game.message).toBe(Game.MESSAGE_ONE_MORE);

game.flipTile(tile2b);
expect(game.message).toBe(Game.MESSAGE_MISS);

game.flipTile(tile1b);
expect(game.message).toBe(Game.MESSAGE_ONE_MORE);

game.flipTile(tile1a);
expect(game.message).toBe(Game.MESSAGE_MATCH);

game.flipTile(tile2b);
expect(game.message).toBe(Game.MESSAGE_ONE_MORE);

game.flipTile(tile2a);
expect(game.message).toBe(Game.MESSAGE_WON);
});
});
});

0 comments on commit 78799e4

Please sign in to comment.