Fakultas Ilmu Komputer UI
Skip to content
GitLab
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
17fd251c
Commit
17fd251c
authored
Apr 05, 2021
by
Doan Andreas Nathanael
Browse files
Increase Coverage & Add Tests
parent
fb23e8f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/scenes/questionnaire/DietelaQuizResult/index.test.tsx
0 → 100644
View file @
17fd251c
import
React
from
'
react
'
;
import
{
render
}
from
'
utils/testing
'
;
import
*
as
ROUTES
from
'
constants/routes
'
;
import
DietelaQuizResult
from
'
.
'
;
import
{
mockQuizResult
}
from
'
mocks/quizResult
'
;
describe
(
'
DietelaQuizResult
'
,
()
=>
{
it
(
'
renders correctly
'
,
()
=>
{
render
(<
DietelaQuizResult
/>,
ROUTES
.
dietelaQuizResult
,
mockQuizResult
);
});
});
src/scenes/questionnaire/DietelaQuizResult/kek.txt
deleted
100644 → 0
View file @
fb23e8f5
// import React from 'react';
// import { render } from 'utils/testing';
// import * as ROUTES from 'constants/routes';
// import DietelaQuizResult from '.';
// describe('DietelaQuizResult', () => {
// it('renders correctly', () => {
// render(<DietelaQuizResult />, ROUTES.dietelaQuizResult);
// });
// });
src/scenes/questionnaire/DietelaQuizResult/pages/ResultPage/index.test.tsx
View file @
17fd251c
...
...
@@ -5,66 +5,111 @@ import * as ROUTES from 'constants/routes';
import
ResultPage
from
'
.
'
;
describe
(
'
ResultPage
'
,
()
=>
{
const
infos
=
[
{
label
:
'
Indeks massa tubuh
'
,
content
:
'
31.6
'
,
},
{
label
:
'
Status
'
,
content
:
'
Obesitas 2
'
,
},
];
const
heightWeightData
=
{
header
:
'
Dihitung berdasarkan data:
'
,
content
:
{
statistics
:
[
[
{
label
:
'
berat badan
'
,
emote
:
'
⚖️
'
,
content
:
'
77 kg
'
,
},
{
label
:
'
tinggi badan
'
,
emote
:
'
📐
'
,
content
:
'
156 cm
'
,
},
],
],
},
};
const
weightRecommendation
=
{
header
:
'
Untuk orang dengan tinggi 156 cm, berikut rentang berat badan yang ideal:
'
,
content
:
{
statistics
:
[
[
{
label
:
'
minimal
'
,
emote
:
'
◀️
'
,
content
:
'
46.2 kg
'
,
},
{
label
:
'
maksimal
'
,
emote
:
'
▶️
'
,
content
:
'
55.9 kg
'
,
},
],
],
textCard
:
[
'
Usahakan berat badan kamu masuk ke rentang ideal, ya!
'
],
},
};
const
content
=
{
title
:
'
Status Berat Badan
'
,
mainInfo
:
{
infos
:
[
{
label
:
'
Indeks massa tubuh
'
,
content
:
'
31.6
'
,
},
{
label
:
'
Status
'
,
content
:
'
Obesitas 2
'
,
},
],
infos
:
infos
,
status
:
'
healthy
'
,
},
sections
:
[
{
header
:
'
Dihitung berdasarkan data:
'
,
content
:
{
statistics
:
[
[
{
label
:
'
berat badan
'
,
emote
:
'
⚖️
'
,
content
:
'
77 kg
'
,
},
{
label
:
'
tinggi badan
'
,
emote
:
'
📐
'
,
content
:
'
156 cm
'
,
},
],
],
},
},
{
header
:
'
Untuk orang dengan tinggi 156 cm, berikut rentang berat badan yang ideal:
'
,
content
:
{
statistics
:
[
[
{
label
:
'
minimal
'
,
emote
:
'
◀️
'
,
content
:
'
46.2 kg
'
,
},
{
label
:
'
maksimal
'
,
emote
:
'
▶️
'
,
content
:
'
55.9 kg
'
,
},
],
],
textCard
:
[
'
Usahakan berat badan kamu masuk ke rentang ideal, ya!
'
],
},
},
],
sections
:
[
heightWeightData
,
weightRecommendation
],
};
it
(
'
renders correctly
'
,
()
=>
{
render
(<
ResultPage
content
=
{
content
}
/>,
ROUTES
.
dietelaQuizResult
);
});
it
(
'
renders correctly when there is CTA button
'
,
()
=>
{
render
(
<
ResultPage
content
=
{
content
}
cta
=
{
{
priority_1
:
'
program 1
'
,
priority_2
:
'
program 2
'
}
}
/>,
ROUTES
.
dietelaQuizResult
,
);
});
it
(
'
shows the correct content
'
,
()
=>
{
const
{
getByText
}
=
render
(
<
ResultPage
content
=
{
content
}
/>,
ROUTES
.
dietelaQuizResult
,
);
// Check for result page title
expect
(
getByText
(
content
.
title
)).
toBeTruthy
();
// Check for each info
infos
.
forEach
((
info
)
=>
{
expect
(
getByText
(
info
.
label
)).
toBeTruthy
();
expect
(
getByText
(
info
.
content
)).
toBeTruthy
();
});
// Check for height & weight data shows correct statistics
expect
(
getByText
(
heightWeightData
.
header
)).
toBeTruthy
();
heightWeightData
.
content
.
statistics
[
0
].
forEach
((
stats
)
=>
{
expect
(
getByText
(
stats
.
label
)).
toBeTruthy
();
expect
(
getByText
(
stats
.
emote
)).
toBeTruthy
();
expect
(
getByText
(
stats
.
content
)).
toBeTruthy
();
});
// Check for weight recommendation shows correct statistics
expect
(
getByText
(
weightRecommendation
.
header
)).
toBeTruthy
();
weightRecommendation
.
content
.
statistics
[
0
].
forEach
((
stats
)
=>
{
expect
(
getByText
(
stats
.
label
)).
toBeTruthy
();
expect
(
getByText
(
stats
.
emote
)).
toBeTruthy
();
expect
(
getByText
(
stats
.
content
)).
toBeTruthy
();
});
});
});
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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