2022-12-22 08:35:18 -05:00
|
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
2022-11-02 09:41:30 -04:00
|
|
|
import hbs from "htmlbars-inline-precompile";
|
|
|
|
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
2022-12-22 08:35:18 -05:00
|
|
|
import { module, test } from "qunit";
|
|
|
|
import { render } from "@ember/test-helpers";
|
2022-11-02 09:41:30 -04:00
|
|
|
|
|
|
|
module("Discourse Chat | Component | chat-message-avatar", function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2022-12-22 08:35:18 -05:00
|
|
|
test("chat_webhook_event", async function (assert) {
|
|
|
|
this.set("message", { chat_webhook_event: { emoji: ":heart:" } });
|
2022-11-02 09:41:30 -04:00
|
|
|
|
2022-12-22 08:35:18 -05:00
|
|
|
await render(hbs`<ChatMessageAvatar @message={{this.message}} />`);
|
2022-11-02 09:41:30 -04:00
|
|
|
|
2022-12-22 08:35:18 -05:00
|
|
|
assert.strictEqual(query(".chat-emoji-avatar .emoji").title, "heart");
|
2022-11-02 09:41:30 -04:00
|
|
|
});
|
|
|
|
|
2022-12-22 08:35:18 -05:00
|
|
|
test("user", async function (assert) {
|
|
|
|
this.set("message", { user: { username: "discobot" } });
|
2022-11-02 09:41:30 -04:00
|
|
|
|
2022-12-22 08:35:18 -05:00
|
|
|
await render(hbs`<ChatMessageAvatar @message={{this.message}} />`);
|
2022-11-02 09:41:30 -04:00
|
|
|
|
2022-12-22 08:35:18 -05:00
|
|
|
assert.true(exists('.chat-user-avatar [data-user-card="discobot"]'));
|
2022-11-02 09:41:30 -04:00
|
|
|
});
|
|
|
|
});
|