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
c9b1feb9
Commit
c9b1feb9
authored
Jun 07, 2021
by
doanandreas
Browse files
[GREEN] add tests for WeeklyReportPage
parent
a17186c2
Pipeline
#82180
passed with stages
in 17 minutes and 27 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/scenes/report/ReadOnlyWeeklyReport/components/WeeklyReportPage/index.test.tsx
0 → 100644
View file @
c9b1feb9
import
{
render
}
from
'
@testing-library/react-native
'
;
import
React
from
'
react
'
;
import
WeeklyReportPage
from
'
.
'
;
import
{
QuestionComment
}
from
'
../../pages/types
'
;
describe
(
'
WeeklyReportPage
'
,
()
=>
{
const
questions
:
QuestionComment
[]
=
[
{
questions
:
[
{
question
:
'
Berat badan (kg)
'
,
answer
:
'
50
'
,
},
],
comment
:
'
keren bingits
'
,
},
];
const
questions2
:
QuestionComment
[]
=
[
{
questions
:
[
{
question
:
'
Apakah sudah mulai terasa ada perubahan ukuran baju atau celana?
'
,
desc
:
{
one
:
'
1. Belum terasa sama sekali
'
,
two
:
'
5. Sudah sangat berubah
'
,
},
answer
:
'
Yes
'
,
},
],
comment
:
'
gilaaa
'
,
},
];
it
(
'
renders correctly without title
'
,
()
=>
{
render
(<
WeeklyReportPage
questions
=
{
questions
}
/>);
});
it
(
'
renders correctly with title
'
,
()
=>
{
const
title
=
"
Clearly
\n
You don't own an air flyer
"
;
const
{
queryByText
}
=
render
(
<
WeeklyReportPage
questions
=
{
questions
}
title
=
{
title
}
/>,
);
expect
(
queryByText
(
title
)).
toBeTruthy
();
});
it
(
'
renders correctly with description
'
,
()
=>
{
const
title
=
"
Clearly
\n
You don't own an air flyer
"
;
const
{
queryByText
}
=
render
(
<
WeeklyReportPage
questions
=
{
questions2
}
title
=
{
title
}
/>,
);
const
desc1
=
questions2
[
0
].
questions
[
0
].
desc
!
.
one
;
const
desc2
=
questions2
[
0
].
questions
[
0
].
desc
!
.
two
;
expect
(
queryByText
(
desc1
)).
toBeTruthy
();
expect
(
queryByText
(
desc2
)).
toBeTruthy
();
});
it
(
'
displays correct question and comment
'
,
()
=>
{
const
title
=
"
Clearly
\n
You don't own an air flyer
"
;
const
{
queryByText
}
=
render
(
<
WeeklyReportPage
questions
=
{
questions
}
title
=
{
title
}
/>,
);
// Should display question one
const
questionOneText
=
questions
[
0
].
questions
[
0
].
question
;
const
commentOneText
=
questions
[
0
].
comment
;
expect
(
queryByText
(
questionOneText
)).
toBeTruthy
();
expect
(
queryByText
(
commentOneText
)).
toBeTruthy
();
// Should NOT display question two
const
questionTwoText
=
questions2
[
0
].
questions
[
0
].
question
;
const
commentTwoText
=
questions2
[
0
].
comment
;
expect
(
queryByText
(
questionTwoText
)).
toBeNull
();
expect
(
queryByText
(
commentTwoText
)).
toBeNull
();
});
});
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