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

@@ -8,10 +8,11 @@ import { TAVERN_ID } from '../../../../../website/common/script/constants';
describe('GET challenges/groups/:groupId', () => {
context('Public Guild', () => {
let publicGuild, user, nonMember, challenge, challenge2;
let publicGuild; let user; let nonMember; let challenge; let
challenge2;
before(async () => {
let { group, groupLeader } = await createAndPopulateGroup({
const { group, groupLeader } = await createAndPopulateGroup({
groupDetails: {
name: 'TestGuild',
type: 'guild',
@@ -31,14 +32,14 @@ describe('GET challenges/groups/:groupId', () => {
});
it('should return group challenges for non member with populated leader', async () => {
let challenges = await nonMember.get(`/challenges/groups/${publicGuild._id}`);
const challenges = await nonMember.get(`/challenges/groups/${publicGuild._id}`);
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
const foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -48,12 +49,12 @@ describe('GET challenges/groups/:groupId', () => {
verifiedUsername: true,
},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
const foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -66,14 +67,14 @@ describe('GET challenges/groups/:groupId', () => {
});
it('should return group challenges for member with populated leader', async () => {
let challenges = await user.get(`/challenges/groups/${publicGuild._id}`);
const challenges = await user.get(`/challenges/groups/${publicGuild._id}`);
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
const foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -83,12 +84,12 @@ describe('GET challenges/groups/:groupId', () => {
verifiedUsername: true,
},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
const foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -106,7 +107,7 @@ describe('GET challenges/groups/:groupId', () => {
let foundChallengeIndex = _.findIndex(challenges, { _id: challenge2._id });
expect(foundChallengeIndex).to.eql(0);
let newChallenge = await generateChallenge(user, publicGuild);
const newChallenge = await generateChallenge(user, publicGuild);
await user.post(`/challenges/${newChallenge._id}/join`);
challenges = await user.get(`/challenges/groups/${publicGuild._id}`);
@@ -117,10 +118,11 @@ describe('GET challenges/groups/:groupId', () => {
});
context('Private Guild', () => {
let privateGuild, user, nonMember, challenge, challenge2;
let privateGuild; let user; let nonMember; let challenge; let
challenge2;
before(async () => {
let { group, groupLeader } = await createAndPopulateGroup({
const { group, groupLeader } = await createAndPopulateGroup({
groupDetails: {
name: 'TestPrivateGuild',
type: 'guild',
@@ -149,14 +151,14 @@ describe('GET challenges/groups/:groupId', () => {
});
it('should return group challenges for member with populated leader', async () => {
let challenges = await user.get(`/challenges/groups/${privateGuild._id}`);
const challenges = await user.get(`/challenges/groups/${privateGuild._id}`);
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
const foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: privateGuild.leader._id,
id: privateGuild.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -166,12 +168,12 @@ describe('GET challenges/groups/:groupId', () => {
verifiedUsername: true,
},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
const foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: privateGuild.leader._id,
id: privateGuild.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -185,10 +187,11 @@ describe('GET challenges/groups/:groupId', () => {
});
context('official challenge is present', () => {
let publicGuild, user, officialChallenge, challenge, challenge2;
let publicGuild; let user; let officialChallenge; let challenge; let
challenge2;
before(async () => {
let { group, groupLeader } = await createAndPopulateGroup({
const { group, groupLeader } = await createAndPopulateGroup({
groupDetails: {
name: 'TestGuild',
type: 'guild',
@@ -218,9 +221,9 @@ describe('GET challenges/groups/:groupId', () => {
});
it('should return official challenges first', async () => {
let challenges = await user.get(`/challenges/groups/${publicGuild._id}`);
const challenges = await user.get(`/challenges/groups/${publicGuild._id}`);
let foundChallengeIndex = _.findIndex(challenges, { _id: officialChallenge._id });
const foundChallengeIndex = _.findIndex(challenges, { _id: officialChallenge._id });
expect(foundChallengeIndex).to.eql(0);
});
@@ -233,7 +236,7 @@ describe('GET challenges/groups/:groupId', () => {
foundChallengeIndex = _.findIndex(challenges, { _id: challenge2._id });
expect(foundChallengeIndex).to.eql(1);
let newChallenge = await generateChallenge(user, publicGuild);
const newChallenge = await generateChallenge(user, publicGuild);
await user.post(`/challenges/${newChallenge._id}/join`);
challenges = await user.get(`/challenges/groups/${publicGuild._id}`);
@@ -244,10 +247,11 @@ describe('GET challenges/groups/:groupId', () => {
});
context('Party', () => {
let party, user, nonMember, challenge, challenge2;
let party; let user; let nonMember; let challenge; let
challenge2;
before(async () => {
let { group, groupLeader } = await createAndPopulateGroup({
const { group, groupLeader } = await createAndPopulateGroup({
groupDetails: {
name: 'TestParty',
type: 'party',
@@ -275,14 +279,14 @@ describe('GET challenges/groups/:groupId', () => {
});
it('should return group challenges for member with populated leader', async () => {
let challenges = await user.get(`/challenges/groups/${party._id}`);
const challenges = await user.get(`/challenges/groups/${party._id}`);
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
const foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: party.leader._id,
id: party.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -292,12 +296,12 @@ describe('GET challenges/groups/:groupId', () => {
verifiedUsername: true,
},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
const foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: party.leader._id,
id: party.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -310,14 +314,14 @@ describe('GET challenges/groups/:groupId', () => {
});
it('should return group challenges for member using ID "party"', async () => {
let challenges = await user.get('/challenges/groups/party');
const challenges = await user.get('/challenges/groups/party');
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
const foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: party.leader._id,
id: party.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -327,12 +331,12 @@ describe('GET challenges/groups/:groupId', () => {
verifiedUsername: true,
},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
const foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: party.leader._id,
id: party.leader._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -346,28 +350,29 @@ describe('GET challenges/groups/:groupId', () => {
});
context('Tavern', () => {
let tavern, user, challenge, challenge2;
let tavern; let user; let challenge; let
challenge2;
before(async () => {
user = await generateUser();
await user.update({balance: 0.5});
await user.update({ balance: 0.5 });
tavern = await user.get(`/groups/${TAVERN_ID}`);
challenge = await generateChallenge(user, tavern, {prize: 1});
challenge = await generateChallenge(user, tavern, { prize: 1 });
await user.post(`/challenges/${challenge._id}/join`);
challenge2 = await generateChallenge(user, tavern, {prize: 1});
challenge2 = await generateChallenge(user, tavern, { prize: 1 });
await user.post(`/challenges/${challenge2._id}/join`);
});
it('should return tavern challenges with populated leader', async () => {
let challenges = await user.get(`/challenges/groups/${TAVERN_ID}`);
const challenges = await user.get(`/challenges/groups/${TAVERN_ID}`);
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
const foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: user._id,
id: user._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -377,12 +382,12 @@ describe('GET challenges/groups/:groupId', () => {
verifiedUsername: true,
},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
const foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: user._id,
id: user._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -395,14 +400,14 @@ describe('GET challenges/groups/:groupId', () => {
});
it('should return tavern challenges using ID "habitrpg', async () => {
let challenges = await user.get('/challenges/groups/habitrpg');
const challenges = await user.get('/challenges/groups/habitrpg');
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
const foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: user._id,
id: user._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,
@@ -412,12 +417,12 @@ describe('GET challenges/groups/:groupId', () => {
verifiedUsername: true,
},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
const foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: user._id,
id: user._id,
profile: {name: user.profile.name},
profile: { name: user.profile.name },
auth: {
local: {
username: user.auth.local.username,