Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should display error', () => {
const channel = addonsMock.getChannel();
const code = 'source code';
const scope = {};
const wrapper = shallow(
);
expect(addonsMock.__channel.on).toBeCalledTimes(1);
expect(addonsMock.__channel.on).toBeCalledWith(event.UpdateSource, expect.any(Function));
expect(addonsMock.__channel.emit).toBeCalledTimes(1);
expect(addonsMock.__channel.emit).toBeCalledWith(event.LoadSource, code);
expect(wrapper.find(ErrorDisplay).exists()).toBeTruthy();
wrapper.unmount();
expect(addonsMock.__channel.removeListener).toBeCalledTimes(1);
expect(addonsMock.__channel.removeListener).toBeCalledWith(event.UpdateSource, expect.any(Function));
expect(addonsMock.__channel.emit).toBeCalledTimes(2);
expect(addonsMock.__channel.emit).toBeCalledWith(event.LoadSource, null);
});
it('should display error', () => {
const channel = addonsMock.getChannel();
const code = 'source code';
const scope = {};
const wrapper = shallow(
);
expect(addonsMock.__channel.on).toBeCalledTimes(1);
expect(addonsMock.__channel.on).toBeCalledWith(event.UpdateSource, expect.any(Function));
expect(addonsMock.__channel.emit).toBeCalledTimes(1);
expect(addonsMock.__channel.emit).toBeCalledWith(event.LoadSource, code);
expect(wrapper.find(ErrorDisplay).exists()).toBeTruthy();
wrapper.unmount();
expect(addonsMock.__channel.removeListener).toBeCalledTimes(1);
expect(addonsMock.__channel.removeListener).toBeCalledWith(event.UpdateSource, expect.any(Function));
expect(addonsMock.__channel.emit).toBeCalledTimes(2);
expect(addonsMock.__channel.emit).toBeCalledWith(event.LoadSource, null);
});
const source = 'source';
const localScope = { scopeVar: 'xxx' };
const contextScope = { scopeVar: 'zzz', scopeVar2: 'yyy' };
addLiveSource.addLiveSource(kind, source, localScope);
expect(addLiveSource.add).toBeCalledWith(kind, expect.any(Function));
const storyFn = addLiveSource.add.mock.calls[0][1];
const renderedStory = mount(storyFn({ [symbol.Scope]: contextScope }));
expect(renderedStory.type()).toBe(LivePreview);
expect(renderedStory.prop('code')).toBe(source);
expect(renderedStory.prop('scope')).toEqual({ ...contextScope, ...localScope });
expect(renderedStory.prop('channel')).toBe(addonsMock.__channel);
});
});