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:
Jarek Radosz
2022-12-22 14:35:18 +01:00
committed by GitHub
parent 8546c2084a
commit dc3473fe06
34 changed files with 1397 additions and 1762 deletions

View File

@ -1,28 +1,21 @@
import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
import { click } from "@ember/test-helpers";
import { module } from "qunit";
import { click, render } from "@ember/test-helpers";
import { module, test } from "qunit";
module("Discourse Chat | Component | chat-composer-dropdown", function (hooks) {
setupRenderingTest(hooks);
componentTest("buttons", {
template: hbs`{{chat-composer-dropdown buttons=buttons}}`,
test("buttons", async function (assert) {
this.set("buttons", [{ id: "foo", icon: "times", action: () => {} }]);
async beforeEach() {
this.set("buttons", [{ id: "foo", icon: "times", action: () => {} }]);
},
await render(hbs`<ChatComposerDropdown @buttons={{this.buttons}} />`);
await click(".chat-composer-dropdown__trigger-btn");
async test(assert) {
await click(".chat-composer-dropdown__trigger-btn");
assert.ok(exists(".chat-composer-dropdown__item.foo"));
assert.ok(
exists(".chat-composer-dropdown__action-btn.foo .d-icon-times")
);
},
assert.true(exists(".chat-composer-dropdown__item.foo"));
assert.true(
exists(".chat-composer-dropdown__action-btn.foo .d-icon-times")
);
});
});