diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index 794c6b96f22e5649cf0bd1920e4698a39d13a758..c6e92ff2165da0e97ff326d388034f23e82f4021 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, @@ -53,14 +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) => { - console.log('ASDADS'); - this.setState({ linkedin_url: result.linkedin_url }); - }, - ); Server.get( `/companies/${this.props.user.data.company.id}/vacancies/`, false, @@ -78,7 +59,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, diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx index c065dc4124476cedac49e77ff3379a55fe79696e..368018bbfe0401a7824205e96399859cec3d0034 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'); diff --git a/assets/js/components/InfoLowonganModal.jsx b/assets/js/components/InfoLowonganModal.jsx index 20dcc7975fc3d2defe1a3b7151bc4a886db40230..b765c5f073cf1eda58068262e6626f52fb254e3f 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 (