discourse/plugins/chat/test/javascripts/components/sidebar-channels-test.js
Joffrey JAFFEUX 84c1cc70d6
REFACTOR: naming and state refactor (#19187)
- better handling of drawer state using chat state manager
- removes various float and topic occurrences to use drawer
- ensures user can chat before doing a lot of chat setup
- fixes a bug which was creating presence errors in tests
- removes dead code
2022-11-25 14:15:38 +01:00

79 lines
1.6 KiB
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import hbs from "htmlbars-inline-precompile";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import {
setup as setupChatStub,
teardown as teardownChatStub,
} from "../helpers/chat-stub";
import { module } from "qunit";
module("Discourse Chat | Component | sidebar-channels", function (hooks) {
setupRenderingTest(hooks);
componentTest("default", {
template: hbs`{{sidebar-channels}}`,
beforeEach() {
setupChatStub(this);
},
afterEach() {
teardownChatStub();
},
async test(assert) {
assert.ok(exists("[data-chat-channel-id]"));
},
});
componentTest("chat is on chat page", {
template: hbs`{{sidebar-channels}}`,
beforeEach() {
setupChatStub(this, {});
},
afterEach() {
teardownChatStub();
},
async test(assert) {
assert.ok(exists("[data-chat-channel-id]"));
},
});
componentTest("none of the conditions are fulfilled", {
template: hbs`{{sidebar-channels}}`,
beforeEach() {
setupChatStub(this, { userCanChat: false });
},
afterEach() {
teardownChatStub();
},
async test(assert) {
assert.notOk(exists("[data-chat-channel-id]"));
},
});
componentTest("user cant chat", {
template: hbs`{{sidebar-channels}}`,
beforeEach() {
setupChatStub(this, { userCanChat: false });
},
afterEach() {
teardownChatStub();
},
async test(assert) {
assert.notOk(exists("[data-chat-channel-id]"));
},
});
});