diff --git a/test.js b/test.js index 5844fe9..f2d6c87 100644 --- a/test.js +++ b/test.js @@ -184,6 +184,7 @@ describe('Ultron', function () { assume('__ultron' in once).is.false(); assume('__ultron' in on).is.false(); + ee.removeAllListeners(); ultron.destroy(); ee = new EE(); @@ -215,14 +216,12 @@ describe('Ultron', function () { ultron.remove('foo'); assume(ee.listeners('foo').length).equals(1); assume(ee.listeners('foo')[0]).equals(foo); - }); - it('removes only our assigned `once` listeners from regular EE', function () { - var ee = new EE() - , ultron = new Ultron(ee); + ee.removeAllListeners(); + ultron.destroy(); - function foo() {} - function bar() {} + ee = new EE(); + ultron = new Ultron(ee); ee.once('foo', foo); ultron.once('foo', bar); @@ -247,6 +246,23 @@ describe('Ultron', function () { assume(ee.listeners('foo').length).equals(0); assume(ee.listeners('bar').length).equals(0); + + ee.removeAllListeners(); + ultron.destroy(); + + ee = new EE(); + ultron = new Ultron(ee); + + ultron.on('foo', foo); + ultron.on('bar', bar); + + assume(ee.listeners('foo').length).equals(1); + assume(ee.listeners('bar').length).equals(1); + + ultron.remove(); + + assume(ee.listeners('foo').length).equals(0); + assume(ee.listeners('bar').length).equals(0); }); it('removes multiple listeners based on args', function () { @@ -318,6 +334,35 @@ describe('Ultron', function () { ultron.remove(); assume(ee.listeners(s).length).equals(1); assume(ee.listeners(s)[0]).equals(foo); + + ee.removeAllListeners(); + ultron.destroy(); + + ee = new EE(); + ultron = new Ultron(ee); + + ee.on(s, foo); + ultron.on(s, bar); + assume(ee.listeners(s).length).equals(2); + + ultron.remove(s); + assume(ee.listeners(s).length).equals(1); + assume(ee.listeners(s)[0]).equals(foo); + + ultron.once(s, bar); + assume(ee.listeners(s).length).equals(2); + + ultron.remove(s); + assume(ee.listeners(s).length).equals(1); + assume(ee.listeners(s)[0]).equals(foo); + + ultron.on(s, bar); + ultron.on(s, baz); + assume(ee.listeners(s).length).equals(3); + + ultron.remove(); + assume(ee.listeners(s).length).equals(1); + assume(ee.listeners(s)[0]).equals(foo); }); });