Merge "Add tests to Inventory module"
[aai/sparky-fe.git] / test / generic-components / autoCompleteSearchBar / AutoCompleteSearchBar.test.js
1 import React from 'react';
2 import { shallow } from 'enzyme';
3 import {Provider} from 'react-redux'
4 import configureStore from 'redux-mock-store';
5
6 import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx';
7
8 describe('AutoCompleteSearchBarTests', () => {
9   const suggestions = [
10     {
11       text: 'Apple'
12     },
13     {
14       text: 'Orange'
15     },
16     {
17       text: 'Banana'
18     }
19   ];
20   const initialState = {
21     globalAutoCompleteSearchBarReducer: {
22       value: '',
23       suggestions: [],
24       cachedSuggestions: [],
25       suggestionName: ''
26     }
27   };
28   const mockStore = configureStore();
29   let store, wrapper;
30
31   beforeEach( () => {
32     store = mockStore(initialState);
33     wrapper = shallow(<Provider store={store}><AutoCompleteSearchBar /></Provider>);
34   })
35
36   it('render search bar - visible', () => {
37     expect(wrapper).toHaveLength(1); // ensure the message bar is mounted
38     expect(wrapper.find(AutoCompleteSearchBar)).toHaveLength(1); // ensure the InlineMessage is mounted
39   });
40 })