From 579a8f1c6c723cebc13737e5ac01424201e0c8be Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 11 Mar 2014 15:57:37 -0400 Subject: [PATCH] fix(board): emit 'badmove' with player data This is needed to simplify backend server code, otherwise it makes things a tiny bit crazy. --- test/board.spec.js | 10 ++++++++++ tictactoe.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/board.spec.js b/test/board.spec.js index d861023..f4a074a 100644 --- a/test/board.spec.js +++ b/test/board.spec.js @@ -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); + }); }); }); diff --git a/tictactoe.js b/tictactoe.js index 1c7ccf2..eca1257 100644 --- a/tictactoe.js +++ b/tictactoe.js @@ -126,7 +126,7 @@ function main() { return true; } - emit(this, 'badmove', x, y); + emit(this, 'badmove', player, x, y); return false; },