-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test - CO2EDistributionBarchart component test to verify axis
- Loading branch information
1 parent
599858f
commit 63170d1
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...print/visualization-components/CO2EDistributionDiagrams/CO2EDistributionBarchart.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { screen } from '@testing-library/react'; | ||
import { expect } from '@jest/globals'; | ||
import { CustomRenderReactIntl } from 'test-utils/CustomRenderReactIntl'; | ||
import { CO2EBarchart } from 'app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2EDistributionDiagrams/CO2EDistributionBarchart'; | ||
|
||
window.ResizeObserver = | ||
window.ResizeObserver || | ||
jest.fn().mockImplementation(() => ({ | ||
disconnect: jest.fn(), | ||
observe: jest.fn(), | ||
unobserve: jest.fn(), | ||
})); | ||
|
||
jest.mock('recharts', () => { | ||
const OriginalRechartsModule = jest.requireActual('recharts'); | ||
|
||
return { | ||
...OriginalRechartsModule, | ||
ResponsiveContainer: ({ children }: never) => ( | ||
<OriginalRechartsModule.ResponsiveContainer | ||
className="recharts-responsive-container" | ||
width={800} | ||
height={800} | ||
> | ||
{children} | ||
</OriginalRechartsModule.ResponsiveContainer> | ||
), | ||
}; | ||
}); | ||
|
||
const co2EquivalentsPerLifecycleStage = { | ||
A1: 0.235, | ||
A2: 0.553, | ||
A3: 0.823, | ||
A4: 0.123, | ||
}; | ||
|
||
describe('CarbonFootprint - CO2EquivalentsDistribution', () => { | ||
it('should renders correct axis descriptions', async () => { | ||
CustomRenderReactIntl(<CO2EBarchart co2EquivalentsPerLifecycleStage={co2EquivalentsPerLifecycleStage} />); | ||
expect(screen.getByText('kg CO2e')).toBeInTheDocument(); | ||
expect(screen.getByText('CO2 Equivalents')).toBeInTheDocument(); | ||
expect(screen.getByText('A3')).toBeInTheDocument(); | ||
expect(screen.getByText('A2')).toBeInTheDocument(); | ||
expect(screen.getByText('A1')).toBeInTheDocument(); | ||
}); | ||
}); |