Newer
Older
import EcogestureModal from 'components/Ecogesture/EcogestureModal/EcogestureModal'
import { UserActionState } from 'enums'
import { mount } from 'enzyme'

Hugo SUBTIL
committed
import { UserAction } from 'models'
import React from 'react'
import { Provider } from 'react-redux'
import { defaultEcogestureData } from 'tests/__mocks__/actionData.mock'
import { createMockEcolyoStore } from 'tests/__mocks__/store'
import { waitForComponentToPaint } from 'tests/__mocks__/testUtils'
import ActionOnGoing from './ActionOnGoing'

Hugo SUBTIL
committed
const userAction: UserAction = {
// TODO if ecogesture is null snapshot test is useless

Hugo SUBTIL
committed
ecogesture: null,
.setZone('utc', {
keepLocalTime: true,
})
.startOf('day'),
it('should render correctly', async () => {
const wrapper = mount(
<Provider store={store}>
<ActionOnGoing userAction={userAction} />
</Provider>
)
await waitForComponentToPaint(wrapper)
expect(toJson(wrapper)).toMatchSnapshot()

Hugo SUBTIL
committed
it('should click on button open ecogesture Modal', async () => {
const userAction1: UserAction = {
ecogesture: defaultEcogestureData[1],
startDate: null,
state: UserActionState.ONGOING,
}
const wrapper = mount(
<Provider store={store}>

Hugo SUBTIL
committed
<ActionOnGoing userAction={userAction1} />
wrapper.find(Button).first().simulate('click')
expect(wrapper.find(EcogestureModal).exists()).toBeTruthy()
})
})