Skip to content

Commit

Permalink
[GREEN] update test for payment transaction history
Browse files Browse the repository at this point in the history
  • Loading branch information
catherineeangel committed May 16, 2024
1 parent 01d0970 commit 612708a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions __tests__/profile/profile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Profile from '@/app/profile/page'
import { useGetSubscriptionsQuery } from '@/redux/api/subscriptionApi'
import { useGetTransactionListQuery } from '@/redux/api/paymentApi'
import dayjs from 'dayjs'
import { formatRupiah } from '@/utils/formatRupiah'

jest.mock('next/navigation', () => ({
useSearchParams: jest.fn(() => ({
Expand Down Expand Up @@ -57,8 +58,8 @@ const mockTransactionData = [
midtrans_transaction_id: 'mid-2',
order_id: 'ord-2',
price: 10000,
checkout_time: '2024-05-06T14:49:19Z',
expiry_time: '2024-05-06T15:04:19Z',
checkout_time: '2024-05-04T14:49:19Z',
expiry_time: '2024-05-04T15:04:19Z',
payment_type: 'qris',
payment_merchant: 'gopay',
status: 'failed',
Expand All @@ -72,8 +73,8 @@ const mockTransactionData = [
midtrans_transaction_id: 'mid-3',
order_id: 'ord-3',
price: 10000,
checkout_time: '2024-05-06T14:49:19Z',
expiry_time: '2024-05-06T15:04:19Z',
checkout_time: '2024-05-03T14:49:19Z',
expiry_time: '2024-05-03T15:04:19Z',
payment_type: 'qris',
payment_merchant: 'gopay',
status: 'pending',
Expand Down Expand Up @@ -274,8 +275,12 @@ describe('Profile Component', () => {
expect(getByText('Price')).toBeInTheDocument()
expect(getByText('Expiry Time')).toBeInTheDocument()
expect(getByText('Status')).toBeInTheDocument()
expect(getByText(mockTransactionData[0].status)).toBeInTheDocument()
expect(getByText(mockTransactionData[0].price)).toBeInTheDocument()
expect(
getByText(mockTransactionData[0].status.toUpperCase())
).toBeInTheDocument()
expect(
getAllByText(formatRupiah(mockTransactionData[0].price))[0]
).toBeInTheDocument()
expect(
getByText(
dayjs(mockTransactionData[0].checkout_time).format(
Expand Down

0 comments on commit 612708a

Please sign in to comment.