Skip to content

Commit

Permalink
feat(profile): change update profile requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
thislekan committed Apr 16, 2019
1 parent f0a710e commit 6237594
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
4 changes: 0 additions & 4 deletions server/middlewares/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ export default class Validator {
static validateUpdateProfile() {
return [
...Validator.validateUpdateUsername(),
...Validator.validateFirstname(),
...Validator.validateLastname(),
...Validator.validateBio(),
...Validator.validateImageURL()
];
}

Expand Down
72 changes: 0 additions & 72 deletions test/integrations/routes/profile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,42 +68,6 @@ describe('Testing user profile feature', () => {
});
});

it('should return an error if firstname is not provided', (done) => {
chai
.request(app)
.post('/api/v1/profiles')
.send({ ...profile, firstname: '' })
.set('Authorization', `Bearer ${dummyUser3.token}`)
.end((err, res) => {
expect(res.status).eql(BAD_REQUEST);
expect(res.body).to.have.property('status').equal(false);
expect(res.body).to.have.property('code').equal(400);
expect(res.body).to.have.property('message').equal(MESSAGE.PROFILE_UPDATE_ERROR);
expect(res.body).to.have.property('data');
expect(res.body.data[0].field).to.be.equals('firstname');
expect(res.body.data[0].message).to.be.equals('Firstname is required');
done();
});
});

it('should return an error if lastname is not provided', (done) => {
chai
.request(app)
.post('/api/v1/profiles')
.send({ ...profile, lastname: '' })
.set('Authorization', `Bearer ${dummyUser3.token}`)
.end((err, res) => {
expect(res.status).eql(BAD_REQUEST);
expect(res.body).to.have.property('status').equal(false);
expect(res.body).to.have.property('code').equal(400);
expect(res.body).to.have.property('message').equal(MESSAGE.PROFILE_UPDATE_ERROR);
expect(res.body).to.have.property('data');
expect(res.body.data[0].field).to.be.equals('lastname');
expect(res.body.data[0].message).to.be.equals('Lastname is required');
done();
});
});

it('should return error if username is not provided', (done) => {
chai
.request(app)
Expand All @@ -122,42 +86,6 @@ describe('Testing user profile feature', () => {
});
});

it('should throw an error if bio is not provided', (done) => {
chai
.request(app)
.post('/api/v1/profiles')
.send({ ...profile, bio: '' })
.set('Authorization', `Bearer ${dummyUser3.token}`)
.end((err, res) => {
expect(res.status).eql(BAD_REQUEST);
expect(res.body).to.have.property('status').equal(false);
expect(res.body).to.have.property('code').equal(400);
expect(res.body).to.have.property('message').equal(MESSAGE.PROFILE_UPDATE_ERROR);
expect(res.body).to.have.property('data');
expect(res.body.data[0].field).to.be.equals('bio');
expect(res.body.data[0].message).to.be.equals('Bio is required');
done();
});
});

it('should throw an error if image url is invalid', (done) => {
chai
.request(app)
.post('/api/v1/profiles')
.send({ ...profile, image: 'hffhh.cam' })
.set('Authorization', `Bearer ${dummyUser3.token}`)
.end((err, res) => {
expect(res.status).eql(BAD_REQUEST);
expect(res.body).to.have.property('status').equal(false);
expect(res.body).to.have.property('code').equal(400);
expect(res.body).to.have.property('message').equal(MESSAGE.PROFILE_UPDATE_ERROR);
expect(res.body).to.have.property('data');
expect(res.body.data[0].field).to.be.equals('image');
expect(res.body.data[0].message).to.be.equals('image URL is not valid');
done();
});
});

it('should fetch all users', (done) => {
chai
.request(app)
Expand Down

0 comments on commit 6237594

Please sign in to comment.