-
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.
Merge pull request #12 from XAlinaGS/test(CarbonFootprintVisualizatio…
…ns)test-carbon-footprint-visualizations test(CarbonFootprintVisualizations): write test for CarbonFootprintVi…
- Loading branch information
Showing
7 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
...cale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations.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,72 @@ | ||
import { screen } from '@testing-library/react'; | ||
import { expect } from '@jest/globals'; | ||
import testSubmodel from '../../submodel/carbon-footprint/test-submodel/carbonFootprint-test.json'; | ||
import { Submodel } from '@aas-core-works/aas-core3.0-typescript/types'; | ||
import { CustomRenderReactIntl } from 'test-utils/CustomRenderReactIntl'; | ||
import { | ||
CarbonFootprintVisualizations | ||
} from 'app/[locale]/viewer/_components/submodel/carbon-footprint/CarbonFootprintVisualizations'; | ||
|
||
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: ({ height, children }: never) => ( | ||
<div className="recharts-responsive-container" style={{ width: 800, height }}> | ||
{children} | ||
</div> | ||
), | ||
}; | ||
}); | ||
|
||
describe('CarbonFootprintVisualizations Detail', () => { | ||
it('should render all submodel visualilzations for irdi id', async () => { | ||
CustomRenderReactIntl( | ||
<CarbonFootprintVisualizations submodel={testSubmodel['carbonFootprint-IrdiId'] as unknown as Submodel} />, | ||
); | ||
assertOnElements(); | ||
}); | ||
|
||
it('should render all submodel visualilzations for URL id', async () => { | ||
CustomRenderReactIntl( | ||
<CarbonFootprintVisualizations submodel={testSubmodel['carbonFootprint-UrlId'] as unknown as Submodel} />, | ||
); | ||
assertOnElements(); | ||
}); | ||
}); | ||
|
||
function assertOnElements() { | ||
const totalCo2Equivalents = screen.getByTestId('co2-equivalents'); | ||
expect(totalCo2Equivalents).toBeDefined(); | ||
expect(totalCo2Equivalents).toBeInTheDocument(); | ||
|
||
const productLifecycle = screen.getByTestId('product-lifecycle-stepper'); | ||
expect(productLifecycle).toBeDefined(); | ||
expect(productLifecycle).toBeInTheDocument(); | ||
|
||
const co2EquivalentsDistribution = screen.getByTestId('co2-equivalents-distribution-box'); | ||
expect(co2EquivalentsDistribution).toBeDefined(); | ||
expect(co2EquivalentsDistribution).toBeInTheDocument(); | ||
|
||
const co2Comparison = screen.getByTestId('co2-comparison-box'); | ||
expect(co2Comparison).toBeDefined(); | ||
expect(co2Comparison).toBeInTheDocument(); | ||
|
||
const productJourney = screen.getByTestId('product-journey-box'); | ||
expect(productJourney).toBeDefined(); | ||
expect(productJourney).toBeInTheDocument(); | ||
|
||
const calculationMethod = screen.getByTestId('co2-calculation-method-text'); | ||
expect(calculationMethod).toBeDefined(); | ||
expect(calculationMethod).toBeInTheDocument(); | ||
} | ||
|
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
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
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
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
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
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