Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/llle_project/ecolyo
1 result
Show changes
Commits on Source (2)
Showing
with 39 additions and 28 deletions
......@@ -29,8 +29,15 @@ module.exports = {
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['**/*.spec.{ts,tsx}'],
extends: ['plugin:jest/recommended'],
rules: {
'jest/no-mocks-import': 0,
},
},
],
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
plugins: ['@typescript-eslint', 'react', 'react-hooks', 'jest'],
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
......
......@@ -47,6 +47,7 @@
"sonarlint.connectedMode.project": {
"projectKey": "ecolyo"
},
"gitlens.remotes": [{ "type": "GitLab", "domain": "forge.grandlyon.com" }],
"cSpell.language": "fr,en",
"cSpell.words": [
"authform",
......
......@@ -69,7 +69,7 @@ describe('ActionBegin component', () => {
await waitForComponentToPaint(wrapper)
expect(wrapper.find('.action-title').text()).toBe('Coup de vent')
})
it('should render chosen action ', async () => {
it('should render chosen action', async () => {
const store = createMockEcolyoStore({
global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
profile: mockProfileState,
......@@ -87,7 +87,7 @@ describe('ActionBegin component', () => {
await waitForComponentToPaint(wrapper)
expect(wrapper.find(ActionBegin).exists()).toBeTruthy()
})
it('should open launch Modal ', async () => {
it('should open launch Modal', async () => {
const store = createMockEcolyoStore({
global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
profile: mockProfileState,
......@@ -107,7 +107,7 @@ describe('ActionBegin component', () => {
expect(wrapper.find(ActionModal).exists()).toBeTruthy()
expect(wrapper.find(ActionModal).prop('open')).toBeTruthy()
})
it('should go to the list ', async () => {
it('should go to the list', async () => {
const store = createMockEcolyoStore({
global: { ...mockGlobalState, fluidTypes: [0, 1, 2] },
profile: mockProfileState,
......
......@@ -45,6 +45,6 @@ describe('ActionDone component', () => {
)
wrapper.find(Button).first().simulate('click')
await waitForComponentToPaint(wrapper)
expect(updateChallengeSpy).toBeCalledTimes(1)
expect(updateChallengeSpy).toHaveBeenCalledTimes(1)
})
})
......@@ -7,6 +7,7 @@ import {
mockChallengeState,
mockProfileState,
} from 'tests/__mocks__/store'
import { waitForComponentToPaint } from 'tests/__mocks__/testUtils'
import ActionCard from '../ActionCard/ActionCard'
import ActionList from './ActionList'
......@@ -21,7 +22,7 @@ jest.mock('services/action.service', () => {
})
describe('ActionList component', () => {
it('should be rendered correctly', () => {
it('should be rendered correctly', async () => {
mockGetDefaultActions.mockResolvedValueOnce(defaultEcogestureData)
const store = createMockEcolyoStore({
challenge: { ...mockChallengeState },
......@@ -33,6 +34,7 @@ describe('ActionList component', () => {
<ActionList setSelectedAction={jest.fn()} setShowList={jest.fn()} />
</Provider>
)
expect(wrapper.find(ActionCard).exists())
await waitForComponentToPaint(wrapper)
expect(wrapper.find(ActionCard)).toBeTruthy()
})
})
......@@ -56,6 +56,6 @@ describe('ActionModal component', () => {
)
wrapper.find(Button).first().simulate('click')
await waitForComponentToPaint(wrapper)
expect(updateChallengeSpy).toBeCalledTimes(1)
expect(updateChallengeSpy).toHaveBeenCalledTimes(1)
})
})
......@@ -67,11 +67,11 @@ describe('AnalysisView component', () => {
expect(wrapper.find('mock-header').exists()).toBeTruthy()
expect(wrapper.find('mock-datenavigator').exists()).toBeTruthy()
expect(wrapper.find('mock-monthlyanalysis').exists()).toBeTruthy()
expect(updateProfileSpy).toBeCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledWith({
haveSeenLastAnalysis: true,
})
expect(toggleAnalysisNotificationSpy).toBeCalledTimes(1)
expect(toggleAnalysisNotificationSpy).toHaveBeenCalledTimes(1)
expect(toggleAnalysisNotificationSpy).toHaveBeenCalledWith(false)
})
})
......@@ -205,6 +205,6 @@ describe('AnalysisConsumption component', () => {
)
await waitForComponentToPaint(wrapper)
wrapper.find(Button).first().simulate('click')
expect(mockedNavigate).toBeCalledWith('/profileType')
expect(mockedNavigate).toHaveBeenCalledWith('/profileType')
})
})
......@@ -49,11 +49,11 @@ describe('ChallengeCardDone component', () => {
)
wrapper.find(Button).last().simulate('click')
await waitForComponentToPaint(wrapper)
expect(mockDispatch).toBeCalledTimes(1)
expect(mockDispatch).toBeCalledWith({
expect(mockDispatch).toHaveBeenCalledTimes(1)
expect(mockDispatch).toHaveBeenCalledWith({
type: 'challenge/updateUserChallengeList',
})
expect(mockUpdateUserChallenge).toBeCalledTimes(1)
expect(mockUpdateUserChallenge).toHaveBeenCalledTimes(1)
})
it('should not reset challenge if another challenge is on going', async () => {
mockAppDispatch.mockImplementationOnce(() => mockDispatch)
......@@ -69,8 +69,8 @@ describe('ChallengeCardDone component', () => {
)
wrapper.find(Button).last().simulate('click')
await waitForComponentToPaint(wrapper)
expect(mockDispatch).toBeCalledTimes(0)
expect(mockUpdateUserChallenge).toBeCalledTimes(0)
expect(mockDispatch).toHaveBeenCalledTimes(0)
expect(mockUpdateUserChallenge).toHaveBeenCalledTimes(0)
})
it('should be primary button is challenge is lost', async () => {
const wrapper = mount(
......
......@@ -17,7 +17,7 @@ describe('ChallengeCardLast component', () => {
const wrapper = mount(<ChallengeCardLast />)
wrapper.find('.btn_lastCard').first().simulate('click')
expect(window.open).toBeCalledTimes(1)
expect(window.open).toHaveBeenCalledTimes(1)
expect(global.open).toHaveBeenCalledWith(
`${__SAU_IDEA_DIRECT_LINK__}?version=0.0.0`
)
......
......@@ -130,7 +130,7 @@ describe('Bar component test', () => {
</Provider>
)
wrapper.find('rect').first().simulate('click')
expect(setSelectedDateSpy).toBeCalledTimes(1)
expect(setSelectedDateSpy).toHaveBeenCalledTimes(1)
expect(setSelectedDateSpy).toHaveBeenCalledWith(
graphData.actualData[0].date
)
......
......@@ -20,7 +20,7 @@ describe('ConsumptionDetails component', () => {
expect(toJson(wrapper)).toMatchSnapshot()
})
it('should not render connection card ', () => {
it('should not render connection card', () => {
const wrapper = mount(
<Provider store={store}>
<ConsumptionDetails fluidType={FluidType.MULTIFLUID} />
......@@ -28,7 +28,7 @@ describe('ConsumptionDetails component', () => {
)
expect(wrapper.contains('.fluidcard-link')).toBeFalsy()
})
it('should render one connection card ', () => {
it('should render one connection card', () => {
const wrapper = mount(
<Provider store={store}>
<ConsumptionDetails fluidType={FluidType.MULTIFLUID} />
......
......@@ -132,7 +132,7 @@ describe('ConsumptionView component', () => {
<ConsumptionView fluidType={FluidType.GAS} />
</Provider>
)
expect(setCurrentTimeStepSpy).toBeCalledTimes(1)
expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1)
expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.WEEK)
})
......
......@@ -109,6 +109,6 @@ describe('DataloadNoValue component', () => {
/>
)
wrapper.find('.dataloadvisualizer-content').simulate('click')
expect(mockSetActive).toBeCalledWith(true)
expect(mockSetActive).toHaveBeenCalledWith(true)
})
})
......@@ -105,7 +105,7 @@ describe('DataloadSectionValue component', () => {
/>
)
wrapper.find('.estimated').simulate('click')
expect(mockToggleEstimationModal).toBeCalled()
expect(mockToggleEstimationModal).toHaveBeenCalled()
})
})
})
......@@ -77,7 +77,7 @@ describe('DuelView component', () => {
expect(wrapper.find(DuelError).exists()).toBeTruthy()
})
it('should be rendered with DuelError component when current challenge with state != duel ', () => {
it('should be rendered with DuelError component when current challenge with state != duel', () => {
const updatedUserChallenge = {
...userChallengeData[1],
state: UserChallengeState.ONGOING,
......
......@@ -17,7 +17,7 @@ describe('EcogestureInitModal component', () => {
)
expect(toJson(wrapper)).toMatchSnapshot()
})
it('should close modal ', () => {
it('should close modal', () => {
const wrapper = mount(
<EcogestureInitModal
open={true}
......
......@@ -62,7 +62,7 @@ describe('EcogesturesList component', () => {
wrapper.find(Button).first().simulate('click')
expect(wrapper.find('.filter-menu').exists()).toBeTruthy()
wrapper.find(MenuItem).at(1).simulate('click')
expect(updateEcogestureFilter).toBeCalledTimes(1)
expect(updateEcogestureFilter).toHaveBeenCalledTimes(1)
})
it('should display the selection section', async () => {
......
......@@ -45,7 +45,7 @@ describe('EcogestureFormEquipment component', () => {
wrapper.find('.item-eq').first().simulate('change')
await waitForComponentToPaint(wrapper)
expect(wrapper.find('.item-eq').first().hasClass('checked')).toBeTruthy
expect(wrapper.find('.item-eq').first().hasClass('checked')).toBeTruthy()
wrapper.find('.checked').first().simulate('change')
await waitForComponentToPaint(wrapper)
expect(wrapper.find('.item-eq').first().hasClass('checked')).toBeFalsy()
......