Fakultas Ilmu Komputer UI

Commit c185ac43 authored by M. Reza Qorib's avatar M. Reza Qorib
Browse files

[#140652771] #18 Refactor test codes

parent b9ac3cf0
......@@ -4,11 +4,11 @@ import ReactTestUtils from 'react-addons-test-utils';
import ApplyModal from '../../components/ApplyModal';
describe('ApplyModal', () => {
it('renders without problem', () => {
it('renders without problem', () => {
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
<ApplyModal id={4} data={{key: 'value'}} buttonTitle="submit" />);
<ApplyModal id={4} data={{ key: 'value' }} buttonTitle="submit" />);
expect(modalPendaftaran).to.exist;
});
});
it('open without problem', () => {
const modalPendaftaran = ReactTestUtils.renderIntoDocument(
......
/**
* Created by baisa on 09/04/2017.
*/
import React from 'react';
import ReactTestUtils from 'react-addons-test-utils';
import CompanyVacancy from '../../components/CompanyVacancy';
describe('ApplyModal', () => {
it('renders without problem', () => {
describe('CompanyVacancy', () => {
const response ={
close_time: '2019-03-28T05:55:42Z',
company: {
address: 'kebayoran baru',
id: 1,
logo: null,
name: 'tutup lapak',
},
created: '2017-03-28T07:05:47.128672Z',
description: 'Lorem ipsum dolbh.',
id: 3,
name: 'Software Engineer',
open_time: '2017-03-28T05:55:38Z',
updated: '2017-03-28T07:34:13.122093Z',
verified: true,
};
const response2 = {
close_time: '2019-03-28T05:55:42Z',
company: {
address: 'kebayoran baru',
id: 1,
logo: 'pictures',
name: 'tutup lapak',
},
created: '2017-03-28T07:05:47.128672Z',
description: 'Lorem ipsum dolbh.',
id: 3,
name: 'Software Engineer',
open_time: '2017-03-28T05:55:38Z',
updated: '2017-03-28T07:34:13.122093Z',
verified: true,
};
it('renders with logo without problem', () => {
const companyVacancy = ReactTestUtils.renderIntoDocument(
<CompanyVacancy data={response2} />);
expect(companyVacancy).to.exist;
});
it('renders without logo without problem', () => {
const companyVacancy = ReactTestUtils.renderIntoDocument(
<CompanyVacancy header="header"/>);
<CompanyVacancy data={response} />);
expect(companyVacancy).to.exist;
});
}
});
});
......@@ -8,11 +8,11 @@ describe('Vacancy', () => {
const fetchMock = require('fetch-mock');
const response ={
close_time: '2019-03-28T05:55:42Z',
company: {
company: {
address: 'kebayoran baru',
id: 1,
logo: null,
name: 'tutup lapak',
id: 1,
logo: null,
name: 'tutup lapak',
},
created: '2017-03-28T07:05:47.128672Z',
description: 'Lorem ipsum dolbh.',
......
......@@ -22,19 +22,26 @@ describe('VacancyList', () => {
updated: '2017-03-28T07:34:13.122093Z',
verified: true,
}];
// const response2 = { hello: 'not-world' };
it('renders without problem', () => {
fetchMock.get('*', response);
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList studentId={1} url="test" />);
<VacancyList userId={1} url="test" />);
expect(vacancyList).to.exist;
});
it('renders without problem for company', () => {
fetchMock.get('*', response);
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList type='company' userId={1} url="test" />);
vacancyList.state.vacancies = response;
expect(vacancyList.generateVacancies()).to.exist;
});
it('update bookmarks without problem', () => {
fetchMock.get('*', response);
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList studentId={1} url="test" />);
<VacancyList userId={1} url="test" />);
vacancyList.updateBookmarkList();
expect(JSON.stringify(vacancyList.state.bookmarkList)).to.be.defined;
});
......@@ -42,19 +49,27 @@ describe('VacancyList', () => {
it('renders marked bookmarked vacancies without problem', () => {
fetchMock.get('*', response);
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList studentId={1} url="test" />);
<VacancyList userId={1} url="test" />);
vacancyList.state.vacancies = response;
vacancyList.state.bookmarkList = [{id: 5}, {id: 3}];
vacancyList.state.bookmarkList = [{id: 5}, {id: 3}, {id: 1}];
expect(vacancyList.generateVacancies()).to.exist;
});
it('renders not marked vacancies without problem', () => {
fetchMock.get('*', response);
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList userId={1} url="test" />);
vacancyList.state.vacancies = response;
vacancyList.state.bookmarkList = [{id: 6}, {id: 4}, {id: 2}];
expect(vacancyList.generateVacancies()).to.exist;
});
it('success calling API', () => {
fetchMock.get('*', response);
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList studentId={1} url="test" />);
<VacancyList userId={1} url="test" />);
vacancyList.state.vacancies = response;
expect(JSON.stringify(vacancyList.state.vacancies)).to.equal(JSON.stringify(response));
expect(vacancyList.generateVacancies()).to.exist;
});
});
......@@ -24,10 +24,10 @@ export default class VacancyList extends React.Component {
if (this.props.type === 'student') {
this.updateBookmarkList();
}
this.state = { vacancies: [], bookmarkList: [] };
Server.get(this.props.url, false).then((data) => {
this.setState({ vacancies: data });
});
this.state = { vacancies: [], bookmarkList: [] };
this.updateBookmarkList = this.updateBookmarkList.bind(this);
this.generateVacancies = this.generateVacancies.bind(this);
this.checkBookmark = this.checkBookmark.bind(this);
......
[0415/162748.577:ERROR:prune_crash_reports.cc(35)] PruneCrashReportDatabase: Failed to get pending reports
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