-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle scenario where a repo doesn't have any coverage (#776)
- Loading branch information
Showing
2 changed files
with
84 additions
and
16 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
66 changes: 66 additions & 0 deletions
66
ui/src/Organization/Coverage/__tests__/OrganizationCoverageDetails.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,66 @@ | ||
import "@testing-library/jest-dom/extend-expect"; | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
import OrganizationCoverageDetails from "../OrganizationCoverageDetails"; | ||
import { | ||
OrganizationCoverage, | ||
RepositoryCoverage, | ||
} from "../../../model/OrganizationModel"; | ||
import { | ||
Coverage, | ||
CoverageStat, | ||
CoverageStats, | ||
} from "../../../model/TestRunModel"; | ||
|
||
describe("OrganizationCoverageDetails", () => { | ||
it("should render coverage details even when one project doesn't have any coverage stats", async () => { | ||
const orgName = "my-org"; | ||
const organizationCoverage = { | ||
repositories: [ | ||
{ | ||
publicId: "no-coverage-id", | ||
repoName: "no-coverage-repo", | ||
coverage: null, | ||
} as RepositoryCoverage, | ||
{ | ||
publicId: "has-coverage-id", | ||
repoName: "has-coverage-repo", | ||
coverage: { | ||
groups: [], | ||
overallStats: { | ||
branchStat: { | ||
covered: 80, | ||
missed: 20, | ||
total: 100, | ||
coveredPercentage: 80, | ||
} as CoverageStat, | ||
lineStat: { | ||
covered: 80, | ||
missed: 20, | ||
total: 100, | ||
coveredPercentage: 80, | ||
} as CoverageStat, | ||
statementStat: { | ||
covered: 80, | ||
missed: 20, | ||
total: 100, | ||
coveredPercentage: 80, | ||
} as CoverageStat, | ||
} as CoverageStats, | ||
} as Coverage, | ||
} as RepositoryCoverage, | ||
], | ||
} as OrganizationCoverage; | ||
|
||
const { findByTestId } = render( | ||
<OrganizationCoverageDetails | ||
orgName={orgName} | ||
organizationCoverage={organizationCoverage} | ||
/> | ||
); | ||
|
||
expect(await findByTestId("coverage-name-1")).toHaveTextContent( | ||
`has-coverage-repo` | ||
); | ||
}); | ||
}); |