mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
* `@ember/owner` instead of `@ember/application`
* `discourse-i18n` instead of `I18n`
* `{ service } from "@ember/service"` instead of `inject as service`
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import { getOwner } from "@ember/owner";
|
|
import { setupTest } from "ember-qunit";
|
|
import { module, test } from "qunit";
|
|
import UserAction from "discourse/models/user-action";
|
|
|
|
module("Unit | Model | user-action", function (hooks) {
|
|
setupTest(hooks);
|
|
|
|
test("collapsing likes", function (assert) {
|
|
const store = getOwner(this).lookup("service:store");
|
|
const actions = UserAction.collapseStream([
|
|
store.createRecord("user-action", {
|
|
action_type: UserAction.TYPES.likes_given,
|
|
topic_id: 1,
|
|
user_id: 1,
|
|
post_number: 1,
|
|
}),
|
|
store.createRecord("user-action", {
|
|
action_type: UserAction.TYPES.edits,
|
|
topic_id: 2,
|
|
user_id: 1,
|
|
post_number: 1,
|
|
}),
|
|
store.createRecord("user-action", {
|
|
action_type: UserAction.TYPES.likes_given,
|
|
topic_id: 1,
|
|
user_id: 2,
|
|
post_number: 1,
|
|
}),
|
|
]);
|
|
|
|
assert.strictEqual(actions.length, 2);
|
|
assert.strictEqual(actions[0].children.length, 1);
|
|
assert.strictEqual(actions[0].children[0].items.length, 2);
|
|
});
|
|
});
|