79 lines
1.6 KiB
JavaScript
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]"));
|
|
},
|
|
});
|
|
});
|