Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 8d29ad34 authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#140652771] [#21] [Red] Add delete vancancy testcases

parent 4d2d3c4d
No related branches found
No related tags found
No related merge requests found
...@@ -49,4 +49,11 @@ describe('CompanyVacancy', () => { ...@@ -49,4 +49,11 @@ describe('CompanyVacancy', () => {
expect(companyVacancy).to.exist; expect(companyVacancy).to.exist;
}); });
it('loads when delete button clicked', () => {
const companyVacancy = ReactTestUtils.renderIntoDocument(
<CompanyVacancy data={response} />);
const button = ReactTestUtils.findRenderedDOMComponentWithTag(companyVacancy, 'Button');
ReactTestUtils.Simulate.click(button);
expect(companyVacancy.state.deleteLoading).to.equal(true);
});
}); });
...@@ -76,5 +76,38 @@ describe('VacancyList', () => { ...@@ -76,5 +76,38 @@ describe('VacancyList', () => {
expect(JSON.stringify(vacancyList.state.vacancies)).to.equal(JSON.stringify(response)); expect(JSON.stringify(vacancyList.state.vacancies)).to.equal(JSON.stringify(response));
fetchMock.restore(); fetchMock.restore();
}); });
it('success delete vacancy', (done) => {
fetchMock.delete('*', response);
fetchMock.get('*', response);
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList userId={1} url="test" deleteCallback={() => {}} />);
vacancyList.state.vacancies = response;
vacancyList.deleteVacancy(1).then(() => {
expect(JSON.stringify(vacancyList.state.vacancies)).to.equal(JSON.stringify(response));
fetchMock.restore();
done();
}, () => {
fetchMock.restore();
done();
});
});
it('fails delete vacancy', (done) => {
fetchMock.delete('*', 404);
fetchMock.get('*', response);
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList userId={1} url="test" deleteCallback={() => {}} />
);
vacancyList.state.vacancies = response;
vacancyList.deleteVacancy(1).then(() => {
fetchMock.restore();
done();
}, () => {
expect(JSON.stringify(vacancyList.state.vacancies)).to.equal(JSON.stringify(response));
fetchMock.restore();
done();
});
});
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment