mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
fix test lint
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user