mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
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
This commit is contained in:
@ -1,34 +1,25 @@
|
||||
import componentTest, {
|
||||
setupRenderingTest,
|
||||
} from "discourse/tests/helpers/component-test";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { module } from "qunit";
|
||||
import { module, test } from "qunit";
|
||||
import { render } from "@ember/test-helpers";
|
||||
|
||||
module("Discourse Chat | Component | chat-message-avatar", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
componentTest("chat_webhook_event", {
|
||||
template: hbs`{{chat-message-avatar message=message}}`,
|
||||
test("chat_webhook_event", async function (assert) {
|
||||
this.set("message", { chat_webhook_event: { emoji: ":heart:" } });
|
||||
|
||||
beforeEach() {
|
||||
this.set("message", { chat_webhook_event: { emoji: ":heart:" } });
|
||||
},
|
||||
await render(hbs`<ChatMessageAvatar @message={{this.message}} />`);
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(query(".chat-emoji-avatar .emoji").title, "heart");
|
||||
},
|
||||
assert.strictEqual(query(".chat-emoji-avatar .emoji").title, "heart");
|
||||
});
|
||||
|
||||
componentTest("user", {
|
||||
template: hbs`{{chat-message-avatar message=message}}`,
|
||||
test("user", async function (assert) {
|
||||
this.set("message", { user: { username: "discobot" } });
|
||||
|
||||
beforeEach() {
|
||||
this.set("message", { user: { username: "discobot" } });
|
||||
},
|
||||
await render(hbs`<ChatMessageAvatar @message={{this.message}} />`);
|
||||
|
||||
async test(assert) {
|
||||
assert.ok(exists('.chat-user-avatar [data-user-card="discobot"]'));
|
||||
},
|
||||
assert.true(exists('.chat-user-avatar [data-user-card="discobot"]'));
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user