v3 fix GET /groups: return an error only if an invalid type is supplied not when there are 0 results (#7203)

This commit is contained in:
Matteo Pagliazzi
2016-05-13 19:08:38 +02:00
parent 199732539f
commit 468a312357
3 changed files with 20 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ import {
generateUser,
resetHabiticaDB,
generateGroup,
translate as t,
} from '../../../../helpers/api-v3-integration.helper';
import {
TAVERN_ID,
@@ -70,6 +71,15 @@ describe('GET /groups', () => {
});
});
it('returns error when an invalid ?type query is passed', async () => {
await expect(user.get('/groups?type=invalid'))
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('groupTypesRequired'),
});
});
it('returns only the tavern when tavern passed in as query', async () => {
await expect(user.get('/groups?type=tavern'))
.to.eventually.have.a.lengthOf(1)