mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
commit
78b32a4c5d
@ -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';
|
||||
|
Loading…
x
Reference in New Issue
Block a user