Reinstate error code in resolve promise for api tests.
This commit is contained in:
@@ -146,7 +146,10 @@ describe('GET /groups/:id', () => {
|
||||
it('does not return the group object for a non-member', () => {
|
||||
let api = requester(nonMember);
|
||||
return expect(api.get(`/groups/${createdGroup._id}`))
|
||||
.to.be.rejectedWith('Group not found or you don\'t have access.');
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'Group not found or you don\'t have access.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -173,7 +176,10 @@ describe('GET /groups/:id', () => {
|
||||
it('does not return the group object for a non-member', () => {
|
||||
let api = requester(nonMember);
|
||||
return expect(api.get(`/groups/${createdGroup._id}`))
|
||||
.to.be.rejectedWith('Group not found or you don\'t have access.');
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'Group not found or you don\'t have access.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -219,7 +225,10 @@ describe('GET /groups/:id', () => {
|
||||
it('returns error if group does not exist', () => {
|
||||
let api = requester(user);
|
||||
return expect(api.get('/groups/group-that-does-not-exist'))
|
||||
.to.be.rejectedWith('Group not found or you don\'t have access.');
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'Group not found or you don\'t have access.',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -80,14 +80,20 @@ describe('POST /groups', () => {
|
||||
return api.post('/groups', {
|
||||
type: 'party',
|
||||
});
|
||||
})).to.be.rejectedWith('Already in a party, try refreshing.');
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
text: 'Already in a party, try refreshing.',
|
||||
});
|
||||
})
|
||||
|
||||
xit('prevents creating a public party. TODO: it is possible to create a public party. Should we send back an error? Automatically switch the privacy to private?', () => {
|
||||
return expect(api.post('/groups', {
|
||||
type: 'party',
|
||||
privacy: 'public',
|
||||
})).to.be.rejectedWith('Parties must be private');
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
text: 'Parties must be private',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,7 +117,10 @@ describe('POST /groups', () => {
|
||||
return api.post('/groups', {
|
||||
type: 'guild',
|
||||
});
|
||||
})).to.be.rejectedWith('Not enough gems!');
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
text: 'Not enough gems!',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,10 @@ describe('POST /groups/:id', () => {
|
||||
it('does not allow user to update group', () => {
|
||||
return expect(api.post(`/groups/${groupUserDoesNotOwn._id}`, {
|
||||
name: 'Change'
|
||||
})).to.be.rejectedWith('Only the group leader can update the group!');
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
text: 'Only the group leader can update the group!',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -86,7 +86,10 @@ describe('POST /groups/:id/leave', () => {
|
||||
it('group is not accessible after leaving', () => {
|
||||
return expect(api.post(`/groups/${group._id}/leave`).then((result) => {
|
||||
return api.get(`/groups/${group._id}`);
|
||||
})).to.be.rejectedWith('Group not found or you don\'t have access.');
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'Group not found or you don\'t have access.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -38,7 +38,10 @@ describe('POST /groups/:id/removeMember', () => {
|
||||
it('does not allow leader to remove themselves', () => {
|
||||
return expect(api.post(`/groups/${group._id}/removeMember`, null, {
|
||||
uuid: leader._id,
|
||||
})).to.be.rejectedWith('You cannot remove yourself!');
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
text: 'You cannot remove yourself!',
|
||||
});
|
||||
});
|
||||
|
||||
it('can remove other members of guild', () => {
|
||||
|
||||
Reference in New Issue
Block a user