diff --git a/src/components/Consumption/ConsumptionView.spec.tsx b/src/components/Consumption/ConsumptionView.spec.tsx index c654401923706cd42ec0a7ca9772dfdbf322dee6..722bc1e095e35f5a3b34289362af37c8ec2cc89f 100644 --- a/src/components/Consumption/ConsumptionView.spec.tsx +++ b/src/components/Consumption/ConsumptionView.spec.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { FluidState, FluidType, TimeStep } from 'enums' import React from 'react' import { Provider } from 'react-redux' @@ -122,7 +122,7 @@ describe('ConsumptionView component', () => { ).toBeTruthy() }) - it('should render mutlifluid consumption if at least one fluid is connected', () => { + it('should render mutlifluid consumption if at least one fluid is connected without konnectorViewerCard', async () => { const store = createMockEcolyoStore({ chart: mockChartStateShowOffline, global: { @@ -136,12 +136,16 @@ describe('ConsumptionView component', () => { <ConsumptionView fluidType={FluidType.MULTIFLUID} /> </Provider> ) + await waitFor(() => null, { container }) expect( - container.getElementsByClassName('consumptionview-content')[0] + container.getElementsByTagName('mock-consumptionDetails').item(0) ).toBeInTheDocument() + expect( + container.getElementsByTagName('mock-konnectorViewerCard').item(0) + ).not.toBeInTheDocument() }) - it('should render Electricity when elec is connected', () => { + it('should render Electricity when elec is connected with konnectorViewCard', async () => { const store = createMockEcolyoStore({ chart: mockChartStateShowOffline, global: { @@ -155,11 +159,12 @@ describe('ConsumptionView component', () => { <ConsumptionView fluidType={FluidType.ELECTRICITY} /> </Provider> ) + await waitFor(() => null, { container }) expect( - container.getElementsByClassName('consumptionview-content').item(0) + container.getElementsByTagName('mock-consumptionDetails').item(0) ).toBeInTheDocument() expect( - container.getElementsByTagName('mock-consumptionDetails').item(0) + container.getElementsByTagName('mock-konnectorViewerCard').item(0) ).toBeInTheDocument() })