Skip to content

Commit

Permalink
added method to disable the SlotMachine
Browse files Browse the repository at this point in the history
this method would remove the event listener from the start button
this method would be helpful if the consumer want to use the same markup
for a different slot machine.
  • Loading branch information
sarbbottam committed Aug 24, 2015
1 parent 346ca44 commit b9f7951
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/slot-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ function SlotMachine(config) {
this.startButton.addEventListener('click', start);
};

/**
* @function disable
* disable the instance of a SlotMachine
*/
this.disable = function() {
this.startButton.removeEventListener('click', start);
};

}

module.exports = SlotMachine;
6 changes: 6 additions & 0 deletions test/slot-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ describe('SlotMachine', function() {
}, 5000);
});

it('should disable the slotMachine', function() {
var spy = sinon.spy(slotMachine, 'disable');
slotMachine.disable();
assert.isTrue(spy.called);
});

// it('should result in Jackpot, for tea', function(done) {
// this.timeout(10000);
// slotMachine.reels.forEach(function(reel) {
Expand Down

0 comments on commit b9f7951

Please sign in to comment.