From a59613f3602bd7405ecf04a78abb3b6069ebeb9c Mon Sep 17 00:00:00 2001 From: Kristianto <liauwkristianto@gmail.com> Date: Fri, 15 Nov 2019 17:48:20 +0700 Subject: [PATCH 1/3] Add get student profile test --- assets/js/__test__/ProfilePage-test.jsx | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/assets/js/__test__/ProfilePage-test.jsx b/assets/js/__test__/ProfilePage-test.jsx index 32762b6a..e47c0e6e 100755 --- a/assets/js/__test__/ProfilePage-test.jsx +++ b/assets/js/__test__/ProfilePage-test.jsx @@ -5,6 +5,40 @@ import fetchMock from 'fetch-mock'; import ProfilePage from '../ProfilePage'; import { studentSession, companyUser, response, response2 } from '../object/Response'; +const studentUserVerified = { + role: 'student', + data: { + url: 'http://localhost:8000/api/users/9/', + username: 'muhammad.reza42', + email: 'muhammad.reza42@ui.ac.id', + is_staff: false, + company: null, + supervisor: null, + student: { + id: 3, + user: { + url: 'http://localhost:8000/api/users/9/', + username: 'muhammad.reza42', + email: 'muhammad.reza42@ui.ac.id', + is_staff: false, + }, + name: 'Muhammad R.', + created: '2017-03-28T13:33:46.147241Z', + updated: '2017-03-28T13:33:46.148248Z', + npm: 1406543593, + resume: null, + phone_number: null, + bookmarked_vacancies: [ + 3, + ], + applied_vacancies: [ + 3, + 1, + ], + }, + }, +}; + describe('ProfilePage', () => { it('renders without problem', () => { fetchMock.get('*', response); @@ -32,6 +66,21 @@ describe('ProfilePage', () => { fetchMock.restore(); }); + it('get student profile without problem', () => { + fetchMock.get('*', response); + const profile = ReactTestUtils.renderIntoDocument( + <ProfilePage route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{}} />); + profile.getProfile().then(()=> { + expect(profile.state.name).to.equal(student.name); + expect(profile.state.npm).to.equal(student.npm); + expect(profile.state.birth_date).to.equal(student.birth_date); + expect(profile.state.major).to.equal(student.major); + expect(profile.state.batch).to.equal(student.batch); + expect(profile.state.bookmarked_vacancies).to.equal(student.bookmarked_vacancies); + expect(profile.state.applied_vacancies).to.equal(student.applied_vacancies); + }); + }) + it('renders edit profile default value', () => { fetchMock.get('*', response); const profile = ReactTestUtils.renderIntoDocument( @@ -72,3 +121,4 @@ describe('ProfilePage', () => { }); }); + -- GitLab From d0397ad8edbfb87d5eefc6d2d6673c2da492e656 Mon Sep 17 00:00:00 2001 From: Kristianto <kristianto61@ui.ac.id> Date: Fri, 15 Nov 2019 18:51:12 +0700 Subject: [PATCH 2/3] File name changes --- .../{CompanyVacancy-test.js => CompanyVacancy-test.jsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename assets/js/__test__/components/{CompanyVacancy-test.js => CompanyVacancy-test.jsx} (100%) diff --git a/assets/js/__test__/components/CompanyVacancy-test.js b/assets/js/__test__/components/CompanyVacancy-test.jsx similarity index 100% rename from assets/js/__test__/components/CompanyVacancy-test.js rename to assets/js/__test__/components/CompanyVacancy-test.jsx -- GitLab From 55a60108f338c2c13f8a73981e6eb2964a75d9bf Mon Sep 17 00:00:00 2001 From: Kristianto <kristianto61@ui.ac.id> Date: Fri, 15 Nov 2019 19:13:08 +0700 Subject: [PATCH 3/3] Fix typo --- assets/js/__test__/ProfilePage-test.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/js/__test__/ProfilePage-test.jsx b/assets/js/__test__/ProfilePage-test.jsx index b68f11a2..976919ad 100755 --- a/assets/js/__test__/ProfilePage-test.jsx +++ b/assets/js/__test__/ProfilePage-test.jsx @@ -71,13 +71,13 @@ describe('ProfilePage', () => { const profile = ReactTestUtils.renderIntoDocument( <ProfilePage route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{}} />); profile.getProfile().then(()=> { - expect(profile.state.name).to.equal(student.name); - expect(profile.state.npm).to.equal(student.npm); - expect(profile.state.birth_date).to.equal(student.birth_date); - expect(profile.state.major).to.equal(student.major); - expect(profile.state.batch).to.equal(student.batch); - expect(profile.state.bookmarked_vacancies).to.equal(student.bookmarked_vacancies); - expect(profile.state.applied_vacancies).to.equal(student.applied_vacancies); + expect(profile.state.name).to.equal(studentUserVerified.data.student.name); + expect(profile.state.npm).to.equal(studentUserVerified.data.student.npm); + expect(profile.state.birth_date).to.equal(studentUserVerified.data.student.birth_date); + expect(profile.state.major).to.equal(studentUserVerified.data.student.major); + expect(profile.state.batch).to.equal(studentUserVerified.data.student.batch); + expect(profile.state.bookmarked_vacancies).to.equal(studentUserVerified.data.student.bookmarked_vacancies); + expect(profile.state.applied_vacancies).to.equal(studentUserVerified.data.student.applied_vacancies); }); }) -- GitLab