-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(CarbonFootprintSubmodel): Add tests for CO2 Equivalent View
Description Added component tests to verify that the total CO2 Equivalents are displayed correctly Fixes # (MNES-1365) Type of change [x] Minor change (non-breaking change, e.g. documentation adaption)
- Loading branch information
1 parent
0216061
commit d55a475
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...er/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents.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,35 @@ | ||
import { screen } from '@testing-library/react'; | ||
import { expect } from '@jest/globals'; | ||
import { CustomRenderReactIntl } from 'test-utils/CustomRenderReactIntl'; | ||
import { CO2Equivalents } from 'app/[locale]/viewer/_components/submodel/carbon-footprint/visualization-components/CO2Equivalents'; | ||
|
||
describe('CarbonFootprint - CO2 Equivalents', () => { | ||
it('should use correct style', async () => { | ||
CustomRenderReactIntl(<CO2Equivalents totalCO2Equivalents={7.125} />); | ||
const component = screen.getByTestId('co2-equivalents'); | ||
expect(component).toBeDefined(); | ||
expect(component).toBeInTheDocument(); | ||
expect(component).toHaveStyle('color: rgb(25, 118, 210)'); | ||
expect(component).toHaveStyle('fontSize: [72, 96]'); | ||
expect(component).toHaveStyle('font-weight: 700'); | ||
expect(component).toHaveStyle('lineHeight: 1'); | ||
}); | ||
|
||
it('should display three digit number', async () => { | ||
CustomRenderReactIntl(<CO2Equivalents totalCO2Equivalents={7.125} />); | ||
const component = screen.getByTestId('co2-equivalents'); | ||
expect(component).toHaveTextContent('7.125 kg'); | ||
}); | ||
|
||
it('should round to three digits', async () => { | ||
CustomRenderReactIntl(<CO2Equivalents totalCO2Equivalents={7.125857} />); | ||
const component = screen.getByTestId('co2-equivalents'); | ||
expect(component).toHaveTextContent('7.126 kg'); | ||
}); | ||
|
||
it('should not fill to three digits', async () => { | ||
CustomRenderReactIntl(<CO2Equivalents totalCO2Equivalents={7.1} />); | ||
const component = screen.getByTestId('co2-equivalents'); | ||
expect(component).toHaveTextContent('7.1 kg'); | ||
}); | ||
}); |
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