Newer
Older
import { render, screen, waitFor } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { UserActionState } from 'enums'

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

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

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

Hugo SUBTIL
committed
<ActionOnGoing userAction={userAction1} />
await userEvent.click(screen.getByText('action.details'))
expect(screen.getByRole('dialog')).toBeTruthy()