Fakultas Ilmu Komputer UI

Commit 1e2eb72b authored by wulanmantiri's avatar wulanmantiri
Browse files

[GREEN] Add tests for back to checkout button

parent d899fc4c
Pipeline #74519 passed with stages
in 28 minutes and 48 seconds
import React from 'react';
import { withAuthRender } from 'utils/testing';
import { render, fireEvent } from 'utils/testing';
import * as ROUTES from 'constants/routes';
import PaymentResult from '.';
......@@ -12,33 +12,37 @@ const getMockParams = (statusCode: string) => ({
describe('PaymentResult', () => {
it('shows success message with successful payment', () => {
const { queryByText } = withAuthRender(
<PaymentResult />,
ROUTES.paymentResult,
getMockParams('200'),
);
const { queryByText } = render(<PaymentResult />, ROUTES.paymentResult, {
routeParams: getMockParams('200'),
});
expect(queryByText(/Pembayaran berhasil/i)).toBeTruthy();
});
it('shows please pay message with pending payment', () => {
const { queryByText } = withAuthRender(
const { queryByText, getByText, queryAllByText } = render(
<PaymentResult />,
ROUTES.paymentResult,
getMockParams('201'),
{
routeParams: getMockParams('201'),
},
);
expect(
queryByText(/Mohon segara menyelesaikan pembayaran Anda/i),
).toBeTruthy();
const button = getByText(/Kembali ke Checkout/i);
expect(button).toBeTruthy();
fireEvent.press(button);
expect(queryAllByText(/Checkout/i)).toBeTruthy();
});
it('shows error message with failed payment', () => {
const { queryByText } = withAuthRender(
<PaymentResult />,
ROUTES.paymentResult,
getMockParams('400'),
);
const { queryByText } = render(<PaymentResult />, ROUTES.paymentResult, {
routeParams: getMockParams('400'),
});
expect(queryByText(/Pembayaran gagal/i)).toBeTruthy();
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment