Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RulaKhaled committed May 17, 2024
1 parent 518d523 commit b41de14
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/pages/RepoPage/CoverageTab/CoverageTab.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const wrapper =
</QueryClientProvider>
)

const mockRepo = (isPrivate = false) => ({
const mockRepo = (isPrivate = false, isFirstPullRequest = false) => ({
owner: {
isCurrentUserPartOfOrg: true,
isAdmin: null,
Expand All @@ -50,7 +50,7 @@ const mockRepo = (isPrivate = false) => ({
activated: false,
oldestCommitAt: '',
active: true,
isFirstPullRequest: false,
isFirstPullRequest,
},
},
})
Expand Down Expand Up @@ -202,9 +202,14 @@ afterAll(() => {

describe('Coverage Tab', () => {
function setup(
{ isPrivate = false, tierValue = TierNames.PRO } = {
{
isPrivate = false,
tierValue = TierNames.PRO,
isFirstPullRequest = false,
} = {
isPrivate: false,
tierValue: TierNames.PRO,
isFirstPullRequest: false,
}
) {
useFlags.mockReturnValue({
Expand All @@ -213,7 +218,7 @@ describe('Coverage Tab', () => {

server.use(
graphql.query('GetRepo', (req, res, ctx) =>
res(ctx.status(200), ctx.data(mockRepo(isPrivate)))
res(ctx.status(200), ctx.data(mockRepo(isPrivate, isFirstPullRequest)))
),
graphql.query('GetBranches', (req, res, ctx) =>
res(ctx.status(200), ctx.data(branchesMock))
Expand Down Expand Up @@ -318,4 +323,15 @@ describe('Coverage Tab', () => {
expect(coverageChart).not.toBeInTheDocument()
})
})

it('renders first pull request banner', async () => {
setup({ isFirstPullRequest: true })

render(<CoverageTab />, { wrapper: wrapper(['/gh/test-org/repoName']) })

const firstPullRequestBanner = await screen.findByText(
/Once merged to your default branch, Codecov will show your report results on this dashboard./
)
expect(firstPullRequestBanner).toBeInTheDocument()
})
})

0 comments on commit b41de14

Please sign in to comment.