DEV: Extensively use qunit-dom's hasText (#30012)

This commit is contained in:
Jarek Radosz
2024-11-30 16:44:51 +01:00
committed by GitHub
parent d93967e2fb
commit dfb74d90c3
37 changed files with 348 additions and 563 deletions

View File

@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import CoreFabricators from "discourse/lib/fabricators";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChannelName from "discourse/plugins/chat/discourse/components/channel-name";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
import { CHATABLE_TYPES } from "discourse/plugins/chat/discourse/models/chat-channel";
@ -42,10 +41,7 @@ module("Discourse Chat | Component | <ChannelName />", function (hooks) {
await render(<template><ChannelName @channel={{channel}} /></template>);
assert.strictEqual(
query(CHANNEL_NAME_LABEL).innerText.trim(),
user.username
);
assert.dom(CHANNEL_NAME_LABEL).hasText(user.username);
});
test("dm channel - multiple users", async function (assert) {
@ -61,10 +57,7 @@ module("Discourse Chat | Component | <ChannelName />", function (hooks) {
await render(<template><ChannelName @channel={{channel}} /></template>);
assert.strictEqual(
query(CHANNEL_NAME_LABEL).innerText.trim(),
users.mapBy("username").join(", ")
);
assert.dom(CHANNEL_NAME_LABEL).hasText(users.mapBy("username").join(", "));
});
test("dm channel - self", async function (assert) {
@ -76,10 +69,7 @@ module("Discourse Chat | Component | <ChannelName />", function (hooks) {
await render(<template><ChannelName @channel={{channel}} /></template>);
assert.strictEqual(
query(CHANNEL_NAME_LABEL).innerText.trim(),
this.currentUser.username
);
assert.dom(CHANNEL_NAME_LABEL).hasText(this.currentUser.username);
});
test("dm channel - prefers name", async function (assert) {
@ -99,10 +89,7 @@ module("Discourse Chat | Component | <ChannelName />", function (hooks) {
await render(<template><ChannelName @channel={{channel}} /></template>);
assert.strictEqual(
query(CHANNEL_NAME_LABEL).innerText.trim(),
users.mapBy("name").join(", ")
);
assert.dom(CHANNEL_NAME_LABEL).hasText(users.mapBy("name").join(", "));
});
test("unreadIndicator", async function (assert) {