diff --git a/assets/js/__test__/components/ApplyModal-test.jsx b/assets/js/__test__/components/ApplyModal-test.jsx index 58baa31d2d68f6438a27d7f6e0cf7eaeaaf6c0f0..f805b8dba8b9d81bfe2d2650c8f374eb41bf2ca6 100644 --- a/assets/js/__test__/components/ApplyModal-test.jsx +++ b/assets/js/__test__/components/ApplyModal-test.jsx @@ -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( diff --git a/assets/js/__test__/components/CompanyVacancy-test.js b/assets/js/__test__/components/CompanyVacancy-test.js index 5ae7ef927f36e71add534914f5a8279c57e1093f..df7bc4dbc9a9f1af9d96313a57676acd3bf1d1ac 100644 --- a/assets/js/__test__/components/CompanyVacancy-test.js +++ b/assets/js/__test__/components/CompanyVacancy-test.js @@ -1,14 +1,52 @@ -/** - * 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; - }); -} + }); + +}); diff --git a/assets/js/__test__/components/Vacancy-test.jsx b/assets/js/__test__/components/Vacancy-test.jsx index a98d55657dedf5404f493a9495e34b091aaa5369..8a08783eaa8520412da6aaaf335bef3bce6b24c3 100644 --- a/assets/js/__test__/components/Vacancy-test.jsx +++ b/assets/js/__test__/components/Vacancy-test.jsx @@ -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.', diff --git a/assets/js/__test__/components/VacancyList-test.jsx b/assets/js/__test__/components/VacancyList-test.jsx index b94249c1f41b0e696389e015b1620b63763a9440..3663c12926e65036a92cd4f53b93140f7b57da82 100644 --- a/assets/js/__test__/components/VacancyList-test.jsx +++ b/assets/js/__test__/components/VacancyList-test.jsx @@ -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; }); }); diff --git a/assets/js/components/VacancyList.jsx b/assets/js/components/VacancyList.jsx index d14c126d0dc8ea50004feaa3f601a87a50ad33b0..37295929cbb8038b2622bf71ab930f6c034750c6 100644 --- a/assets/js/components/VacancyList.jsx +++ b/assets/js/components/VacancyList.jsx @@ -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); diff --git a/debug.log b/debug.log new file mode 100644 index 0000000000000000000000000000000000000000..48169a2e171ee3907eb15b383c6c54cd59d2ac69 --- /dev/null +++ b/debug.log @@ -0,0 +1 @@ +[0415/162748.577:ERROR:prune_crash_reports.cc(35)] PruneCrashReportDatabase: Failed to get pending reports