Move generators to own file
This commit is contained in:
@@ -14,7 +14,7 @@ describe('DELETE /groups/:id/chat', () => {
|
||||
},
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
|
||||
return user.post(`/groups/${group._id}/chat`, null, { message: 'Some message' });
|
||||
}).then((res) => {
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('GET /groups/:id/chat', () => {
|
||||
});
|
||||
|
||||
group = groupData.group;
|
||||
user = groupData.leader;
|
||||
user = groupData.groupLeader;
|
||||
member = groupData.members[0];
|
||||
|
||||
await member.post(`/groups/${group._id}/chat`, null, { message: 'Group member message' });
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('POST /groups/:id/chat', () => {
|
||||
},
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -5,24 +5,23 @@ import {
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
describe('POST /groups/:id/chat/:id/clearflags', () => {
|
||||
let group;
|
||||
let guild;
|
||||
|
||||
beforeEach(async () => {
|
||||
return createAndPopulateGroup({
|
||||
let { group } = await createAndPopulateGroup({
|
||||
groupDetails: {
|
||||
type: 'guild',
|
||||
privacy: 'public',
|
||||
members: 1,
|
||||
flagCount: 1,
|
||||
chat: [{
|
||||
id: 'message-to-clear',
|
||||
flagCount: 1,
|
||||
flags: { 'some-id': true },
|
||||
}],
|
||||
},
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
});
|
||||
|
||||
guild = group;
|
||||
});
|
||||
|
||||
context('non admin', () => {
|
||||
@@ -33,7 +32,7 @@ describe('POST /groups/:id/chat/:id/clearflags', () => {
|
||||
});
|
||||
|
||||
it('cannot clear flags', async () => {
|
||||
return expect(nonadmin.post(`/groups/${group._id}/chat/message-to-clear/clearflags`))
|
||||
return expect(nonadmin.post(`/groups/${guild._id}/chat/message-to-clear/clearflags`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
text: t('messageGroupChatAdminClearFlagCount'),
|
||||
@@ -53,23 +52,23 @@ describe('POST /groups/:id/chat/:id/clearflags', () => {
|
||||
});
|
||||
|
||||
it('clears flags', async () => {
|
||||
return admin.post(`/groups/${group._id}/chat/message-to-clear/clearflags`).then(() => {
|
||||
return admin.get(`/groups/${group._id}/chat`);
|
||||
return admin.post(`/groups/${guild._id}/chat/message-to-clear/clearflags`).then(() => {
|
||||
return admin.get(`/groups/${guild._id}/chat`);
|
||||
}).then((messages) => {
|
||||
expect(messages[0].flagCount).to.eql(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('leaves old flags on the flag object', async () => {
|
||||
return admin.post(`/groups/${group._id}/chat/message-to-clear/clearflags`).then(() => {
|
||||
return admin.get(`/groups/${group._id}/chat`);
|
||||
return admin.post(`/groups/${guild._id}/chat/message-to-clear/clearflags`).then(() => {
|
||||
return admin.get(`/groups/${guild._id}/chat`);
|
||||
}).then((messages) => {
|
||||
expect(messages[0].flags).to.have.property('some-id', true);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns error if message does not exist', async () => {
|
||||
return expect(admin.post(`/groups/${group._id}/chat/non-existant-message/clearflags`))
|
||||
return expect(admin.post(`/groups/${guild._id}/chat/non-existant-message/clearflags`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: t('messageGroupChatNotFound'),
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('POST /groups/:id/chat/:id/flag', () => {
|
||||
members: 1,
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
member = res.members[0];
|
||||
|
||||
return member.post(`/groups/${group._id}/chat`, null, { message: 'Group member message' });
|
||||
@@ -56,7 +56,7 @@ describe('POST /groups/:id/chat/:id/flag', () => {
|
||||
},
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
|
||||
return user.post(`/groups/${group._id}/chat`, null, { message: 'User\'s own message' });
|
||||
}).then((res) => {
|
||||
@@ -84,7 +84,7 @@ describe('POST /groups/:id/chat/:id/flag', () => {
|
||||
},
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,7 +121,7 @@ describe('POST /groups/:id/chat/:id/flag', () => {
|
||||
});
|
||||
|
||||
group = groupData.group;
|
||||
user = groupData.leader;
|
||||
user = groupData.groupLeader;
|
||||
});
|
||||
|
||||
it('changes only the message that is flagged', async () => {
|
||||
@@ -166,7 +166,7 @@ describe('POST /groups/:id/chat/:id/flag', () => {
|
||||
members: 1,
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
member = res.members[0];
|
||||
|
||||
return member.post(`/groups/${group._id}/chat`, null, { message: 'Group member message' });
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('POST /groups/:id/chat/:id/like', () => {
|
||||
members: 1,
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
member = res.members[0];
|
||||
|
||||
return member.post(`/groups/${group._id}/chat`, null, { message: 'Group member message' });
|
||||
@@ -53,7 +53,7 @@ describe('POST /groups/:id/chat/:id/like', () => {
|
||||
},
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
|
||||
return user.post(`/groups/${group._id}/chat`, null, { message: 'User\'s own message' });
|
||||
}).then((res) => {
|
||||
@@ -94,7 +94,7 @@ describe('POST /groups/:id/chat/:id/like', () => {
|
||||
});
|
||||
|
||||
group = groupData.group;
|
||||
user = groupData.leader;
|
||||
user = groupData.groupLeader;
|
||||
});
|
||||
|
||||
it('changes only the message that is liked', async () => {
|
||||
@@ -134,7 +134,7 @@ describe('POST /groups/:id/chat/:id/like', () => {
|
||||
},
|
||||
}).then((res) => {
|
||||
group = res.group;
|
||||
user = res.leader;
|
||||
user = res.groupLeader;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user