discourse/plugins/chat/test/javascripts/widgets/chat-invitation-notification-item-test.js
David Taylor 48193767bf DEV: Sort imports
Automatically generated by `eslint --fix` to satisfy the updated configuration
2023-10-10 21:46:54 +01:00

53 lines
1.6 KiB
JavaScript

import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import Notification from "discourse/models/notification";
import { NOTIFICATION_TYPES } from "discourse/tests/fixtures/concerns/notification-types";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import { deepMerge } from "discourse-common/lib/object";
import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel";
function getNotification(overrides = {}) {
return Notification.create(
deepMerge(
{
id: 11,
notification_type: NOTIFICATION_TYPES.chat_invitation,
read: false,
data: {
message: "chat.invitation_notification",
invited_by_username: "eviltrout",
chat_channel_id: 9,
chat_message_id: 2,
chat_channel_title: "Site",
},
},
overrides
)
);
}
module(
"Discourse Chat | Widget | chat-invitation-notification-item",
function (hooks) {
setupRenderingTest(hooks);
test("notification url", async function (assert) {
this.set("args", getNotification());
await render(
hbs`<MountWidget @widget="chat-invitation-notification-item" @args={{this.args}} />`
);
const data = this.args.data;
assert.strictEqual(
query(".chat-invitation a").getAttribute("href"),
`/chat/c/${slugifyChannel({
title: data.chat_channel_title,
})}/${data.chat_channel_id}/${data.chat_message_id}`
);
});
}
);