This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/unit/lib/notification-items/group-message-summary-test.js
Osama Sayegh 69664d2153
DEV: Make group message summary notification Link to the group inbox (#17884)
This fix is for the experimental user menu.
2022-08-12 15:15:43 +03:00

66 lines
1.8 KiB
JavaScript

import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types";
import { deepMerge } from "discourse-common/lib/object";
import { createRenderDirector } from "discourse/tests/helpers/notification-items-helper";
import Notification from "discourse/models/notification";
import I18n from "I18n";
function getNotification(overrides = {}) {
return Notification.create(
deepMerge(
{
id: 11,
user_id: 1,
notification_type: NOTIFICATION_TYPES.group_message_summary,
read: false,
high_priority: false,
created_at: "2022-07-01T06:00:32.173Z",
data: {
group_id: 321,
group_name: "drummers",
inbox_count: 13,
username: "drummers.boss",
},
},
overrides
)
);
}
discourseModule(
"Unit | Notification Items | group-message-summary",
function () {
test("description", function (assert) {
const notification = getNotification();
const director = createRenderDirector(
notification,
"group_message_summary",
this.siteSettings
);
assert.strictEqual(
director.description,
I18n.t("notifications.group_message_summary", {
group_name: "drummers",
count: 13,
}),
"displays the right content"
);
});
test("linkHref", function (assert) {
const notification = getNotification();
const director = createRenderDirector(
notification,
"group_message_summary",
this.siteSettings
);
assert.strictEqual(
director.linkHref,
"/u/drummers.boss/messages/group/drummers",
"links to the group inbox in the user profile"
);
});
}
);