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
588b92ab
Commit
588b92ab
authored
Jun 23, 2021
by
wulanmantiri
Browse files
[RED] Add tests for Choose Week on client and nutritionist access
parent
4829bc3b
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/scenes/report/ChooseWeek/index.test.tsx
0 → 100644
View file @
588b92ab
import
React
from
'
react
'
;
import
{
fireEvent
,
render
}
from
'
@testing-library/react-native
'
;
import
ChooseWeek
from
'
.
'
;
import
{
mockUserReportHistory
}
from
'
mocks/userReport
'
;
const
mockedNavigate
=
jest
.
fn
();
jest
.
mock
(
'
@react-navigation/native
'
,
()
=>
{
return
{
useNavigation
:
()
=>
({
navigate
:
mockedNavigate
,
}),
};
});
describe
(
'
ChooseWeek component
'
,
()
=>
{
it
(
'
has "Isi" button when form is never filled and accessed by client
'
,
()
=>
{
const
{
getByText
}
=
render
(<
ChooseWeek
data
=
{
mockUserReportHistory
}
/>);
const
fillButton
=
getByText
(
/Isi/i
);
expect
(
fillButton
).
toBeTruthy
();
fireEvent
.
press
(
fillButton
);
expect
(
mockedNavigate
).
toHaveBeenCalled
();
});
it
(
'
does not have "Isi" button when form is never filled but accessed by nutritionist
'
,
()
=>
{
const
{
queryByText
}
=
render
(
<
ChooseWeek
data
=
{
mockUserReportHistory
}
isNutritionist
/>,
);
expect
(
queryByText
(
/Isi/i
)).
toBeFalsy
();
});
it
(
'
does not have "Isi" button when form is already filled
'
,
()
=>
{
const
{
queryByText
}
=
render
(
<
ChooseWeek
data
=
{
{
...
mockUserReportHistory
,
has_not_filled_form
:
false
}
}
/>,
);
expect
(
queryByText
(
/Isi/i
)).
toBeFalsy
();
});
it
(
'
redirects to designated route when button "Lihat" is pressed
'
,
()
=>
{
const
{
getAllByText
}
=
render
(
<
ChooseWeek
data
=
{
mockUserReportHistory
}
/>,
);
const
viewButton
=
getAllByText
(
/Lihat/i
)[
0
];
expect
(
viewButton
).
toBeTruthy
();
fireEvent
.
press
(
viewButton
);
expect
(
mockedNavigate
).
toHaveBeenCalled
();
});
});
src/scenes/report/ChooseWeekForClient/index.test.tsx
0 → 100644
View file @
588b92ab
import
React
from
'
react
'
;
import
{
render
}
from
'
@testing-library/react-native
'
;
import
ChooseWeekForClient
from
'
.
'
;
const
mockedNavigate
=
jest
.
fn
();
jest
.
mock
(
'
@react-navigation/native
'
,
()
=>
{
return
{
useNavigation
:
()
=>
({
navigate
:
mockedNavigate
,
}),
};
});
describe
(
'
ChooseWeekForClient
'
,
()
=>
{
it
(
'
renders correctly
'
,
()
=>
{
render
(<
ChooseWeekForClient
/>);
});
});
src/scenes/report/ChooseWeekForNutritionist/index.test.tsx
0 → 100644
View file @
588b92ab
import
React
from
'
react
'
;
import
{
render
}
from
'
@testing-library/react-native
'
;
import
ChooseWeekForNutritionist
from
'
.
'
;
const
mockedNavigate
=
jest
.
fn
();
jest
.
mock
(
'
@react-navigation/native
'
,
()
=>
{
return
{
useNavigation
:
()
=>
({
navigate
:
mockedNavigate
,
}),
};
});
describe
(
'
ChooseWeekForNutritionist
'
,
()
=>
{
it
(
'
renders correctly
'
,
()
=>
{
render
(<
ChooseWeekForNutritionist
/>);
});
});
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