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,9 +1,9 @@
import { each, get } from 'lodash';
import {
generateUser,
translate as t,
} from '../../../../helpers/api-integration/v3';
import { each, get } from 'lodash';
describe('PUT /user', () => {
let user;
@@ -40,7 +40,7 @@ describe('PUT /user', () => {
});
it('update tags', async () => {
let userTags = user.tags;
const userTags = user.tags;
await user.put('/user', {
tags: [...user.tags, {
@@ -98,20 +98,20 @@ describe('PUT /user', () => {
});
context('Top Level Protected Operations', () => {
let protectedOperations = {
'gem balance': {balance: 100},
auth: {'auth.blocked': true, 'auth.timestamps.created': new Date()},
contributor: {'contributor.level': 9, 'contributor.admin': true, 'contributor.text': 'some text'},
backer: {'backer.tier': 10, 'backer.npc': 'Bilbo'},
subscriptions: {'purchased.plan.extraMonths': 500, 'purchased.plan.consecutive.trinkets': 1000},
'customization gem purchases': {'purchased.background.tavern': true, 'purchased.skin.bear': true},
notifications: [{type: 123}],
webhooks: {webhooks: [{url: 'https://foobar.com'}]},
const protectedOperations = {
'gem balance': { balance: 100 },
auth: { 'auth.blocked': true, 'auth.timestamps.created': new Date() },
contributor: { 'contributor.level': 9, 'contributor.admin': true, 'contributor.text': 'some text' },
backer: { 'backer.tier': 10, 'backer.npc': 'Bilbo' },
subscriptions: { 'purchased.plan.extraMonths': 500, 'purchased.plan.consecutive.trinkets': 1000 },
'customization gem purchases': { 'purchased.background.tavern': true, 'purchased.skin.bear': true },
notifications: [{ type: 123 }],
webhooks: { webhooks: [{ url: 'https://foobar.com' }] },
};
each(protectedOperations, (data, testName) => {
it(`does not allow updating ${testName}`, async () => {
let errorText = t('messageUserOperationProtected', { operation: Object.keys(data)[0] });
const errorText = t('messageUserOperationProtected', { operation: Object.keys(data)[0] });
await expect(user.put('/user', data)).to.eventually.be.rejected.and.eql({
code: 401,
@@ -123,17 +123,17 @@ describe('PUT /user', () => {
});
context('Sub-Level Protected Operations', () => {
let protectedOperations = {
'class stat': {'stats.class': 'wizard'},
'flags unless whitelisted': {'flags.dropsEnabled': true},
webhooks: {'preferences.webhooks': [1, 2, 3]},
sleep: {'preferences.sleep': true},
'disable classes': {'preferences.disableClasses': true},
const protectedOperations = {
'class stat': { 'stats.class': 'wizard' },
'flags unless whitelisted': { 'flags.dropsEnabled': true },
webhooks: { 'preferences.webhooks': [1, 2, 3] },
sleep: { 'preferences.sleep': true },
'disable classes': { 'preferences.disableClasses': true },
};
each(protectedOperations, (data, testName) => {
it(`does not allow updating ${testName}`, async () => {
let errorText = t('messageUserOperationProtected', { operation: Object.keys(data)[0] });
const errorText = t('messageUserOperationProtected', { operation: Object.keys(data)[0] });
await expect(user.put('/user', data)).to.eventually.be.rejected.and.eql({
code: 401,
@@ -145,7 +145,7 @@ describe('PUT /user', () => {
});
context('Default Appearance Preferences', () => {
let testCases = {
const testCases = {
shirt: 'yellow',
skin: 'ddc994',
'hair.color': 'blond',
@@ -160,14 +160,14 @@ describe('PUT /user', () => {
update[`preferences.${type}`] = item;
it(`updates user with ${type} that is a default`, async () => {
let dbUpdate = {};
const dbUpdate = {};
dbUpdate[`purchased.${type}.${item}`] = true;
await user.update(dbUpdate);
// Sanity checks to make sure user is not already equipped with item
expect(get(user.preferences, type)).to.not.eql(item);
let updatedUser = await user.put('/user', update);
const updatedUser = await user.put('/user', update);
expect(get(updatedUser.preferences, type)).to.eql(item);
});
@@ -189,7 +189,7 @@ describe('PUT /user', () => {
'preferences.hair.beard': 3,
});
let updatedUser = await user.put('/user', {
const updatedUser = await user.put('/user', {
'preferences.hair.beard': 0,
});
@@ -202,7 +202,7 @@ describe('PUT /user', () => {
'preferences.hair.mustache': 2,
});
let updatedUser = await user.put('/user', {
const updatedUser = await user.put('/user', {
'preferences.hair.mustache': 0,
});
@@ -211,7 +211,7 @@ describe('PUT /user', () => {
});
context('Purchasable Appearance Preferences', () => {
let testCases = {
const testCases = {
background: 'volcano',
shirt: 'convict',
skin: 'cactus',
@@ -229,19 +229,19 @@ describe('PUT /user', () => {
await expect(user.put('/user', update)).to.eventually.be.rejected.and.eql({
code: 401,
error: 'NotAuthorized',
message: t('mustPurchaseToSet', {val: item, key: `preferences.${type}`}),
message: t('mustPurchaseToSet', { val: item, key: `preferences.${type}` }),
});
});
it(`updates user with ${type} user does own`, async () => {
let dbUpdate = {};
const dbUpdate = {};
dbUpdate[`purchased.${type}.${item}`] = true;
await user.update(dbUpdate);
// Sanity check to make sure user is not already equipped with item
expect(get(user.preferences, type)).to.not.eql(item);
let updatedUser = await user.put('/user', update);
const updatedUser = await user.put('/user', update);
expect(get(updatedUser.preferences, type)).to.eql(item);
});