added support for configuring limiting, action optims

This commit is contained in:
Wyatt Johnson
2018-02-13 17:24:57 -07:00
parent 74a2ed4a41
commit 73034a20f0
11 changed files with 180 additions and 206 deletions
-63
View File
@@ -151,67 +151,4 @@ describe('services.ActionsService', () => {
);
});
});
describe('#getActionSummaries()', () => {
it('should return properly formatted summaries from an array of item_ids', () => {
return ActionsService.getActionSummaries([comment.id, '789']).then(
summaries => {
expect(summaries).to.have.length(2);
expect(summaries).to.deep.include({
action_type: 'LIKE',
count: 1,
item_id: comment.id,
item_type: 'COMMENTS',
current_user: null,
});
expect(summaries).to.deep.include({
action_type: 'FLAG',
count: 2,
item_id: comment.id,
item_type: 'COMMENTS',
current_user: null,
});
}
);
});
it('should include a current user when one is passed', () => {
return ActionsService.getActionSummaries(
[comment.id],
'flagginguserid'
).then(summaries => {
expect(summaries).to.have.length(2);
let summary = summaries.find(
s => s.item_id === comment.id && s.action_type === 'FLAG'
);
expect(summary).to.not.be.undefined;
expect(summary.current_user).to.not.be.null;
expect(summary.current_user).to.have.property('item_id', comment.id);
expect(summary.current_user).to.have.property('item_type', 'COMMENTS');
expect(summary.current_user).to.have.property(
'user_id',
'flagginguserid'
);
expect(summary.current_user).to.have.property('action_type', 'FLAG');
});
});
it("should not include a current user when one is passed for a user that doesn't have an action", () => {
return ActionsService.getActionSummaries(
[comment.id],
'flagginguserid2'
).then(summaries => {
expect(summaries).to.have.length(2);
summaries.forEach(summary => {
expect(summary).to.not.be.undefined;
expect(summary).to.have.property('current_user', null);
});
});
});
});
});