From be1b5996bfe4aa650d1d01aa3d9e88a494233613 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 18:56:55 +0700
Subject: [PATCH 01/10] Menghilangkan console.log

---
 assets/js/CompanyProfile.jsx | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx
index 794c6b96..9e5d27d9 100755
--- a/assets/js/CompanyProfile.jsx
+++ b/assets/js/CompanyProfile.jsx
@@ -1,15 +1,6 @@
 import React from 'react';
 import PropTypes from 'prop-types';
-import {
-  Segment,
-  Header,
-  Image,
-  Container,
-  Form,
-  Button,
-  Icon,
-  TextArea,
-} from 'semantic-ui-react';
+import { Segment, Header, Image, Container, Form, Button, Icon, TextArea } from 'semantic-ui-react';
 import { Doughnut } from 'react-chartjs-2';
 import TopMenu from './components/TopMenu';
 import Server from './lib/Server';
@@ -26,8 +17,6 @@ export default class CompanyProfile extends React.Component {
   constructor(props) {
     super(props);
     const data = TopMenu.getInfo(this.props.user);
-    console.log('ASdasdadasda');
-    console.log(data);
     this.state = {
       id: this.props.user.data.company.id,
       name: data.name,
@@ -57,7 +46,6 @@ export default class CompanyProfile extends React.Component {
       `/companies/${this.state.id}/`,
     ).then(
       (result) => {
-        console.log('ASDADS');
         this.setState({ linkedin_url: result.linkedin_url });
       },
     );
@@ -78,7 +66,6 @@ export default class CompanyProfile extends React.Component {
   getProfile() {
     return Server.get(`/companies/${this.state.id}/`).then(
       (result) => {
-        console.log(result);
         this.setState({
           name: result.name,
           address: result.address,
-- 
GitLab


From 1bd4b76a78423699f0733b59ecbcdd87f3675922 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 18:57:31 +0700
Subject: [PATCH 02/10] Menggunakan companySession dari Response.jsx untuk
 mencegah duplicate

---
 assets/js/__test__/CompanyProfile-test.jsx | 74 +++++++---------------
 1 file changed, 24 insertions(+), 50 deletions(-)

diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx
index c065dc41..368018bb 100755
--- a/assets/js/__test__/CompanyProfile-test.jsx
+++ b/assets/js/__test__/CompanyProfile-test.jsx
@@ -1,74 +1,48 @@
 import React from 'react';
 import ReactTestUtils from 'react-dom/test-utils';
 import CompanyProfile from '../CompanyProfile';
-
-const companyUserVerified = {
-  role: 'company',
-  data: {
-    url: 'http://localhost:8001/api/users/8/',
-    username: 'Tutuplapak',
-    email: '',
-    is_staff: false,
-    company: {
-      id: 3,
-      user: {
-        url: 'http://localhost:8001/api/users/8/',
-        username: 'Tutuplapak',
-        email: '',
-        is_staff: false,
-      },
-      name: 'Tutuplapak',
-      created: '2017-03-28T07:30:10.535000Z',
-      updated: '2017-03-28T07:30:10.535000Z',
-      description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla aliquet semper neque a fermentum. Duis ac tellus vitae augue iaculis ultrices. Curabitur commodo et neque nec feugiat. Morbi ac diam vel nunc commodo cursus. Phasellus nulla sapien, hendrerit vitae bibendum at, sollicitudin eu ante. Maecenas maximus, ante eu sollicitudin convallis, mauris nunc posuere risus, eu porttitor diam lacus vitae enim. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse at lectus a elit sollicitudin tempor. Nullam condimentum, justo nec tincidunt maximus, neque mi vulputate leo, sit amet lacinia massa ex eget sem. Duis ac erat facilisis, fringilla mauris in, consequat neque. In et neque consequat, vehicula magna at, efficitur ante. Mauris ac lacinia nibh.\r\n\r\nProin sagittis, lectus quis maximus varius, libero justo sollicitudin augue, non lacinia risus orci a enim. Curabitur iaculis enim quis ullamcorper commodo. Vivamus id nisi rhoncus, dignissim tellus quis, interdum est. Fusce sollicitudin eu libero ac feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas semper posuere ex, sed accumsan libero iaculis faucibus. Fusce laoreet ac ligula ut consectetur. Donec tortor mauris, rutrum at sodales et, viverra in dolor. Sed bibendum elit et maximus volutpat. Phasellus justo ipsum, laoreet sit amet faucibus eu, ultricies suscipit mauris. Nullam aliquam libero eu ante ultrices mattis. Donec non justo hendrerit neque volutpat placerat. Ut euismod est nec sem mollis, sit amet porttitor massa rhoncus. Aenean id erat sit amet nunc ultrices scelerisque non in ipsum. Curabitur sollicitudin nulla id mi accumsan venenatis.',
-      verified: true,
-      logo: 'http://localhost:8001/files/company-logo/8a258a48-3bce-4873-b5d1-538b360d0059.png',
-      address: 'Jl. Kebayoran Baru nomor 13, Jakarta Barat',
-      category: 'Belum ada kategori perusahaan',
-      website: 'Belum ada link website',
-      size: 'Jumlah karyawan belum dimasukan',
-      linkedin_url: 'Belum ada LinkedIn URL',
-    },
-    supervisor: null,
-    student: null,
-  },
-};
+import { companySession } from '../object/Response';
 
 describe('CompanyProfile', () => {
   it('renders without problem', () => {
     const companyProfile = ReactTestUtils.renderIntoDocument(
-      <CompanyProfile user={companyUserVerified} />);
+      <CompanyProfile
+        route={{ own: true, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />);
     expect(companyProfile).to.exist;
   });
 
   it('renders Doughnut chart without problem', () => {
     const companyProfile = ReactTestUtils.renderIntoDocument(
-      <CompanyProfile user={companyUserVerified} />);
+      <CompanyProfile
+        route={{ own: true, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />);
     const chart = ReactTestUtils.scryRenderedDOMComponentsWithTag(companyProfile, 'Doughnut');
     expect(chart).to.exist;
   });
 
   it('get company\'s profile without problem', () => {
     const profile = ReactTestUtils.renderIntoDocument(
-      <CompanyProfile user={companyUserVerified} />);
-    expect(profile.state.id).to.equal(companyUserVerified.data.company.id);
-    profile.getProfile().then(()=> {
-      expect(profile.state.name).to.equal(companyUserVerified.data.company.name);
-      expect(profile.state.address).to.equal(companyUserVerified.data.company.address);
-      expect(profile.state.category).to.equal(companyUserVerified.data.company.category);
-      expect(profile.state.description).to.equal(companyUserVerified.data.company.description);
-      expect(profile.state.size).to.equal(companyUserVerified.data.company.size);
-      expect(profile.state.website).to.equal(companyUserVerified.data.company.website);
-      expect(profile.state.logo).to.equal(companyUserVerified.data.company.logo);
-      expect(profile.state.linkedin_url).to.equal(companyUserVerified.data.company.linkedin_url);
-    });
+      <CompanyProfile
+        route={{ own: true, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />)
+      profile.getProfile().then(() => {
+        expect(profile.state.id).to.equal(companySession.company.id);
+      });
   });
 
-  it('submit edit form of verified company without problem', () => {
+  it('submit edit form of verified company', () => {
     const profile = ReactTestUtils.renderIntoDocument(
-      <CompanyProfile user={companyUserVerified} />);
-    profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', website:'www.uenak.com', linkedin_url:'https://www.linkedin.com/in/bob/',  size:'1000'};
-    const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[1];
+      <CompanyProfile
+        route={{ own: false, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />);
+    profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', 
+    website:'www.uenak.com', linkedin_url:'https://www.linkedin.com/in/bob/',  size:'1000'};
+    const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Button')[0];
     ReactTestUtils.Simulate.click(submitButton);
 
     const form = ReactTestUtils.findRenderedDOMComponentWithTag(profile, 'Form');
-- 
GitLab


From d034aee412412988feb366b1c822b90d6d7a4731 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 19:07:57 +0700
Subject: [PATCH 03/10] Menghapus Server.get yang tidak perlu karena sudah
 di-cover di getProfile()

---
 assets/js/CompanyProfile.jsx | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx
index 9e5d27d9..c6e92ff2 100755
--- a/assets/js/CompanyProfile.jsx
+++ b/assets/js/CompanyProfile.jsx
@@ -42,13 +42,6 @@ export default class CompanyProfile extends React.Component {
     this.getProfile = this.getProfile.bind(this);
     this.handleChange = this.handleChange.bind(this);
     this.handleSubmit = this.handleSubmit.bind(this);
-    Server.get(
-      `/companies/${this.state.id}/`,
-    ).then(
-      (result) => {
-        this.setState({ linkedin_url: result.linkedin_url });
-      },
-    );
     Server.get(
       `/companies/${this.props.user.data.company.id}/vacancies/`,
       false,
-- 
GitLab


From f08d6f89494c2db15bdb4036a2a6e0b4c03136e0 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 21:01:38 +0700
Subject: [PATCH 04/10] Mengurangi duplicate code di InfoLowonganModal

---
 assets/js/components/InfoLowonganModal.jsx | 55 +---------------------
 1 file changed, 2 insertions(+), 53 deletions(-)

diff --git a/assets/js/components/InfoLowonganModal.jsx b/assets/js/components/InfoLowonganModal.jsx
index 20dcc797..b765c5f0 100644
--- a/assets/js/components/InfoLowonganModal.jsx
+++ b/assets/js/components/InfoLowonganModal.jsx
@@ -2,60 +2,9 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import { Modal, Button } from 'semantic-ui-react';
 import ModalAlert from './ModalAlert';
+import GeneralModal from './GeneralModal';
 
-export default class InfoLowonganModal extends React.Component {
-  static propTypes = {
-    data: PropTypes.object.isRequired,
-    active: PropTypes.bool.isRequired,
-    buttonTitle: PropTypes.string.isRequired,
-    resume: PropTypes.string,
-    studentId: PropTypes.number.isRequired,
-    updateStatus: PropTypes.func.isRequired,
-  };
-
-  constructor(props) {
-    super(props);
-    /* istanbul ignore next */
-    this.state = {
-      modalOpen: false,
-      coverLetter: '',
-      load: false,
-    };
-    this.handleChange = this.handleChange.bind(this);
-    this.handleOpen = this.handleOpen.bind(this);
-    this.handleApply = this.handleApply.bind(this);
-  }
-
-  componentWillUpdate() {
-    this.fixBody();
-  }
-
-  componentDidUpdate() {
-    this.fixBody();
-  }
-
-  fixBody = () => {
-    const anotherModal = document.getElementsByClassName('ui page modals')
-      .length;
-    if (anotherModal > 0) document.body.classList.add('scrolling', 'dimmable', 'dimmed');
-  };
-
-  handleChange(event) {
-    this.setState({ coverLetter: event.target.value });
-  }
-
-  handleOpen() {
-    this.setState({ modalOpen: true });
-  }
-
-  handleClose = () => this.setState({
-    modalOpen: false,
-    load: false,
-  });
-
-  handleApply = () => {
-    this.setState({ load: true });
-  };
+export default class InfoLowonganModal extends GeneralModal {
 
   render() {
     return (
-- 
GitLab


From d0fffca54c63abbb05ec9de804e26d1785a391a1 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 22:51:10 +0700
Subject: [PATCH 05/10] Memperbaiki beberapa variabel dan kondisi if-else
 karena sudah required

---
 assets/js/CompanyProfile.jsx | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx
index c6e92ff2..f76eb7e4 100755
--- a/assets/js/CompanyProfile.jsx
+++ b/assets/js/CompanyProfile.jsx
@@ -2,7 +2,6 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import { Segment, Header, Image, Container, Form, Button, Icon, TextArea } from 'semantic-ui-react';
 import { Doughnut } from 'react-chartjs-2';
-import TopMenu from './components/TopMenu';
 import Server from './lib/Server';
 import Dumper from './lib/Dumper';
 import ModalAlert from './components/ModalAlert';
@@ -16,17 +15,16 @@ export default class CompanyProfile extends React.Component {
 
   constructor(props) {
     super(props);
-    const data = TopMenu.getInfo(this.props.user);
     this.state = {
       id: this.props.user.data.company.id,
-      name: data.name,
-      address: data.address,
-      category: data.category,
-      description: data.description,
-      website: data.website,
-      logo: data.logo,
-      size: data.size,
-      linkedin_url: data.linkedin_url,
+      name: this.props.user.data.company.name,
+      address: this.props.user.data.company.address,
+      category: this.props.user.data.company.category,
+      description: this.props.user.data.company.description,
+      website: this.props.user.data.company.website,
+      logo: this.props.user.data.company.logo,
+      size: this.props.user.data.company.size,
+      linkedin_url: this.props.user.data.company.linkedin_url,
       loading: false,
       form: {
         name: '',
@@ -69,10 +67,8 @@ export default class CompanyProfile extends React.Component {
           website: result.website,
           size: result.size,
           linkedin_url: result.linkedin_url,
+          logo: result.logo,
         });
-        if (result.logo != '') {
-          this.setState({ logo: result.logo });
-        }
       },
       (error) => error.then(() => {
         this.state.name = 'Gagal mendapatkan informasi';
-- 
GitLab


From 37e2e6b283daebaf836746a8136fe7e921157eba Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 22:51:35 +0700
Subject: [PATCH 06/10] Menambahkan variabel ke companySession dan companyUser

---
 assets/js/object/Response.jsx | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/assets/js/object/Response.jsx b/assets/js/object/Response.jsx
index 92b00fad..d2f03caf 100644
--- a/assets/js/object/Response.jsx
+++ b/assets/js/object/Response.jsx
@@ -92,6 +92,9 @@ export const companyUser = {
       verified: true,
       logo: 'http://localhost:8001/files/company-logo/8a258a48-3bce-4873-b5d1-538b360d0059.png',
       address: 'Jl. Kebayoran Baru nomor 13, Jakarta Barat',
+      website: 'www.testing.com',
+      linkedin_url: 'www.testing.com',
+      size: '1000',
     },
     supervisor: null,
     student: null,
@@ -119,6 +122,9 @@ export const companySession = {
     benefits: 'Makan siang gratis, Waktu kerja fleksibel, Asuransi kesehatan, Liburan berbayar',
     logo: 'http://localhost:8001/files/company-logo/8a258a48-3bce-4873-b5d1-538b360d0059.png',
     address: 'Jl. Kebayoran Baru nomor 13, Jakarta Barat',
+    website: 'www.testing.com',
+    linkedin_url: 'www.testing.com',
+    size: '1000',
   },
   supervisor: null,
   student: null,
-- 
GitLab


From c35e81e99057dfa5935b9d797bb562df24f49656 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Sun, 1 Dec 2019 22:52:03 +0700
Subject: [PATCH 07/10] Memperbaiki CompanyProfile-test

---
 assets/js/__test__/CompanyProfile-test.jsx | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx
index 368018bb..453253e7 100755
--- a/assets/js/__test__/CompanyProfile-test.jsx
+++ b/assets/js/__test__/CompanyProfile-test.jsx
@@ -34,14 +34,15 @@ describe('CompanyProfile', () => {
       });
   });
 
-  it('submit edit form of verified company', () => {
+  it('handle submit without problem', () => {
     const profile = ReactTestUtils.renderIntoDocument(
       <CompanyProfile
         route={{ own: false, data: companySession }}
         user={{ data: companySession }} params={{}}
       />);
     profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', 
-    website:'www.uenak.com', linkedin_url:'https://www.linkedin.com/in/bob/',  size:'1000'};
+    website:'www.uenak.com', linkedin_url:'',  size:'1000'};
+
     const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Button')[0];
     ReactTestUtils.Simulate.click(submitButton);
 
@@ -49,4 +50,15 @@ describe('CompanyProfile', () => {
     ReactTestUtils.Simulate.submit(form);
   });
 
+  it('handle change without problem', () => {
+    const profile = ReactTestUtils.renderIntoDocument(
+      <CompanyProfile
+        route={{ own: false, data: companySession }}
+        user={{ data: companySession }} params={{}}
+      />);
+    
+    profile.handleChange({ target: { name: 'name', value: 'okedeh' }});
+    expect(profile.state.form.name).to.equal('okedeh');
+  });
+
 });
\ No newline at end of file
-- 
GitLab


From d4e783fa510fd63a743ae3697f0ce5298e5e3186 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Mon, 2 Dec 2019 10:56:24 +0700
Subject: [PATCH 08/10] Refactor test CompanyProfile

---
 assets/js/__test__/CompanyProfile-test.jsx | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx
index 453253e7..7dbc604e 100755
--- a/assets/js/__test__/CompanyProfile-test.jsx
+++ b/assets/js/__test__/CompanyProfile-test.jsx
@@ -29,15 +29,14 @@ describe('CompanyProfile', () => {
         route={{ own: true, data: companySession }}
         user={{ data: companySession }} params={{}}
       />)
-      profile.getProfile().then(() => {
-        expect(profile.state.id).to.equal(companySession.company.id);
-      });
+      expect(profile.state.id).to.equal(companySession.company.id);
+      
   });
 
-  it('handle submit without problem', () => {
+  it('handle submit with problem', () => {
     const profile = ReactTestUtils.renderIntoDocument(
       <CompanyProfile
-        route={{ own: false, data: companySession }}
+        route={{ own: true, data: companySession }}
         user={{ data: companySession }} params={{}}
       />);
     profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', 
@@ -48,12 +47,15 @@ describe('CompanyProfile', () => {
 
     const form = ReactTestUtils.findRenderedDOMComponentWithTag(profile, 'Form');
     ReactTestUtils.Simulate.submit(form);
+    
+    // There's an error, so it remains unchanged
+    expect(profile.state.name).to.not.equal('Restopedia');
   });
 
   it('handle change without problem', () => {
     const profile = ReactTestUtils.renderIntoDocument(
       <CompanyProfile
-        route={{ own: false, data: companySession }}
+        route={{ own: true, data: companySession }}
         user={{ data: companySession }} params={{}}
       />);
     
-- 
GitLab


From c9d9b577b930a166d724928fd96cb52224cbaa36 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Mon, 2 Dec 2019 10:56:44 +0700
Subject: [PATCH 09/10] Menambah kondisi error

---
 assets/js/CompanyProfile.jsx | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx
index f76eb7e4..1216c767 100755
--- a/assets/js/CompanyProfile.jsx
+++ b/assets/js/CompanyProfile.jsx
@@ -40,18 +40,28 @@ export default class CompanyProfile extends React.Component {
     this.getProfile = this.getProfile.bind(this);
     this.handleChange = this.handleChange.bind(this);
     this.handleSubmit = this.handleSubmit.bind(this);
+
     Server.get(
       `/companies/${this.props.user.data.company.id}/vacancies/`,
       false,
     ).then((result) => {
       this.setState({ vacancies: result.results });
-    });
+    },
+    (error) => error.then(() => {
+      console.log(error);
+    }),
+    );
+    
     Server.get(
       `/companies/${this.props.user.data.company.id}/applications/`,
       false,
     ).then((result) => {
       this.setState({ applications: result.results });
-    });
+    },
+    (error) => error.then(() => {
+      console.log(error);
+    }),
+    );
   }
 
   getProfile() {
@@ -72,6 +82,7 @@ export default class CompanyProfile extends React.Component {
       },
       (error) => error.then(() => {
         this.state.name = 'Gagal mendapatkan informasi';
+        console.log(error);
       }),
     );
   }
-- 
GitLab


From 7f47cfe8da2fde60f3aba8b4c0f956ad696240e6 Mon Sep 17 00:00:00 2001
From: "alsabila.shakina" <alsabila.shakina@ui.ac.id>
Date: Mon, 2 Dec 2019 11:16:14 +0700
Subject: [PATCH 10/10] Refactor test CompanyProfile lagi, ada yang tertinggal

---
 assets/js/__test__/CompanyProfile-test.jsx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx
index 7dbc604e..85db4ce2 100755
--- a/assets/js/__test__/CompanyProfile-test.jsx
+++ b/assets/js/__test__/CompanyProfile-test.jsx
@@ -47,7 +47,8 @@ describe('CompanyProfile', () => {
 
     const form = ReactTestUtils.findRenderedDOMComponentWithTag(profile, 'Form');
     ReactTestUtils.Simulate.submit(form);
-    
+
+    profile.getProfile();
     // There's an error, so it remains unchanged
     expect(profile.state.name).to.not.equal('Restopedia');
   });
-- 
GitLab