-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for
StatisticsBreadcrumbs
- Loading branch information
Robert Schüler
committed
Aug 26, 2024
1 parent
39cbe29
commit d52f441
Showing
3 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
new/src/components/Scenarios/__test__/StatisticsBreadcrumbs.test.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,63 @@ | ||
import { createReportStatistics } from "./scenarioTestData"; | ||
import { StatisticBreadcrumbs } from "../StatisticsBreadcrumbs"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
|
||
describe("StatisticsBreadcrumbs", () => { | ||
it("should display statistics", () => { | ||
const numSuccessfulScenarios = 1; | ||
const numFailedScenarios = 2; | ||
const numPendingScenarios = 3; | ||
const numScenarios = 4; | ||
const statistic = createReportStatistics({ | ||
numSuccessfulScenarios, | ||
numFailedScenarios, | ||
numPendingScenarios, | ||
numScenarios | ||
}); | ||
|
||
render( | ||
<MemoryRouter> | ||
<StatisticBreadcrumbs statistic={statistic} /> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(screen.getByText(`${numSuccessfulScenarios} Successful,`)).toBeVisible(); | ||
expect(screen.getByText(`${numFailedScenarios} failed,`)).toBeVisible(); | ||
expect(screen.getByText(`${numPendingScenarios} pending,`)).toBeVisible(); | ||
expect(screen.getByText(`${numScenarios} Total`)).toBeVisible(); | ||
}); | ||
|
||
it.each([ | ||
[1e7 + 1, "(0.010s)"], | ||
[1e9, "(1.000s)"], | ||
[234123455532, "(234.123s)"] | ||
])( | ||
"should display the runtime in seconds if durationInNanos = %s", | ||
(durationInNanos, expectedDisplayValue) => { | ||
const statistic = createReportStatistics({ durationInNanos }); | ||
render( | ||
<MemoryRouter> | ||
<StatisticBreadcrumbs statistic={statistic} /> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(screen.getByText(expectedDisplayValue)).toBeVisible(); | ||
} | ||
); | ||
|
||
it.each([[-1e16], [0], [100], [1e7]])( | ||
"should not display the duration if durationInNanos = %s", | ||
durationInNanos => { | ||
const statistic = createReportStatistics({ durationInNanos }); | ||
render( | ||
<MemoryRouter> | ||
<StatisticBreadcrumbs statistic={statistic} /> | ||
</MemoryRouter> | ||
); | ||
|
||
expect(screen.queryByText("(", { exact: false })).not.toBeInTheDocument(); | ||
expect(screen.queryByText(")", { exact: false })).not.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