fix(tests): correct expects

This commit is contained in:
SabreCat
2018-11-14 13:07:44 +00:00
committed by Phillip Thelen
parent 577ff4cab9
commit dd2c2f62b8
10 changed files with 262 additions and 14 deletions

View File

@@ -47,6 +47,14 @@ describe('GET /challenges/:challengeId', () => {
_id: groupLeader._id, _id: groupLeader._id,
id: groupLeader._id, id: groupLeader._id,
profile: {name: groupLeader.profile.name}, profile: {name: groupLeader.profile.name},
auth: {
local: {
username: groupLeader.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(chal.group).to.eql({ expect(chal.group).to.eql({
_id: group._id, _id: group._id,
@@ -105,6 +113,14 @@ describe('GET /challenges/:challengeId', () => {
_id: challengeLeader._id, _id: challengeLeader._id,
id: challengeLeader._id, id: challengeLeader._id,
profile: {name: challengeLeader.profile.name}, profile: {name: challengeLeader.profile.name},
auth: {
local: {
username: challengeLeader.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(chal.group).to.eql({ expect(chal.group).to.eql({
_id: group._id, _id: group._id,
@@ -131,6 +147,14 @@ describe('GET /challenges/:challengeId', () => {
_id: challengeLeader._id, _id: challengeLeader._id,
id: challengeLeader._id, id: challengeLeader._id,
profile: {name: challengeLeader.profile.name}, profile: {name: challengeLeader.profile.name},
auth: {
local: {
username: challengeLeader.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
}); });
@@ -179,6 +203,14 @@ describe('GET /challenges/:challengeId', () => {
_id: challengeLeader._id, _id: challengeLeader._id,
id: challengeLeader._id, id: challengeLeader._id,
profile: {name: challengeLeader.profile.name}, profile: {name: challengeLeader.profile.name},
auth: {
local: {
username: challengeLeader.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(chal.group).to.eql({ expect(chal.group).to.eql({
_id: group._id, _id: group._id,
@@ -205,6 +237,14 @@ describe('GET /challenges/:challengeId', () => {
_id: challengeLeader._id, _id: challengeLeader._id,
id: challengeLeader._id, id: challengeLeader._id,
profile: {name: challengeLeader.profile.name}, profile: {name: challengeLeader.profile.name},
auth: {
local: {
username: challengeLeader.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
}); });

View File

@@ -60,6 +60,14 @@ describe('GET /challenges/:challengeId/members', () => {
_id: groupLeader._id, _id: groupLeader._id,
id: groupLeader._id, id: groupLeader._id,
profile: {name: groupLeader.profile.name}, profile: {name: groupLeader.profile.name},
auth: {
local: {
username: groupLeader.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
@@ -73,8 +81,16 @@ describe('GET /challenges/:challengeId/members', () => {
_id: leader._id, _id: leader._id,
id: leader._id, id: leader._id,
profile: {name: leader.profile.name}, profile: {name: leader.profile.name},
auth: {
local: {
username: leader.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']); expect(res[0]).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(res[0].profile).to.have.all.keys(['name']); expect(res[0].profile).to.have.all.keys(['name']);
}); });
@@ -88,8 +104,16 @@ describe('GET /challenges/:challengeId/members', () => {
_id: anotherUser._id, _id: anotherUser._id,
id: anotherUser._id, id: anotherUser._id,
profile: {name: anotherUser.profile.name}, profile: {name: anotherUser.profile.name},
auth: {
local: {
username: anotherUser.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']); expect(res[0]).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(res[0].profile).to.have.all.keys(['name']); expect(res[0].profile).to.have.all.keys(['name']);
}); });
@@ -107,7 +131,7 @@ describe('GET /challenges/:challengeId/members', () => {
let res = await user.get(`/challenges/${challenge._id}/members?includeAllMembers=not-true`); let res = await user.get(`/challenges/${challenge._id}/members?includeAllMembers=not-true`);
expect(res.length).to.equal(30); expect(res.length).to.equal(30);
res.forEach(member => { res.forEach(member => {
expect(member).to.have.all.keys(['_id', 'id', 'profile']); expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(member.profile).to.have.all.keys(['name']); expect(member.profile).to.have.all.keys(['name']);
}); });
}); });
@@ -126,7 +150,7 @@ describe('GET /challenges/:challengeId/members', () => {
let res = await user.get(`/challenges/${challenge._id}/members`); let res = await user.get(`/challenges/${challenge._id}/members`);
expect(res.length).to.equal(30); expect(res.length).to.equal(30);
res.forEach(member => { res.forEach(member => {
expect(member).to.have.all.keys(['_id', 'id', 'profile']); expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(member.profile).to.have.all.keys(['name']); expect(member.profile).to.have.all.keys(['name']);
}); });
}); });
@@ -145,7 +169,7 @@ describe('GET /challenges/:challengeId/members', () => {
let res = await user.get(`/challenges/${challenge._id}/members?includeAllMembers=true`); let res = await user.get(`/challenges/${challenge._id}/members?includeAllMembers=true`);
expect(res.length).to.equal(32); expect(res.length).to.equal(32);
res.forEach(member => { res.forEach(member => {
expect(member).to.have.all.keys(['_id', 'id', 'profile']); expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(member.profile).to.have.all.keys(['name']); expect(member.profile).to.have.all.keys(['name']);
}); });
}); });

View File

@@ -39,6 +39,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist; expect(foundChallenge2).to.exist;
@@ -46,6 +54,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
@@ -58,6 +74,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist; expect(foundChallenge2).to.exist;
@@ -65,6 +89,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
@@ -125,6 +157,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: privateGuild.leader._id, _id: privateGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist; expect(foundChallenge2).to.exist;
@@ -132,6 +172,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: privateGuild.leader._id, _id: privateGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
}); });
@@ -235,6 +283,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: party.leader._id, _id: party.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist; expect(foundChallenge2).to.exist;
@@ -242,6 +298,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: party.leader._id, _id: party.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
@@ -254,6 +318,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: party.leader._id, _id: party.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist; expect(foundChallenge2).to.exist;
@@ -261,6 +333,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: party.leader._id, _id: party.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
}); });
@@ -288,6 +368,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: user._id, _id: user._id,
id: user._id, id: user._id,
profile: {name: user.profile.name}, profile: {name: user.profile.name},
auth: {
local: {
username: user.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist; expect(foundChallenge2).to.exist;
@@ -295,6 +383,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: user._id, _id: user._id,
id: user._id, id: user._id,
profile: {name: user.profile.name}, profile: {name: user.profile.name},
auth: {
local: {
username: user.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
@@ -307,6 +403,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: user._id, _id: user._id,
id: user._id, id: user._id,
profile: {name: user.profile.name}, profile: {name: user.profile.name},
auth: {
local: {
username: user.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
let foundChallenge2 = _.find(challenges, { _id: challenge2._id }); let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist; expect(foundChallenge2).to.exist;
@@ -314,6 +418,14 @@ describe('GET challenges/groups/:groupId', () => {
_id: user._id, _id: user._id,
id: user._id, id: user._id,
profile: {name: user.profile.name}, profile: {name: user.profile.name},
auth: {
local: {
username: user.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
}); });

View File

@@ -40,6 +40,14 @@ describe('GET challenges/user', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(foundChallenge.group).to.eql({ expect(foundChallenge.group).to.eql({
_id: publicGuild._id, _id: publicGuild._id,
@@ -62,6 +70,14 @@ describe('GET challenges/user', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(foundChallenge1.group).to.eql({ expect(foundChallenge1.group).to.eql({
_id: publicGuild._id, _id: publicGuild._id,
@@ -79,6 +95,14 @@ describe('GET challenges/user', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(foundChallenge2.group).to.eql({ expect(foundChallenge2.group).to.eql({
_id: publicGuild._id, _id: publicGuild._id,
@@ -101,6 +125,14 @@ describe('GET challenges/user', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(foundChallenge1.group).to.eql({ expect(foundChallenge1.group).to.eql({
_id: publicGuild._id, _id: publicGuild._id,
@@ -118,6 +150,14 @@ describe('GET challenges/user', () => {
_id: publicGuild.leader._id, _id: publicGuild.leader._id,
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,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(foundChallenge2.group).to.eql({ expect(foundChallenge2.group).to.eql({
_id: publicGuild._id, _id: publicGuild._id,

View File

@@ -79,6 +79,14 @@ describe('POST /challenges/:challengeId/join', () => {
_id: groupLeader._id, _id: groupLeader._id,
id: groupLeader._id, id: groupLeader._id,
profile: {name: groupLeader.profile.name}, profile: {name: groupLeader.profile.name},
auth: {
local: {
username: groupLeader.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(res.name).to.equal(challenge.name); expect(res.name).to.equal(challenge.name);
}); });

View File

@@ -79,6 +79,14 @@ describe('PUT /challenges/:challengeId', () => {
_id: member._id, _id: member._id,
id: member._id, id: member._id,
profile: {name: member.profile.name}, profile: {name: member.profile.name},
auth: {
local: {
username: member.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
expect(res.name).to.equal('New Challenge Name'); expect(res.name).to.equal('New Challenge Name');
expect(res.description).to.equal('New challenge description.'); expect(res.description).to.equal('New challenge description.');

View File

@@ -50,6 +50,14 @@ describe('GET /groups/:groupId/invites', () => {
_id: invited._id, _id: invited._id,
id: invited._id, id: invited._id,
profile: {name: invited.profile.name}, profile: {name: invited.profile.name},
auth: {
local: {
username: invited.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
@@ -58,7 +66,7 @@ describe('GET /groups/:groupId/invites', () => {
let invited = await generateUser(); let invited = await generateUser();
await user.post(`/groups/${group._id}/invite`, {uuids: [invited._id]}); await user.post(`/groups/${group._id}/invite`, {uuids: [invited._id]});
let res = await user.get('/groups/party/invites'); let res = await user.get('/groups/party/invites');
expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']); expect(res[0]).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(res[0].profile).to.have.all.keys(['name']); expect(res[0].profile).to.have.all.keys(['name']);
}); });
@@ -76,7 +84,7 @@ describe('GET /groups/:groupId/invites', () => {
let res = await leader.get(`/groups/${group._id}/invites`); let res = await leader.get(`/groups/${group._id}/invites`);
expect(res.length).to.equal(30); expect(res.length).to.equal(30);
res.forEach(member => { res.forEach(member => {
expect(member).to.have.all.keys(['_id', 'id', 'profile']); expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(member.profile).to.have.all.keys(['name']); expect(member.profile).to.have.all.keys(['name']);
}); });
}).timeout(10000); }).timeout(10000);

View File

@@ -56,13 +56,21 @@ describe('GET /groups/:groupId/members', () => {
_id: user._id, _id: user._id,
id: user._id, id: user._id,
profile: {name: user.profile.name}, profile: {name: user.profile.name},
auth: {
local: {
username: user.auth.local.username,
}
},
flags: {
verifiedUsername: true,
},
}); });
}); });
it('populates only some fields', async () => { it('populates only some fields', async () => {
await generateGroup(user, {type: 'party', name: generateUUID()}); await generateGroup(user, {type: 'party', name: generateUUID()});
let res = await user.get('/groups/party/members'); let res = await user.get('/groups/party/members');
expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']); expect(res[0]).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(res[0].profile).to.have.all.keys(['name']); expect(res[0].profile).to.have.all.keys(['name']);
}); });
@@ -74,7 +82,7 @@ describe('GET /groups/:groupId/members', () => {
'_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party', '_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party',
'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags', 'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags',
]); ]);
expect(Object.keys(memberRes.auth)).to.eql(['timestamps']); expect(Object.keys(memberRes.auth)).to.eql(['local', 'timestamps']);
expect(Object.keys(memberRes.preferences).sort()).to.eql([ expect(Object.keys(memberRes.preferences).sort()).to.eql([
'size', 'hair', 'skin', 'shirt', 'size', 'hair', 'skin', 'shirt',
'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses', 'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses',
@@ -95,7 +103,7 @@ describe('GET /groups/:groupId/members', () => {
'_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party', '_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party',
'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags', 'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags',
]); ]);
expect(Object.keys(memberRes.auth)).to.eql(['timestamps']); expect(Object.keys(memberRes.auth)).to.eql(['local', 'timestamps']);
expect(Object.keys(memberRes.preferences).sort()).to.eql([ expect(Object.keys(memberRes.preferences).sort()).to.eql([
'size', 'hair', 'skin', 'shirt', 'size', 'hair', 'skin', 'shirt',
'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses', 'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses',
@@ -120,7 +128,7 @@ describe('GET /groups/:groupId/members', () => {
let res = await user.get('/groups/party/members'); let res = await user.get('/groups/party/members');
expect(res.length).to.equal(30); expect(res.length).to.equal(30);
res.forEach(member => { res.forEach(member => {
expect(member).to.have.all.keys(['_id', 'id', 'profile']); expect(member).to.have.all.keys(['_id', 'auth', 'flags', 'id', 'profile']);
expect(member.profile).to.have.all.keys(['name']); expect(member.profile).to.have.all.keys(['name']);
}); });
}); });

View File

@@ -160,7 +160,7 @@ describe('Post /groups/:groupId/invite', () => {
.to.eventually.be.rejected.and.eql({ .to.eventually.be.rejected.and.eql({
code: 400, code: 400,
error: 'BadRequest', error: 'BadRequest',
message: t('inviteMissingUuid'), message: t('inviteMustNotBeEmpty'),
}); });
}); });
@@ -295,7 +295,7 @@ describe('Post /groups/:groupId/invite', () => {
.to.eventually.be.rejected.and.eql({ .to.eventually.be.rejected.and.eql({
code: 400, code: 400,
error: 'BadRequest', error: 'BadRequest',
message: t('inviteMissingEmail'), message: t('inviteMustNotBeEmpty'),
}); });
}); });

View File

@@ -34,7 +34,7 @@ describe('GET /members/:memberId', () => {
'_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party', '_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party',
'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags', 'backer', 'contributor', 'auth', 'items', 'inbox', 'loginIncentives', 'flags',
]); ]);
expect(Object.keys(memberRes.auth)).to.eql(['timestamps']); expect(Object.keys(memberRes.auth)).to.eql(['local', 'timestamps']);
expect(Object.keys(memberRes.preferences).sort()).to.eql([ expect(Object.keys(memberRes.preferences).sort()).to.eql([
'size', 'hair', 'skin', 'shirt', 'size', 'hair', 'skin', 'shirt',
'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses', 'chair', 'costume', 'sleep', 'background', 'tasks', 'disableClasses',