mirror of
https://github.com/wassname/talk.git
synced 2026-08-18 12:30:39 +08:00
added support for configuring limiting, action optims
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user