forked from SpookyJS/SpookyJS
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inherit Spooky from EventEmitter correctly
Previously, the constructor did not pass new instances through EventEmitter, so all Spooky instances shared the same EventEmitter instance state. Instead, use util.inherits and call EventEmitter when constructing Spooky instances. Thanks to @tomchentw for figuring this one out. Close SpookyJS#51, SpookyJS#60
- Loading branch information
Showing
2 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var Spooky = require('../../lib/spooky'); | ||
var expect = require('expect.js'); | ||
|
||
describe('Spooky instances', function () { | ||
it('do not share events', function () { | ||
var called = false; | ||
var x = new Spooky({}); | ||
var y = new Spooky({}); | ||
|
||
x.on('test', function () { called = true; }); | ||
y.emit('test'); | ||
|
||
expect(called).not.to.be(true); | ||
}); | ||
}); |