mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
tests(api): Convert groups tests to use user['HTTP_METHOD'] syntax
This commit is contained in:
@@ -1,17 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
generateUser,
|
generateUser,
|
||||||
generateGroup,
|
generateGroup,
|
||||||
requester,
|
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-integration.helper';
|
} from '../../../../helpers/api-integration.helper';
|
||||||
|
|
||||||
describe('GET /groups/:groupId/chat', () => {
|
describe('GET /groups/:groupId/chat', () => {
|
||||||
let user, api;
|
let user;
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
return generateUser().then((generatedUser) => {
|
return generateUser().then((generatedUser) => {
|
||||||
user = generatedUser;
|
user = generatedUser;
|
||||||
api = requester(user);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -38,7 +36,7 @@ describe('GET /groups/:groupId/chat', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns Guild chat', () => {
|
it('returns Guild chat', () => {
|
||||||
return api.get('/groups/' + group._id + '/chat')
|
return user.get('/groups/' + group._id + '/chat')
|
||||||
.then((getChat) => {
|
.then((getChat) => {
|
||||||
expect(getChat).to.eql(group.chat);
|
expect(getChat).to.eql(group.chat);
|
||||||
});
|
});
|
||||||
@@ -69,7 +67,7 @@ describe('GET /groups/:groupId/chat', () => {
|
|||||||
|
|
||||||
it('returns error if user is not member of requested private group', () => {
|
it('returns error if user is not member of requested private group', () => {
|
||||||
return expect(
|
return expect(
|
||||||
api.get('/groups/' + group._id + '/chat')
|
user.get('/groups/' + group._id + '/chat')
|
||||||
)
|
)
|
||||||
.to.eventually.be.rejected.and.eql({
|
.to.eventually.be.rejected.and.eql({
|
||||||
code: 404,
|
code: 404,
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
generateUser,
|
generateUser,
|
||||||
requester,
|
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-integration.helper';
|
} from '../../../../helpers/api-integration.helper';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
describe('POST /chat/:chatId/flag', () => {
|
describe('POST /chat/:chatId/flag', () => {
|
||||||
let user;
|
let user;
|
||||||
let api;
|
|
||||||
let group;
|
let group;
|
||||||
let testMessage = 'Test Message';
|
let testMessage = 'Test Message';
|
||||||
|
|
||||||
@@ -18,10 +16,9 @@ describe('POST /chat/:chatId/flag', () => {
|
|||||||
|
|
||||||
return generateUser({balance: 1}).then((generatedUser) => {
|
return generateUser({balance: 1}).then((generatedUser) => {
|
||||||
user = generatedUser;
|
user = generatedUser;
|
||||||
api = requester(user);
|
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return api.post('/groups', {
|
return user.post('/groups', {
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType,
|
type: groupType,
|
||||||
privacy: groupPrivacy,
|
privacy: groupPrivacy,
|
||||||
@@ -33,7 +30,7 @@ describe('POST /chat/:chatId/flag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Returns an error when chat message is not found', () => {
|
it('Returns an error when chat message is not found', () => {
|
||||||
return expect(api.post(`/groups/${group._id}/chat/incorrectMessage/flag`))
|
return expect(user.post(`/groups/${group._id}/chat/incorrectMessage/flag`))
|
||||||
.to.eventually.be.rejected.and.eql({
|
.to.eventually.be.rejected.and.eql({
|
||||||
code: 404,
|
code: 404,
|
||||||
error: 'NotFound',
|
error: 'NotFound',
|
||||||
@@ -42,9 +39,9 @@ describe('POST /chat/:chatId/flag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Returns an error when user tries to flag their own message', () => {
|
it('Returns an error when user tries to flag their own message', () => {
|
||||||
return api.post(`/groups/${group._id}/chat`, { message: testMessage})
|
return user.post(`/groups/${group._id}/chat`, { message: testMessage})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
return expect(api.post(`/groups/${group._id}/chat/${result.message.id}/flag`))
|
return expect(user.post(`/groups/${group._id}/chat/${result.message.id}/flag`))
|
||||||
.to.eventually.be.rejected.and.eql({
|
.to.eventually.be.rejected.and.eql({
|
||||||
code: 404,
|
code: 404,
|
||||||
error: 'NotFound',
|
error: 'NotFound',
|
||||||
@@ -54,21 +51,19 @@ describe('POST /chat/:chatId/flag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Flags a chat', () => {
|
it('Flags a chat', () => {
|
||||||
let api2;
|
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
return generateUser().then((generatedUser) => {
|
return generateUser().then((anotherUser) => {
|
||||||
api2 = requester(generatedUser);
|
return anotherUser.post(`/groups/${group._id}/chat`, { message: testMessage});
|
||||||
return api2.post(`/groups/${group._id}/chat`, { message: testMessage});
|
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
message = result.message;
|
message = result.message;
|
||||||
return api.post(`/groups/${group._id}/chat/${message.id}/flag`);
|
return user.post(`/groups/${group._id}/chat/${message.id}/flag`);
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
expect(result.flags[user._id]).to.equal(true);
|
expect(result.flags[user._id]).to.equal(true);
|
||||||
expect(result.flagCount).to.equal(1);
|
expect(result.flagCount).to.equal(1);
|
||||||
return api.get(`/groups/${group._id}`);
|
return user.get(`/groups/${group._id}`);
|
||||||
})
|
})
|
||||||
.then((updatedGroup) => {
|
.then((updatedGroup) => {
|
||||||
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
||||||
@@ -77,23 +72,21 @@ describe('POST /chat/:chatId/flag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Flags a chat with a higher flag acount when an admin flags the message', () => {
|
it('Flags a chat with a higher flag acount when an admin flags the message', () => {
|
||||||
let api2;
|
|
||||||
let secondUser;
|
let secondUser;
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
return generateUser({'contributor.admin': true}).then((generatedUser) => {
|
return generateUser({'contributor.admin': true}).then((generatedUser) => {
|
||||||
secondUser = generatedUser;
|
secondUser = generatedUser;
|
||||||
api2 = requester(generatedUser);
|
return user.post(`/groups/${group._id}/chat`, { message: testMessage});
|
||||||
return api.post(`/groups/${group._id}/chat`, { message: testMessage});
|
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
message = result.message;
|
message = result.message;
|
||||||
return api2.post(`/groups/${group._id}/chat/${message.id}/flag`);
|
return secondUser.post(`/groups/${group._id}/chat/${message.id}/flag`);
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
expect(result.flags[secondUser._id]).to.equal(true);
|
expect(result.flags[secondUser._id]).to.equal(true);
|
||||||
expect(result.flagCount).to.equal(5);
|
expect(result.flagCount).to.equal(5);
|
||||||
return api.get(`/groups/${group._id}`);
|
return user.get(`/groups/${group._id}`);
|
||||||
})
|
})
|
||||||
.then((updatedGroup) => {
|
.then((updatedGroup) => {
|
||||||
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
||||||
@@ -103,19 +96,17 @@ describe('POST /chat/:chatId/flag', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Returns an error when user tries to flag a message that is already flagged', () => {
|
it('Returns an error when user tries to flag a message that is already flagged', () => {
|
||||||
let api2;
|
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
return generateUser().then((generatedUser) => {
|
return generateUser().then((anotherUser) => {
|
||||||
api2 = requester(generatedUser);
|
return anotherUser.post(`/groups/${group._id}/chat`, { message: testMessage});
|
||||||
return api2.post(`/groups/${group._id}/chat`, { message: testMessage});
|
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
message = result.message;
|
message = result.message;
|
||||||
return api.post(`/groups/${group._id}/chat/${message.id}/flag`);
|
return user.post(`/groups/${group._id}/chat/${message.id}/flag`);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return expect(api.post(`/groups/${group._id}/chat/${message.id}/flag`))
|
return expect(user.post(`/groups/${group._id}/chat/${message.id}/flag`))
|
||||||
.to.eventually.be.rejected.and.eql({
|
.to.eventually.be.rejected.and.eql({
|
||||||
code: 404,
|
code: 404,
|
||||||
error: 'NotFound',
|
error: 'NotFound',
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
generateUser,
|
generateUser,
|
||||||
requester,
|
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-integration.helper';
|
} from '../../../../helpers/api-integration.helper';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
describe('POST /chat/:chatId/like', () => {
|
describe('POST /chat/:chatId/like', () => {
|
||||||
let user;
|
let user;
|
||||||
let api;
|
|
||||||
let group;
|
let group;
|
||||||
let testMessage = 'Test Message';
|
let testMessage = 'Test Message';
|
||||||
|
|
||||||
@@ -18,10 +16,9 @@ describe('POST /chat/:chatId/like', () => {
|
|||||||
|
|
||||||
return generateUser({balance: 1}).then((generatedUser) => {
|
return generateUser({balance: 1}).then((generatedUser) => {
|
||||||
user = generatedUser;
|
user = generatedUser;
|
||||||
api = requester(user);
|
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return api.post('/groups', {
|
return user.post('/groups', {
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType,
|
type: groupType,
|
||||||
privacy: groupPrivacy,
|
privacy: groupPrivacy,
|
||||||
@@ -33,7 +30,7 @@ describe('POST /chat/:chatId/like', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Returns an error when chat message is not found', () => {
|
it('Returns an error when chat message is not found', () => {
|
||||||
return expect(api.post(`/groups/${group._id}/chat/incorrectMessage/like`))
|
return expect(user.post(`/groups/${group._id}/chat/incorrectMessage/like`))
|
||||||
.to.eventually.be.rejected.and.eql({
|
.to.eventually.be.rejected.and.eql({
|
||||||
code: 404,
|
code: 404,
|
||||||
error: 'NotFound',
|
error: 'NotFound',
|
||||||
@@ -42,9 +39,9 @@ describe('POST /chat/:chatId/like', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Returns an error when user tries to like their own message', () => {
|
it('Returns an error when user tries to like their own message', () => {
|
||||||
return api.post(`/groups/${group._id}/chat`, { message: testMessage})
|
return user.post(`/groups/${group._id}/chat`, { message: testMessage})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
return expect(api.post(`/groups/${group._id}/chat/${result.message.id}/like`))
|
return expect(user.post(`/groups/${group._id}/chat/${result.message.id}/like`))
|
||||||
.to.eventually.be.rejected.and.eql({
|
.to.eventually.be.rejected.and.eql({
|
||||||
code: 404,
|
code: 404,
|
||||||
error: 'NotFound',
|
error: 'NotFound',
|
||||||
@@ -54,20 +51,18 @@ describe('POST /chat/:chatId/like', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Likes a chat', () => {
|
it('Likes a chat', () => {
|
||||||
let api2;
|
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
return generateUser().then((generatedUser) => {
|
return generateUser().then((anotherUser) => {
|
||||||
api2 = requester(generatedUser);
|
return anotherUser.post(`/groups/${group._id}/chat`, { message: testMessage});
|
||||||
return api2.post(`/groups/${group._id}/chat`, { message: testMessage});
|
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
message = result.message;
|
message = result.message;
|
||||||
return api.post(`/groups/${group._id}/chat/${message.id}/like`);
|
return user.post(`/groups/${group._id}/chat/${message.id}/like`);
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
expect(result.likes[user._id]).to.equal(true);
|
expect(result.likes[user._id]).to.equal(true);
|
||||||
return api.get(`/groups/${group._id}`);
|
return user.get(`/groups/${group._id}`);
|
||||||
})
|
})
|
||||||
.then((updatedGroup) => {
|
.then((updatedGroup) => {
|
||||||
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
||||||
@@ -76,24 +71,22 @@ describe('POST /chat/:chatId/like', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Unlikes a chat', () => {
|
it('Unlikes a chat', () => {
|
||||||
let api2;
|
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
return generateUser().then((generatedUser) => {
|
return generateUser().then((anotherUser) => {
|
||||||
api2 = requester(generatedUser);
|
return anotherUser.post(`/groups/${group._id}/chat`, { message: testMessage});
|
||||||
return api2.post(`/groups/${group._id}/chat`, { message: testMessage});
|
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
message = result.message;
|
message = result.message;
|
||||||
return api.post(`/groups/${group._id}/chat/${message.id}/like`);
|
return user.post(`/groups/${group._id}/chat/${message.id}/like`);
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
expect(result.likes[user._id]).to.equal(true);
|
expect(result.likes[user._id]).to.equal(true);
|
||||||
return api.post(`/groups/${group._id}/chat/${message.id}/like`);
|
return user.post(`/groups/${group._id}/chat/${message.id}/like`);
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
expect(result.likes[user._id]).to.equal(false);
|
expect(result.likes[user._id]).to.equal(false);
|
||||||
return api.get(`/groups/${group._id}`);
|
return user.get(`/groups/${group._id}`);
|
||||||
})
|
})
|
||||||
.then((updatedGroup) => {
|
.then((updatedGroup) => {
|
||||||
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
generateUser,
|
generateUser,
|
||||||
requester,
|
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-integration.helper';
|
} from '../../../../helpers/api-integration.helper';
|
||||||
|
|
||||||
describe('POST /chat', () => {
|
describe('POST /chat', () => {
|
||||||
let user;
|
let user;
|
||||||
let api;
|
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
return generateUser().then((generatedUser) => {
|
return generateUser().then((generatedUser) => {
|
||||||
user = generatedUser;
|
user = generatedUser;
|
||||||
api = requester(user);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -20,18 +17,16 @@ describe('POST /chat', () => {
|
|||||||
let groupType = 'guild';
|
let groupType = 'guild';
|
||||||
let groupPrivacy = 'public';
|
let groupPrivacy = 'public';
|
||||||
let testMessage = '';
|
let testMessage = '';
|
||||||
let api2;
|
|
||||||
|
|
||||||
return generateUser({balance: 1}).then((generatedUser) => {
|
return generateUser({balance: 1}).then((anotherUser) => {
|
||||||
api2 = requester(generatedUser);
|
return anotherUser.post('/groups', {
|
||||||
return api2.post('/groups', {
|
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType,
|
type: groupType,
|
||||||
privacy: groupPrivacy,
|
privacy: groupPrivacy,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then((group) => {
|
.then((group) => {
|
||||||
return expect(api.post(`/groups/${group._id}/chat`, { message: testMessage}))
|
return expect(user.post(`/groups/${group._id}/chat`, { message: testMessage}))
|
||||||
.to.eventually.be.rejected.and.eql({
|
.to.eventually.be.rejected.and.eql({
|
||||||
code: 400,
|
code: 400,
|
||||||
error: 'BadRequest',
|
error: 'BadRequest',
|
||||||
@@ -42,7 +37,7 @@ describe('POST /chat', () => {
|
|||||||
|
|
||||||
it('Returns an error when group is not found', () => {
|
it('Returns an error when group is not found', () => {
|
||||||
let testMessage = 'Test Message';
|
let testMessage = 'Test Message';
|
||||||
return expect(api.post('/groups/nvalidID/chat', { message: testMessage})).to.eventually.be.rejected.and.eql({
|
return expect(user.post('/groups/nvalidID/chat', { message: testMessage})).to.eventually.be.rejected.and.eql({
|
||||||
code: 404,
|
code: 404,
|
||||||
error: 'NotFound',
|
error: 'NotFound',
|
||||||
message: t('groupNotFound'),
|
message: t('groupNotFound'),
|
||||||
@@ -54,18 +49,19 @@ describe('POST /chat', () => {
|
|||||||
let groupType = 'guild';
|
let groupType = 'guild';
|
||||||
let groupPrivacy = 'public';
|
let groupPrivacy = 'public';
|
||||||
let testMessage = 'Test Message';
|
let testMessage = 'Test Message';
|
||||||
let api2;
|
let userWithoutChat;
|
||||||
|
|
||||||
return generateUser({balance: 1, 'flags.chatRevoked': true}).then((generatedUser) => {
|
return generateUser({balance: 1, 'flags.chatRevoked': true}).then((generatedUser) => {
|
||||||
api2 = requester(generatedUser);
|
userWithoutChat = generatedUser;
|
||||||
return api2.post('/groups', {
|
|
||||||
|
return userWithoutChat.post('/groups', {
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType,
|
type: groupType,
|
||||||
privacy: groupPrivacy,
|
privacy: groupPrivacy,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then((group) => {
|
.then((group) => {
|
||||||
return expect(api2.post(`/groups/${group._id}/chat`, { message: testMessage})).to.eventually.be.rejected.and.eql({
|
return expect(userWithoutChat.post(`/groups/${group._id}/chat`, { message: testMessage})).to.eventually.be.rejected.and.eql({
|
||||||
code: 404,
|
code: 404,
|
||||||
error: 'NotFound',
|
error: 'NotFound',
|
||||||
message: 'Your chat privileges have been revoked.',
|
message: 'Your chat privileges have been revoked.',
|
||||||
@@ -78,18 +74,19 @@ describe('POST /chat', () => {
|
|||||||
let groupType = 'guild';
|
let groupType = 'guild';
|
||||||
let groupPrivacy = 'public';
|
let groupPrivacy = 'public';
|
||||||
let testMessage = 'Test Message';
|
let testMessage = 'Test Message';
|
||||||
let api2;
|
let anotherUser;
|
||||||
|
|
||||||
return generateUser({balance: 1}).then((generatedUser) => {
|
return generateUser({balance: 1}).then((generatedUser) => {
|
||||||
api2 = requester(generatedUser);
|
anotherUser = generatedUser;
|
||||||
return api2.post('/groups', {
|
|
||||||
|
return anotherUser.post('/groups', {
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType,
|
type: groupType,
|
||||||
privacy: groupPrivacy,
|
privacy: groupPrivacy,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then((group) => {
|
.then((group) => {
|
||||||
return api2.post(`/groups/${group._id}/chat`, { message: testMessage});
|
return anotherUser.post(`/groups/${group._id}/chat`, { message: testMessage});
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
expect(result.message.id).to.exist;
|
expect(result.message.id).to.exist;
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
generateUser,
|
generateUser,
|
||||||
requester,
|
|
||||||
translate as t,
|
translate as t,
|
||||||
} from '../../../../helpers/api-integration.helper';
|
} from '../../../../helpers/api-integration.helper';
|
||||||
|
|
||||||
describe('POST /group', () => {
|
describe('POST /group', () => {
|
||||||
let user, api;
|
let user;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
return generateUser().then((generatedUser) => {
|
return generateUser().then((generatedUser) => {
|
||||||
user = generatedUser;
|
user = generatedUser;
|
||||||
api = requester(user);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -20,7 +18,7 @@ describe('POST /group', () => {
|
|||||||
let groupType = 'guild';
|
let groupType = 'guild';
|
||||||
|
|
||||||
return expect(
|
return expect(
|
||||||
api.post('/groups', {
|
user.post('/groups', {
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType
|
type: groupType
|
||||||
})
|
})
|
||||||
@@ -38,8 +36,7 @@ describe('POST /group', () => {
|
|||||||
let groupType = 'guild';
|
let groupType = 'guild';
|
||||||
|
|
||||||
return generateUser({balance: 1}).then((generatedUser) => {
|
return generateUser({balance: 1}).then((generatedUser) => {
|
||||||
let api2 = requester(generatedUser);
|
return generatedUser.post('/groups', {
|
||||||
return api2.post('/groups', {
|
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType
|
type: groupType
|
||||||
});
|
});
|
||||||
@@ -60,8 +57,7 @@ describe('POST /group', () => {
|
|||||||
let tmpUser;
|
let tmpUser;
|
||||||
|
|
||||||
return generateUser({balance: 1}).then((generatedUser) => {
|
return generateUser({balance: 1}).then((generatedUser) => {
|
||||||
let api2 = requester(generatedUser);
|
return generatedUser.post('/groups', {
|
||||||
return api2.post('/groups', {
|
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType,
|
type: groupType,
|
||||||
privacy: groupPrivacy
|
privacy: groupPrivacy
|
||||||
@@ -82,7 +78,7 @@ describe('POST /group', () => {
|
|||||||
let groupName = "Test Party";
|
let groupName = "Test Party";
|
||||||
let groupType = "party";
|
let groupType = "party";
|
||||||
|
|
||||||
return api.post('/groups', {
|
return user.post('/groups', {
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType
|
type: groupType
|
||||||
})
|
})
|
||||||
@@ -93,28 +89,24 @@ describe('POST /group', () => {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prevents user in a party from creating a party', () => {
|
it('prevents user in a party from creating another party', () => {
|
||||||
let tmpUser;
|
let tmpUser;
|
||||||
let groupName = "Test Party";
|
let groupName = "Test Party";
|
||||||
let groupType = "party";
|
let groupType = "party";
|
||||||
|
|
||||||
return generateUser().then((generatedUser) => {
|
return generateUser().then((generatedUser) => {
|
||||||
tmpUser = generatedUser;
|
tmpUser = generatedUser;
|
||||||
api = requester(tmpUser);
|
return tmpUser.post('/groups', {
|
||||||
return api.post('/groups', {
|
|
||||||
name: groupName,
|
name: groupName,
|
||||||
type: groupType
|
type: groupType
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return expect(api.post('/groups')).to.eventually.be.rejected.and.eql({
|
return expect(tmpUser.post('/groups')).to.eventually.be.rejected.and.eql({
|
||||||
code: 401,
|
code: 401,
|
||||||
error: 'NotAuthorized',
|
error: 'NotAuthorized',
|
||||||
message: t('messageGroupAlreadyInParty'),
|
message: t('messageGroupAlreadyInParty'),
|
||||||
});
|
});
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
api = requester(user);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user