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; },