diff --git a/src/components/Ecogesture/EcogestureCard/EcogestureCard.spec.tsx b/src/components/Ecogesture/EcogestureCard/EcogestureCard.spec.tsx index 836668c817c2485778f5debce45af380ada292d5..d00c057dc48a14e90d9d74f237f72e37e0f51fb6 100644 --- a/src/components/Ecogesture/EcogestureCard/EcogestureCard.spec.tsx +++ b/src/components/Ecogesture/EcogestureCard/EcogestureCard.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/display-name */ import EcogestureCard from 'components/Ecogesture/EcogestureCard/EcogestureCard' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' diff --git a/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx index 9be727a778cd04ebaf2e275cca80ad241fe8f4b4..2fda3b550431c1b0b25d65a40c8bf539eb4e9ecb 100644 --- a/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx +++ b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/display-name */ import { Button } from '@material-ui/core' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' diff --git a/src/components/Ecogesture/SingleEcogestureView.spec.tsx b/src/components/Ecogesture/SingleEcogestureView.spec.tsx index 4d889d7d5524c9f20f26fb605c25f052548f177d..6f96223ab2bd6d147f16ddb66bb582b7065916d3 100644 --- a/src/components/Ecogesture/SingleEcogestureView.spec.tsx +++ b/src/components/Ecogesture/SingleEcogestureView.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/display-name */ import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import React from 'react' diff --git a/src/components/EcogestureForm/EcogestureFormView.spec.tsx b/src/components/EcogestureForm/EcogestureFormView.spec.tsx index 77256f6dc3a6203aa1fd52e46c032f4db2f70854..35e92dd4a31b2bd8a576fcc79410f1666991adb7 100644 --- a/src/components/EcogestureForm/EcogestureFormView.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormView.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/display-name */ import { Button } from '@material-ui/core' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' diff --git a/src/components/EcogestureForm/EquipmentIcon/EquipmentIcon.spec.tsx b/src/components/EcogestureForm/EquipmentIcon/EquipmentIcon.spec.tsx index 6d248173c0e505d11a7d2ed6f6b4e94de80229ac..7fe4d6d3dd1aac6b228b84a22d18eaba53b582ed 100644 --- a/src/components/EcogestureForm/EquipmentIcon/EquipmentIcon.spec.tsx +++ b/src/components/EcogestureForm/EquipmentIcon/EquipmentIcon.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/display-name */ import { EquipmentType } from 'enums' import { mount } from 'enzyme' import toJson from 'enzyme-to-json' diff --git a/src/components/EcogestureSelection/EcogestureSelectionView.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionView.spec.tsx index 234ba798c846879c520b2fdc1091dcbb1e3ea964..ad65360fb1bfdb70f3a60b985b10d2ce9489114d 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionView.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionView.spec.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/display-name */ import { mount } from 'enzyme' import toJson from 'enzyme-to-json' import React from 'react' diff --git a/src/components/Quiz/QuizQuestion/QuizQuestion.spec.tsx b/src/components/Quiz/QuizQuestion/QuizQuestion.spec.tsx index 1421e6ce31b630dbe81e2859b64ccc84908c5ffa..bd99fbd4cbbe0e111f9c822566ef651077bc0d69 100644 --- a/src/components/Quiz/QuizQuestion/QuizQuestion.spec.tsx +++ b/src/components/Quiz/QuizQuestion/QuizQuestion.spec.tsx @@ -1,28 +1,29 @@ -/* eslint-disable react/display-name */ import { UserQuestionState } from 'enums' import { mount } from 'enzyme' import React from 'react' import { Provider } from 'react-redux' import { createMockEcolyoStore } from 'tests/__mocks__/store' +import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock' import QuizQuestion from './QuizQuestion' -const mockgetCustomQuestion = jest.fn() +const mockGetCustomQuestion = jest.fn() jest.mock('services/quiz.service', () => { return jest.fn(() => { return { - getCustomQuestion: mockgetCustomQuestion, + getCustomQuestion: mockGetCustomQuestion, } }) }) jest.mock( 'components/Quiz/QuizQuestion/QuizQuestionContentCustom', - () => () => <div id="QuizQuestionContentCustom" /> + () => 'mock-customQuestion' +) +jest.mock( + 'components/Quiz/QuizQuestion/QuizQuestionContent', + () => 'mock-question' ) -jest.mock('components/Quiz/QuizQuestion/QuizQuestionContent', () => () => ( - <div id="quizquestioncontent" /> -)) describe('QuizQuestion component', () => { const store = createMockEcolyoStore() @@ -30,17 +31,18 @@ describe('QuizQuestion component', () => { store.clearActions() }) - it('should be rendered correctly with question', () => { + it('should be rendered correctly with question', async () => { const wrapper = mount( <Provider store={store}> <QuizQuestion userChallenge={userChallengeData[0]} /> </Provider> ) - expect(wrapper.find('#quizquestioncontent').exists()).toBeTruthy() - expect(wrapper.find('#QuizQuestionContentCustom').exists()).toBeFalsy() + await waitForComponentToPaint(wrapper) + expect(wrapper.find('mock-question').exists()).toBeTruthy() + expect(wrapper.find('mock-customQuestion').exists()).toBeFalsy() }) - it('should be rendered correctly with customQuestion', () => { + it('should be rendered correctly with customQuestion', async () => { const updateUserChallengeData = { ...userChallengeData[0], } @@ -52,7 +54,8 @@ describe('QuizQuestion component', () => { <QuizQuestion userChallenge={updateUserChallengeData} /> </Provider> ) - expect(wrapper.find('#quizquestioncontent').exists()).toBeFalsy() - expect(wrapper.find('#QuizQuestionContentCustom').exists()).toBeTruthy() + await waitForComponentToPaint(wrapper) + expect(wrapper.find('mock-question').exists()).toBeFalsy() + expect(wrapper.find('mock-customQuestion').exists()).toBeTruthy() }) })