Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypnosphi authored and danielduan committed Aug 27, 2017
1 parent 1ac70f8 commit 0eaf239
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/ui/src/modules/ui/components/search_box.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { shallow, mount } from 'enzyme';
import { shallow } from 'enzyme';
import React from 'react';
import ReactModal from 'react-modal';
import FuzzySearch from '@storybook/react-fuzzy';
import FuzzySearch from 'react-fuzzy';

import SearchBox from './search_box';

Expand Down Expand Up @@ -106,14 +106,27 @@ describe('manager.ui.components.search_box', () => {
});

test('should handle selecting a story with click', () => {
const stories = [
{
kind: 'a',
stories: ['b', 'c'],
},
];
const onSelectStory = jest.fn();
const onClose = jest.fn();
const wrap = mount(<SearchBox onSelectStory={onSelectStory} onClose={onClose} />);
const wrap = shallow(
<SearchBox onSelectStory={onSelectStory} onClose={onClose} stories={stories} />
);

const option = wrap.findWhere(el => el.key() === 'a');
const modal = wrap.find(FuzzySearch).dive();
modal.find('input').simulate('change', {
target: { value: 'b' },
});

const option = modal.findWhere(el => el.key() === 'b');
option.simulate('click');

expect(onSelectStory).toHaveBeenCalledWith('b', 'a');
expect(onSelectStory).toHaveBeenCalledWith('a', 'b');
expect(onClose).toHaveBeenCalled();
});
});
Expand Down

0 comments on commit 0eaf239

Please sign in to comment.