Clean up Channel test

This commit is contained in:
Adam Jahnke 2019-10-29 14:55:05 -05:00
parent 1fff1b397f
commit c812ee0163

View File

@ -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';