From 0eaf239fb9961ce42457f37838099645712353f5 Mon Sep 17 00:00:00 2001 From: hypnos Date: Sun, 20 Aug 2017 20:59:54 +0300 Subject: [PATCH] Fix test --- .../modules/ui/components/search_box.test.js | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/ui/src/modules/ui/components/search_box.test.js b/lib/ui/src/modules/ui/components/search_box.test.js index 2129b5d3c9ec..48c47196d9f3 100644 --- a/lib/ui/src/modules/ui/components/search_box.test.js +++ b/lib/ui/src/modules/ui/components/search_box.test.js @@ -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'; @@ -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(); + const wrap = shallow( + + ); - 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(); }); });