Fakultas Ilmu Komputer UI

Commit 0a070be0 authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#144502159] [#35] [Refactor] Update correlated testcases and main component to fix bug

parent 99f4e825
......@@ -29,21 +29,11 @@ export default class ApplicantPage extends React.Component {
const company = this.props.user.data.company;
return (
<Tabs selected={0}>
<Pane label="Lamaran Baru" >
<ApplicantList key={1} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.NEW}`} status={Applicant.APPLICATION_STATUS.NEW} />
</Pane>
<Pane label="Lamaran Dibaca" >
<ApplicantList key={2} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.READ}`} status={Applicant.APPLICATION_STATUS.READ} />
</Pane>
<Pane label="Lamaran Ditandai" >
<ApplicantList key={3} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.BOOKMARKED}`} status={Applicant.APPLICATION_STATUS.BOOKMARKED} />
</Pane>
<Pane label="Lamaran Diterima" >
<ApplicantList key={4} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.ACCEPTED}`} status={Applicant.APPLICATION_STATUS.ACCEPTED} />
</Pane>
<Pane label="Lamaran Ditolak" >
<ApplicantList key={5} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.REJECTED}`} status={Applicant.APPLICATION_STATUS.REJECTED} />
</Pane>
<ApplicantList label="Lamaran Baru" key={1} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.NEW}`} status={Applicant.APPLICATION_STATUS.NEW} />
<ApplicantList label="Lamaran Dibaca" key={2} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.READ}`} status={Applicant.APPLICATION_STATUS.READ} />
<ApplicantList label="Lamaran Ditandai" key={3} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.BOOKMARKED}`} status={Applicant.APPLICATION_STATUS.BOOKMARKED} />
<ApplicantList label="Lamaran Diterima" key={4} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.ACCEPTED}`} status={Applicant.APPLICATION_STATUS.ACCEPTED} />
<ApplicantList label="Lamaran Ditolak" key={5} companyId={company.id} url={`/companies/${company.id}/applications/?status=${Applicant.APPLICATION_STATUS.REJECTED}`} status={Applicant.APPLICATION_STATUS.REJECTED} />
</Tabs>
);
}
......
import React from 'react';
import TopMenu from './components/TopMenu';
import Footer from './components/Footer'
import Footer from './components/Footer';
export default class Dashboard extends React.Component {
static propTypes = {
......
......@@ -89,7 +89,7 @@ export default class ProfilePage extends React.Component {
const form = this.state.form;
form[e.target.name] = e.target.files[0];
this.setState({ form });
}
};
handleChange = (e) => {
const form = this.state.form;
......
......@@ -2,6 +2,7 @@
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import ApplyModal from '../../components/ApplyModal';
import fetchMock from 'fetch-mock';
describe('ApplyModal', () => {
it('renders without problem', () => {
......@@ -11,12 +12,25 @@ describe('ApplyModal', () => {
});
it('open without problem', () => {
fetchMock.post('*', {});
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" apply={() => {}}/>);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalPendaftaran, 'Button');
modalPendaftaran.handleApply();
ReactTestUtils.Simulate.click(modal);
expect(modalPendaftaran).to.exist;
fetchMock.restore();
});
it('open with problem', () => {
fetchMock.post('*', 404);
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" apply={() => {}}/>);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalPendaftaran, 'Button');
modalPendaftaran.handleApply();
ReactTestUtils.Simulate.click(modal);
expect(modalPendaftaran).to.exist;
fetchMock.restore();
});
it('change without problem', () => {
......
......@@ -3,6 +3,7 @@ import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import fetchMock from 'fetch-mock';
import ApproveModal from '../../components/ApproveModal';
import Applicant from '../../components/Applicant';
describe('ApproveModal', () => {
it('renders without problem', () => {
......@@ -14,7 +15,7 @@ describe('ApproveModal', () => {
it('open without problem', () => {
fetchMock.get('*', { student: { resume: 'asdasd' } });
const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' } }} />);
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' }, status: Applicant.APPLICATION_STATUS.NEW }} />);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalApproval, 'Button');
ReactTestUtils.Simulate.click(modal);
......@@ -24,8 +25,9 @@ describe('ApproveModal', () => {
it('close without problem', () => {
fetchMock.get('*', { student: { resume: 'asdasd' } });
fetchMock.patch('*', { student: { resume: 'asdasd' } });
const modalApproval = ReactTestUtils.renderIntoDocument(
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' } }} />);
<ApproveModal updateStatus={() => {}} data={{ key: 'value', student: { resume: 'asdasd' }, status: Applicant.APPLICATION_STATUS.NEW }} />);
modalApproval.handleClose();
expect(modalApproval.state.modalOpen).to.equal(false);
......
......@@ -99,30 +99,4 @@ describe('Vacancy', () => {
expect(lowongan.bookmark()).to.be.undefined;
fetchMock.restore();
});
it('apply without problem', () => {
fetchMock.post('*', response);
fetchMock.delete('*', response);
const lowongan = ReactTestUtils.renderIntoDocument(
<Vacancy status="Daftar" data={response2} bookmarked={1}/>);
const response3 = { student: { id: 1, name: 2 } };
lowongan.apply(1);
expect(lowongan.props.data.id).to.equal(3);
Storage.set('user-data', response3);
expect(lowongan.bookmark()).to.be.undefined;
fetchMock.restore();
});
it('apply with problem', () => {
fetchMock.post('*', 404);
fetchMock.delete('*', response);
const lowongan = ReactTestUtils.renderIntoDocument(
<Vacancy status="Daftar" data={response2} bookmarked={1}/>);
const response3 = { student: { id: 1, name: 2 } };
lowongan.apply(1);
expect(lowongan.props.data.id).to.equal(3);
Storage.set('user-data', response3);
expect(lowongan.bookmark()).to.be.undefined;
fetchMock.restore();
});
});
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