From 0cce8fa09eb7f7d359c001a9b711c3369372dcaf Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 22 Jun 2021 18:24:42 -0400 Subject: [PATCH] Add test for #124 --- test/index_test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/index_test.ts b/test/index_test.ts index ba1dbff..723dfa6 100644 --- a/test/index_test.ts +++ b/test/index_test.ts @@ -150,6 +150,17 @@ describe('mitt#', () => { inst.off('foo', foo); expect(events.get('foo')).to.deep.equal([]); }); + + it('off("type") should remove all handlers of the given type', () => { + inst.on('foo', () => {}); + inst.on('foo', () => {}); + inst.on('bar', () => {}); + inst.off('foo'); + expect(events.get('foo')).to.deep.equal([]); + expect(events.get('bar')).to.have.length(1); + inst.off('bar'); + expect(events.get('bar')).to.deep.equal([]); + }); }); describe('emit()', () => {