Fix tests

This commit is contained in:
hypnos 2017-10-01 03:07:09 +03:00
parent a306d2bd1b
commit cd0291d5e0
3 changed files with 18 additions and 20 deletions

View File

@ -1,18 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`LinkTo render should render a link 1`] = `
<LinkTo
kind="foo"
story="bar"
>
<RoutedLink
href="?selectedKind=foo&selectedStory=bar"
onClick={[Function]}
>
<a
href="?selectedKind=foo&selectedStory=bar"
onClick={[Function]}
/>
</RoutedLink>
</LinkTo>
<RoutedLink
href="?selectedKind=undefined&selectedStory=undefined"
onClick={[Function]}
/>
`;

View File

@ -1,4 +1,4 @@
import { shallow, mount } from 'enzyme';
import { shallow } from 'enzyme';
import React from 'react';
import addons from '@storybook/addons';
@ -14,8 +14,9 @@ describe('LinkTo', () => {
const channel = mockChannel();
addons.getChannel.mockReturnValue(channel);
const wrapper = mount(<LinkTo kind="foo" story="bar" />);
const wrapper = shallow(<LinkTo kind="foo" story="bar" />);
await wrapper.instance().updateHref(wrapper.props());
wrapper.update();
expect(wrapper).toMatchSnapshot();
});
});

View File

@ -265,7 +265,7 @@ describe('manager.ui.components.left_panel.stories', () => {
});
describe('events', () => {
test('should call the onSelectStory prop when a collapsed kind is clicked', () => {
test('should not call the onSelectStory prop when a collapsed kind is clicked', () => {
const onSelectStory = jest.fn();
const wrap = mount(
<Stories
@ -281,7 +281,7 @@ describe('manager.ui.components.left_panel.stories', () => {
const kind = wrap.find('[data-name="a"]').first();
kind.simulate('click', leftClick);
expect(onSelectStory).toHaveBeenCalledWith('a', null);
expect(onSelectStory).not.toHaveBeenCalled();
});
test("shouldn't call the onSelectStory prop when an expanded kind is clicked", () => {
@ -356,7 +356,7 @@ describe('manager.ui.components.left_panel.stories', () => {
.first()
.simulate('click', leftClick);
expect(onSelectStory).toHaveBeenCalledWith('another.space.20', null);
expect(onSelectStory).not.toHaveBeenCalled();
wrap
.find('[data-name="b2"]')
@ -384,6 +384,8 @@ describe('manager.ui.components.left_panel.stories', () => {
.first()
.simulate('keyDown', { keyCode: 13 });
expect(onSelectStory).not.toHaveBeenCalled();
wrap
.find('[data-name="space"]')
.first()
@ -395,7 +397,12 @@ describe('manager.ui.components.left_panel.stories', () => {
.first()
.simulate('click', leftClick);
expect(onSelectStory).toHaveBeenCalledWith('another.space.20', null);
wrap
.find('[data-name="b2"]')
.first()
.simulate('click', leftClick);
expect(onSelectStory).toHaveBeenCalledWith('another.space.20', 'b2');
});
});
});