Fakultas Ilmu Komputer UI

Commit d8a1113c authored by Doan Andreas Nathanael's avatar Doan Andreas Nathanael
Browse files

Merge branch 'increase-coverage-add-tests' into 'staging'

Increase Coverage & Add Tests

Closes #20

See merge request !23
parents fb23e8f5 17fd251c
Pipeline #71115 failed with stages
in 13 minutes and 40 seconds
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);
});
});
// 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);
// });
// });
......@@ -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();
});
});
});
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