discourse/plugins/chat/test/javascripts/components/chat-message-separator-test.js
Jarek Radosz dc3473fe06
DEV: Modernize chat's component tests (#19577)
1. `test()` and `render()` instead of `componentTest()`
2. Angle brackets
3. `strictEqual()`/`true()`/`false()` assertions

This removes all remaining uses of `componentTest` from core
2022-12-22 14:35:18 +01:00

36 lines
1.1 KiB
JavaScript

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