mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 03:25:31 -05:00
f661fa609e
http://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
/*global waitsFor:true expect:true describe:true beforeEach:true it:true */
|
|
(function() {
|
|
|
|
describe("Discourse.UserAction", function() {
|
|
return describe("collapseStream", function() {
|
|
return it("collapses all likes", function() {
|
|
var actions;
|
|
actions = [
|
|
Discourse.UserAction.create({
|
|
action_type: Discourse.UserAction.LIKE,
|
|
topic_id: 1,
|
|
user_id: 1,
|
|
post_number: 1
|
|
}), Discourse.UserAction.create({
|
|
action_type: Discourse.UserAction.EDIT,
|
|
topic_id: 2,
|
|
user_id: 1,
|
|
post_number: 1
|
|
}), Discourse.UserAction.create({
|
|
action_type: Discourse.UserAction.LIKE,
|
|
topic_id: 1,
|
|
user_id: 2,
|
|
post_number: 1
|
|
})
|
|
];
|
|
actions = Discourse.UserAction.collapseStream(actions);
|
|
expect(actions.length).toBe(2);
|
|
expect(actions[0].get("children").length).toBe(1);
|
|
return expect(actions[0].get("children")[0].items.length).toBe(2);
|
|
});
|
|
});
|
|
});
|
|
|
|
}).call(this);
|