discourse/plugins/chat/test/javascripts/components/user-card-chat-button-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

34 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import hbs from "htmlbars-inline-precompile";
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import sinon from "sinon";
import { exists } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Chat | Component | user-card-chat-button", function (hooks) {
setupRenderingTest(hooks);
test("when current user can send direct messages", async function (assert) {
sinon
.stub(this.owner.lookup("service:chat"), "userCanDirectMessage")
.value(true);
await render(hbs`<UserCardChatButton/>`);
assert.true(exists(".user-card-chat-btn"), "it shows the chat button");
});
test("when current user cant send direct messages", async function (assert) {
sinon
.stub(this.owner.lookup("service:chat"), "userCanDirectMessage")
.value(false);
await render(hbs`<UserCardChatButton/>`);
assert.false(
exists(".user-card-chat-btn"),
"it doesnt show the chat button"
);
});
});