Require username to be different when editing it

This commit is contained in:
Chi Vinh Le
2017-06-21 21:18:28 +07:00
parent 6628e6d08d
commit f709057933
6 changed files with 73 additions and 26 deletions
+17
View File
@@ -54,6 +54,23 @@ describe('/api/v1/account/username', () => {
});
});
it('it should return an error when the user submits the same username', (done) => {
chai.request(app)
.post(`/api/v1/users/${mockUser.id}/username-enable`)
.set(passport.inject({id: '456', roles: ['ADMIN']}))
.then(() => chai.request(app)
.put('/api/v1/account/username')
.set(passport.inject({id: mockUser.id, roles: []}))
.send({username: 'Ana'}))
.then(() => {
done(new Error('Expected Error'));
})
.catch((err) => {
expect(err).to.be.ok;
done();
});
});
it('it should return an error when the user tries to edit their username if canEditName is disabled', (done) => {
chai.request(app)
.put('/api/v1/account/username')