Skip to content

Commit 2db2598

Browse files
test: Test payment card billing price
1 parent 6c755aa commit 2db2598

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/PaymentCard.test.jsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,62 @@ describe('PaymentCard', () => {
320320
expect(screen.getByText(/for \$30.00/)).toBeInTheDocument()
321321
})
322322
})
323+
324+
describe('nextBillPrice calculation', () => {
325+
it('calculates monthly billing price correctly', async () => {
326+
// Test with monthly billing: baseUnitPrice 10, 3 paid seats = $30.00
327+
setup()
328+
render(
329+
<PaymentCard
330+
accountDetails={accountDetails}
331+
provider="gh"
332+
owner="codecov"
333+
/>,
334+
{ wrapper }
335+
)
336+
337+
await waitFor(() => {
338+
expect(screen.getByText(/for \$30.00/)).toBeInTheDocument()
339+
})
340+
})
341+
342+
it('calculates annual billing price correctly', async () => {
343+
// Test with annual billing: baseUnitPrice 10, 3 paid seats × 12 = $360.00
344+
server.use(
345+
graphql.query('GetPlanData', () => {
346+
return HttpResponse.json({
347+
data: {
348+
owner: {
349+
hasPrivateRepos: true,
350+
plan: {
351+
...mockPlanData,
352+
billingRate: BillingRate.ANNUALLY,
353+
baseUnitPrice: 10,
354+
planUserCount: 6,
355+
freeSeatCount: 2,
356+
isProPlan: false,
357+
isTeamPlan: true,
358+
},
359+
},
360+
},
361+
})
362+
})
363+
)
364+
365+
render(
366+
<PaymentCard
367+
accountDetails={accountDetails}
368+
provider="gh"
369+
owner="codecov"
370+
/>,
371+
{ wrapper }
372+
)
373+
374+
await waitFor(() => {
375+
expect(screen.getByText(/for \$480.00/)).toBeInTheDocument()
376+
})
377+
})
378+
})
323379
})
324380

325381
describe('when the user has a US bank account', () => {

0 commit comments

Comments
 (0)