improved db query support, added tests

This commit is contained in:
Wyatt Johnson
2018-03-14 14:55:24 -06:00
parent 028f2a0d11
commit 1a8006e3a3
2 changed files with 66 additions and 18 deletions
+13
View File
@@ -58,6 +58,19 @@ describe('services.UsersService', () => {
});
});
describe('#getInitialUsername', () => {
it('should find the first result when there is no conflict', async () => {
const username = await UsersService.getInitialUsername(
'TheGreatSockmonster'
);
expect(username).to.equal('TheGreatSockmonster');
});
it('should find a first result when there is a conflict', async () => {
const username = await UsersService.getInitialUsername('Sockmonster');
expect(username).to.match(/Sockmonster_[0-9]+/);
});
});
describe('#findPublicByIdArray()', () => {
it('should find an array of users from an array of ids', async () => {
const ids = mockUsers.map(user => user.id);