Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
suejung-sentry committed Jan 17, 2025
1 parent ea0b00d commit 31557fe
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ vi.mock('services/account/useCreateStripeSetupIntent', async () => {
})

afterEach(() => {
queryClient.clear()
vi.clearAllMocks()
})

Expand All @@ -54,6 +55,20 @@ const subscriptionDetail = {
cancelAtPeriodEnd: false,
}

const usBankSubscriptionDetail = {
defaultPaymentMethod: {
usBankAccount: {
bankName: 'STRIPE TEST BANK',
last4: '6789',
},
},
plan: {
value: Plans.USERS_PR_INAPPY,
},
currentPeriodEnd: 1606851492,
cancelAtPeriodEnd: false,
}

const wrapper = ({ children }) => (
<QueryClientProvider client={queryClient}>
<ThemeContextProvider>{children}</ThemeContextProvider>
Expand Down Expand Up @@ -200,6 +215,22 @@ describe('PaymentCard', () => {
})
})

describe('when the user has a US bank account', () => {
it('renders the bank account details', () => {
render(
<PaymentCard
subscriptionDetail={usBankSubscriptionDetail}
provider="gh"
owner="codecov"
/>,
{ wrapper }
)

expect(screen.getByText(/STRIPE TEST BANK/)).toBeInTheDocument()
expect(screen.getByText(/ 6789/)).toBeInTheDocument()
})
})

describe('when the subscription is set to expire', () => {
it(`doesn't render the next billing`, () => {
render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('PaymentMethodForm', () => {
/>,
{ wrapper }
)
await user.click(screen.getByTestId('update-payment-method'))
await user.click(screen.getByTestId('save-payment-method'))

expect(screen.queryByText(/Visa/)).not.toBeInTheDocument()
})
Expand All @@ -118,7 +118,7 @@ describe('PaymentMethodForm', () => {
/>,
{ wrapper }
)
await user.click(screen.getByTestId('update-payment-method'))
await user.click(screen.getByTestId('save-payment-method'))

expect(screen.getByRole('button', { name: /Save/i })).toBeInTheDocument()
})
Expand All @@ -140,7 +140,7 @@ describe('PaymentMethodForm', () => {
/>,
{ wrapper }
)
await user.click(screen.getByTestId('update-payment-method'))
await user.click(screen.getByTestId('save-payment-method'))
expect(updatePaymentMethod).toHaveBeenCalled()
})
})
Expand All @@ -163,7 +163,7 @@ describe('PaymentMethodForm', () => {
{ wrapper }
)

await user.click(screen.getByTestId('update-payment-method'))
await user.click(screen.getByTestId('save-payment-method'))
await user.click(screen.getByRole('button', { name: /Cancel/ }))

expect(closeForm).toHaveBeenCalled()
Expand All @@ -189,7 +189,7 @@ describe('PaymentMethodForm', () => {
{ wrapper }
)

await user.click(screen.getByTestId('update-payment-method'))
await user.click(screen.getByTestId('save-payment-method'))

expect(screen.getByText(randomError)).toBeInTheDocument()
})
Expand Down

0 comments on commit 31557fe

Please sign in to comment.