Skip to content

Commit

Permalink
fix(board): emit 'badmove' with player data
Browse files Browse the repository at this point in the history
This is needed to simplify backend server code, otherwise it makes things a tiny bit crazy.
  • Loading branch information
caitp committed Mar 11, 2014
1 parent 1121c04 commit 579a8f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions test/board.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,15 @@ describe('Board', function() {
expect(callback).toHaveBeenCalled();
expect(callback2).toHaveBeenCalled();
});


it('should emit badmove event with player, x position and y position data', function() {
var callback = jasmine.createSpy('badmove');
board.on('badmove', callback);
board.move('X', 0, 0);
board.move('Y', 0, 0);
expect(callback.callCount).toBe(1);
expect(callback).toHaveBeenCalledWith(jasmine.any(Object), 'Y', 0, 0);
});
});
});
2 changes: 1 addition & 1 deletion tictactoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function main() {

return true;
}
emit(this, 'badmove', x, y);
emit(this, 'badmove', player, x, y);
return false;
},

Expand Down

0 comments on commit 579a8f1

Please sign in to comment.