diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index c6e92ff2165da0e97ff326d388034f23e82f4021..f76eb7e498848141c626b6658406020d8fb6a9eb 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'; diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx index 368018bbfe0401a7824205e96399859cec3d0034..453253e7ce1d977f02f416f6a7389f1b1d88129c 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 diff --git a/assets/js/object/Response.jsx b/assets/js/object/Response.jsx index 92b00fad5b55677397f07bee522b1b238213ef51..d2f03caf883f4c28aa12068371c79f7831c3be2c 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,