fix test lint

This commit is contained in:
Matteo Pagliazzi
2019-10-08 20:45:38 +02:00
parent e37f4467f8
commit 85fb5f33aa
367 changed files with 6635 additions and 6080 deletions

View File

@@ -1,20 +1,20 @@
import { v4 as generateUUID } from 'uuid';
import {
generateUser,
translate as t,
} from '../../../../helpers/api-integration/v3';
import { v4 as generateUUID } from 'uuid';
describe('GET /heroes/:heroId', () => {
let user;
before(async () => {
user = await generateUser({
contributor: {admin: true},
contributor: { admin: true },
});
});
it('requires the caller to be an admin', async () => {
let nonAdmin = await generateUser();
const nonAdmin = await generateUser();
await expect(nonAdmin.get(`/hall/heroes/${user._id}`)).to.eventually.be.rejected.and.eql({
code: 401,
@@ -27,24 +27,24 @@ describe('GET /heroes/:heroId', () => {
await expect(user.get('/hall/heroes/invalidUUID')).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('userWithIDNotFound', {userId: 'invalidUUID'}),
message: t('userWithIDNotFound', { userId: 'invalidUUID' }),
});
});
it('handles non-existing heroes', async () => {
let dummyId = generateUUID();
const dummyId = generateUUID();
await expect(user.get(`/hall/heroes/${dummyId}`)).to.eventually.be.rejected.and.eql({
code: 404,
error: 'NotFound',
message: t('userWithIDNotFound', {userId: dummyId}),
message: t('userWithIDNotFound', { userId: dummyId }),
});
});
it('returns only necessary hero data given user id', async () => {
let hero = await generateUser({
contributor: {tier: 23},
const hero = await generateUser({
contributor: { tier: 23 },
});
let heroRes = await user.get(`/hall/heroes/${hero._id}`);
const heroRes = await user.get(`/hall/heroes/${hero._id}`);
expect(heroRes).to.have.all.keys([ // works as: object has all and only these keys
'_id', 'id', 'balance', 'profile', 'purchased',
@@ -55,10 +55,10 @@ describe('GET /heroes/:heroId', () => {
});
it('returns only necessary hero data given username', async () => {
let hero = await generateUser({
contributor: {tier: 23},
const hero = await generateUser({
contributor: { tier: 23 },
});
let heroRes = await user.get(`/hall/heroes/${hero.auth.local.username}`);
const heroRes = await user.get(`/hall/heroes/${hero.auth.local.username}`);
expect(heroRes).to.have.all.keys([ // works as: object has all and only these keys
'_id', 'id', 'balance', 'profile', 'purchased',
@@ -70,7 +70,7 @@ describe('GET /heroes/:heroId', () => {
it('returns correct hero using search with difference case', async () => {
await generateUser({}, { username: 'TestUpperCaseName123' });
let heroRes = await user.get('/hall/heroes/TestuPPerCasEName123');
const heroRes = await user.get('/hall/heroes/TestuPPerCasEName123');
expect(heroRes.auth.local.username).to.equal('TestUpperCaseName123');
});
});