Fakultas Ilmu Komputer UI

Commit 8d29ad34 authored by Zamil Majdy's avatar Zamil Majdy
Browse files

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

parent 4d2d3c4d
......@@ -3,7 +3,7 @@ import ReactTestUtils from 'react-addons-test-utils';
import CompanyVacancy from '../../components/CompanyVacancy';
describe('CompanyVacancy', () => {
const response ={
const response = {
close_time: '2019-03-28T05:55:42Z',
company: {
address: 'kebayoran baru',
......@@ -49,4 +49,11 @@ describe('CompanyVacancy', () => {
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', () => {
expect(JSON.stringify(vacancyList.state.vacancies)).to.equal(JSON.stringify(response));
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();
});
});
});
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