mirror of
https://github.com/wassname/talk.git
synced 2026-07-18 12:40:13 +08:00
Require username to be different when editing it
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user