Fakultas Ilmu Komputer UI

Commit abc7387b authored by Alsabila Shakina Prasetyo's avatar Alsabila Shakina Prasetyo
Browse files

Edit Website Perusahaan 1606917613 99

parent 27bc4f14
......@@ -30,6 +30,7 @@ export default class CompanyProfile extends React.Component {
name: '',
address: '',
description: '',
website: '',
},
refresh: 1,
applications: [],
......@@ -155,6 +156,11 @@ export default class CompanyProfile extends React.Component {
<TextArea placeholder='Try adding multiple lines' name="description" onChange={this.handleChange}
autoHeight
defaultValue={this.state.description === null ? null : this.state.description}/>
</Form.Field>
<Form.Field>
<label htmlFor="website">Website</label>
<input placeholder="Alamat Website" name="website" onChange={this.handleChange}
defaultValue={this.state.website === null ? null : this.state.website}/>
</Form.Field>
<Button type="submit" size="small" loading={this.state.loading} primary floated="right">Submit</Button>
</Form>
......
......@@ -55,6 +55,7 @@ describe('CompanyProfile', () => {
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.website).to.equal(companyUserVerified.data.company.website);
expect(profile.state.logo).to.equal(companyUserVerified.data.company.logo);
});
});
......@@ -62,7 +63,7 @@ describe('CompanyProfile', () => {
it('submit edit form of verified company without problem', () => {
const profile = ReactTestUtils.renderIntoDocument(
<CompanyProfile user={companyUserVerified} />);
profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar'};
profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', website:'www.uenak.com'};
const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[1];
ReactTestUtils.Simulate.click(submitButton);
......
......@@ -130,11 +130,13 @@ class CompanyUpdateSerializer(serializers.ModelSerializer):
return {
'address': instance.address,
'description': instance.description,
'name': instance.name
'name': instance.user.first_name,
'website' : instance.website,
}
def update(self, instance, validated_data):
instance.address = validated_data.get('address', instance.address)
instance.website = validated_data.get('website', instance.website)
instance.description = validated_data.get(
'description', instance.description)
instance.user.first_name = validated_data.get(
......@@ -145,7 +147,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer):
class Meta:
model = Company
fields = ['address', 'description', 'name']
fields = ['address', 'description', 'name' , 'website']
class CompanySerializer(serializers.ModelSerializer):
......
......@@ -288,7 +288,8 @@ class ProfileUpdateTests(APITestCase):
Company.objects.create(user=new_user, description="lalalala", status=Company.VERIFIED, logo=None, address=None)
url = '/api/login/'
response = self.client.post(url, {'username': 'dummy.login.company', 'password': 'lalala123', 'login-type': 'company'}, format='json')
response = self.client.post(url, {'username': 'dummy.login.company', 'password': 'lalala123', 'login-type': 'company'},
format='json')
company_id = response.data.get('company').get('id')
url = '/api/companies/' + str(company_id) + "/profile/"
......@@ -301,3 +302,6 @@ class ProfileUpdateTests(APITestCase):
response = self.client.patch(url, {'description': 'Masak-Masak'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
response = self.client.patch(url, {'website': 'www.huehue.com'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment