Newer
Older
import { render, screen } from '@testing-library/react'
import { FluidState, FluidType } from 'enums'
import React from 'react'
import { Provider } from 'react-redux'
import { createMockEcolyoStore, mockGlobalState } from 'tests/__mocks__/store'
import FluidButton from './FluidButton'
describe('FluidButton component', () => {
it('should be rendered correctly', async () => {
<Provider store={store}>
<FluidButton fluidType={FluidType.ELECTRICITY} isActive={false} />
</Provider>
})
it('should render multifluidButton', () => {
<Provider store={store}>
<FluidButton fluidType={FluidType.MULTIFLUID} isActive={false} />
</Provider>
)
expect(screen.getByText('FLUID.MULTIFLUID.LABEL')).toBeInTheDocument()
it('should render active gas button', () => {
<FluidButton fluidType={FluidType.GAS} isActive={true} />
expect(container.getElementsByClassName('active').length).toBeTruthy()

Guilhem CARRON
committed
it('should render errored button', () => {
const updatedInitialState: GlobalState = {
...mockGlobalState,

Guilhem CARRON
committed
}
updatedInitialState.fluidStatus[FluidType.GAS].status = FluidState.ERROR
const store = createMockEcolyoStore({
global: updatedInitialState,

Guilhem CARRON
committed
})

Guilhem CARRON
committed
<FluidButton fluidType={FluidType.GAS} isActive={false} />
</Provider>
)
const element = container.getElementsByClassName('notif-error').item(0)
expect(element).toBeInTheDocument()

Guilhem CARRON
committed
})