Fakultas Ilmu Komputer UI

Commit d4a1d22d authored by Nabilah Adani's avatar Nabilah Adani
Browse files

[RED] change test for information export pdf

parent 3310736c
Pipeline #79827 failed with stages
in 1 minute and 25 seconds
...@@ -7,18 +7,22 @@ const dummyImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASoAAAEsCAYAAA ...@@ -7,18 +7,22 @@ const dummyImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASoAAAEsCAYAAA
describe('<ExportPDFButton />', () => { describe('<ExportPDFButton />', () => {
it('should render correctly', () => { it('should render correctly', () => {
shallow(<ExportPDFButton shallow(<ExportPDFButton
png={dummyImage}
type={''} type={''}
selectedKey={''} selectedKey={''}
dataType={''}
chartType={true}
information={''}
clickable={false} />); clickable={false} />);
}) })
it('should call downloadAsPDF', () => { it('should call downloadAsPDF', () => {
const mod = require('../../utilities/utils'); const mod = require('../../utilities/utils');
jest.spyOn(mod, 'downloadAsPDF'); jest.spyOn(mod, 'downloadAsPDF');
const btn = shallow(<ExportPDFButton const btn = shallow(<ExportPDFButton
png={dummyImage}
type={''} type={''}
selectedKey={''} selectedKey={''}
dataType={''}
chartType={true}
information={''}
clickable={false} />); clickable={false} />);
btn.find('Button').simulate('click'); btn.find('Button').simulate('click');
expect(mod.downloadAsPDF).toHaveBeenCalled(); expect(mod.downloadAsPDF).toHaveBeenCalled();
......
...@@ -48,7 +48,7 @@ describe('<Statistic />', () => { ...@@ -48,7 +48,7 @@ describe('<Statistic />', () => {
} }
}; };
it('render diagram statistics without crashing', () => { it('render diagram statistics without crashing', () => {
mount( mount(
<AppContext.Provider value={testProps}> <AppContext.Provider value={testProps}>
<Statistic <Statistic
...@@ -60,7 +60,7 @@ describe('<Statistic />', () => { ...@@ -60,7 +60,7 @@ describe('<Statistic />', () => {
); );
}); });
it('render table statistics without crashing', () => { it('render table statistics without crashing', () => {
mount( mount(
<AppContext.Provider value={testProps}> <AppContext.Provider value={testProps}>
<Statistic <Statistic
...@@ -72,7 +72,7 @@ describe('<Statistic />', () => { ...@@ -72,7 +72,7 @@ describe('<Statistic />', () => {
); );
}); });
it('render table age statistics without crashing', () => { it('render table age statistics without crashing', () => {
mount( mount(
<AppContext.Provider value={testProps}> <AppContext.Provider value={testProps}>
<Statistic <Statistic
...@@ -84,8 +84,7 @@ describe('<Statistic />', () => { ...@@ -84,8 +84,7 @@ describe('<Statistic />', () => {
); );
}); });
it('render sex stats chart successfully', () => { it('render sex stats chart successfully', () => {
mount(
<AppContext.Provider value={testProps}> <AppContext.Provider value={testProps}>
<Statistic <Statistic
isTable={false} isTable={false}
...@@ -96,7 +95,7 @@ describe('<Statistic />', () => { ...@@ -96,7 +95,7 @@ describe('<Statistic />', () => {
); );
}); });
it('render kasus in time range stats chart successfully', () => { it('render kasus in time range stats chart successfully', () => {
mount( mount(
<AppContext.Provider value={testProps}> <AppContext.Provider value={testProps}>
<Statistic <Statistic
...@@ -108,7 +107,7 @@ describe('<Statistic />', () => { ...@@ -108,7 +107,7 @@ describe('<Statistic />', () => {
); );
}); });
it('sets ignoreDateRange state after clicking ignoreDateRange button', () => { it('sets ignoreDateRange Statistics state after clicking ignoreDateRange button', () => {
const wrapper = mount(<Statistic const wrapper = mount(<Statistic
isTable={false} isTable={false}
type={StatisticType.Date} type={StatisticType.Date}
...@@ -118,9 +117,22 @@ describe('<Statistic />', () => { ...@@ -118,9 +117,22 @@ describe('<Statistic />', () => {
expect(wrapper.find(Checkbox).props().isChecked).toBe(false); expect(wrapper.find(Checkbox).props().isChecked).toBe(false);
wrapper.find(Checkbox).simulate('click'); wrapper.find(Checkbox).simulate('click');
expect(wrapper.find(Checkbox).props().isChecked).toBe(true); expect(wrapper.find(Checkbox).props().isChecked).toBe(true);
}) });
it('sets ignoreDateRangeFilter age after clicking ignoreDateRange button', () => {
const wrapper = mount(<Statistic
isTable={false}
type={StatisticType.Age}
data={statisticData.age}
/>);
expect(wrapper.find(Checkbox).props().isChecked).toBe(false);
wrapper.find(Checkbox).simulate('click');
expect(wrapper.find(Checkbox).props().isChecked).toBe(true);
});
it('render table district in time range stats chart successfully', () => { it('render table district in time range stats chart successfully', () => {
mount( mount(
<AppContext.Provider value={testProps}> <AppContext.Provider value={testProps}>
<Statistic <Statistic
...@@ -132,7 +144,7 @@ describe('<Statistic />', () => { ...@@ -132,7 +144,7 @@ describe('<Statistic />', () => {
); );
}); });
it('sets ignoreDateRangeTable false state after clicking ignoreDateRangeTable button', () => { it('sets ignoreDateRangeTable false state after clicking ignoreDateRangeTable button', () => {
const wrapper = mount(<Statistic const wrapper = mount(<Statistic
isTable={true} isTable={true}
type={StatisticType.Date} type={StatisticType.Date}
......
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