2022-12-22 21:35:18 +08:00
|
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
2022-11-02 21:41:30 +08:00
|
|
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
import hbs from "htmlbars-inline-precompile";
|
|
|
|
import I18n from "I18n";
|
2022-12-22 21:35:18 +08:00
|
|
|
import { module, test } from "qunit";
|
|
|
|
import { render } from "@ember/test-helpers";
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
module("Discourse Chat | Component | chat-message-separator", function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("newest message", async function (assert) {
|
|
|
|
this.set("message", { newestMessage: true });
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
await render(hbs`<ChatMessageSeparator @message={{this.message}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
assert.strictEqual(
|
|
|
|
query(".chat-message-separator.new-message .text").innerText.trim(),
|
|
|
|
I18n.t("chat.new_messages")
|
|
|
|
);
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("first message of the day", async function (assert) {
|
|
|
|
this.set("date", moment().format("LLL"));
|
|
|
|
this.set("message", { firstMessageOfTheDayAt: this.date });
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
await render(hbs`<ChatMessageSeparator @message={{this.message}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
assert.strictEqual(
|
|
|
|
query(
|
|
|
|
".chat-message-separator.first-daily-message .text"
|
|
|
|
).innerText.trim(),
|
|
|
|
this.date
|
|
|
|
);
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
});
|