From c812ee0163a42cb4fef8942de5cdbc38bfe52e82 Mon Sep 17 00:00:00 2001 From: Adam Jahnke Date: Tue, 29 Oct 2019 14:55:05 -0500 Subject: [PATCH] Clean up Channel test --- lib/channels/src/index.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/channels/src/index.test.ts b/lib/channels/src/index.test.ts index 3a440fc229e..0f8b8ceceb9 100644 --- a/lib/channels/src/index.test.ts +++ b/lib/channels/src/index.test.ts @@ -51,11 +51,23 @@ describe('Channel', () => { it('should do the same as addListener', () => { const eventName = 'event1'; - channel.addListener(eventName, jest.fn()); + channel.on(eventName, jest.fn()); expect(channel.listeners(eventName).length).toBe(1); }); }); + describe('method:off', () => { + it('should remove listeners', () => { + const eventName = 'event1'; + const fn = jest.fn(); + + channel.on(eventName, fn); + expect(channel.listeners(eventName).length).toBe(1); + channel.off(eventName, fn); + expect(channel.listeners(eventName).length).toBe(0); + }); + }); + describe('method:emit', () => { it('should execute the callback fn of a listener', () => { const eventName = 'event1';