Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
PT Gizi Sehat - Dietela
Dietela Mobile
Commits
1e2eb72b
Commit
1e2eb72b
authored
May 03, 2021
by
wulanmantiri
Browse files
[GREEN] Add tests for back to checkout button
parent
d899fc4c
Pipeline
#74519
passed with stages
in 28 minutes and 48 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/scenes/payment/PaymentResult/index.test.tsx
View file @
1e2eb72b
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
}
=
withAuthR
ender
(
const
{
queryByText
,
getByText
,
queryAllByText
}
=
r
ender
(
<
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
();
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment