import React from 'react' ; import { ReactWrapper } from 'enzyme' ; import { createTestComponent , createTestStore , flushPromises } from '@client/tests/util' ; import { LocationPicker } from './LocationPicker' ; import { AppStore } from '@client/store' ; import { waitForElement } from '@client/tests/wait-for-element' ; describe ( 'location picker tests' , ( ) => { let store ; let component ; const onChangeLocationMock = jest . fn ( ) ; beforeAll ( async ( ) => { store = ( await createTestStore ( ) ) . store ; } ) ; beforeEach ( async ( ) => { component = ( await createTestComponent ( < LocationPicker selectedLocationId = "bfe8306c-0910-48fe-8bf5-0db906cf3155" onChangeLocation = { onChangeLocationMock } / > , store , null , { attachTo : document . body } ) ) . component ; } ) ; afterEach ( ( ) => { component . unmount ( ) ; } ) ; it ( 'renders location name' , async ( ) => { const actionElement = await waitForElement ( component , '#location-range-picker-action' ) ; expect ( actionElement . hostNodes ( ) . text ( ) ) . toBe ( 'Baniajan Union Parishad' ) ; } ) ; it ( 'focuses input on click action' , async ( ) => { const actionElement = await waitForElement ( component , '#location-range-picker-action' ) ; actionElement . hostNodes ( ) . simulate ( 'click' ) ; await flushPromises ( ) ; component . update ( ) ; const searchInputElement = await waitForElement ( component , 'input#locationSearchInput' ) ; expect ( searchInputElement . hostNodes ( ) . getDOMNode ( ) ) . toEqual ( document . activeElement ) ; } ) ; } ) ;