Skip to content

Commit

Permalink
base - destroy only once
Browse files Browse the repository at this point in the history
  • Loading branch information
newagebegins committed Jun 19, 2012
1 parent 060d78a commit 0e5d682
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spec/BaseSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ describe("Base", function () {
var base = new Base(eventManager);
spyOn(eventManager, 'fireEvent');
base.hit();
expect(eventManager.fireEvent).toHaveBeenCalledWith({'name': Base.Event.HIT, 'base': base});
var EVENT = {'name': Base.Event.HIT, 'base': base};
expect(eventManager.fireEvent).toHaveBeenCalledWith(EVENT);
eventManager.fireEvent.reset();
base.hit();
expect(eventManager.fireEvent).not.toHaveBeenCalledWith(EVENT);
});
});
3 changes: 3 additions & 0 deletions src/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Base.prototype.notify = function (event) {
};

Base.prototype.hit = function () {
if (this._hit) {
return;
}
this._hit = true;
this._eventManager.fireEvent({'name': Base.Event.HIT, 'base': this});
};
Expand Down

0 comments on commit 0e5d682

Please sign in to comment.