discourse/plugins/chat/test/javascripts/helpers/chat-stub.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

27 lines
722 B
JavaScript

import fabricators from "../helpers/fabricators";
import { isPresent } from "@ember/utils";
import Service from "@ember/service";
let publicChannels;
let userCanChat;
class ChatStub extends Service {
userCanChat = userCanChat;
publicChannels = publicChannels;
}
export function setup(context, options = {}) {
context.registry.register("service:chat-stub", ChatStub);
context.registry.injection("component", "chat", "service:chat-stub");
publicChannels = isPresent(options.publicChannels)
? options.publicChannels
: [fabricators.chatChannel()];
userCanChat = isPresent(options.userCanChat) ? options.userCanChat : true;
}
export function teardown() {
publicChannels = [];
userCanChat = true;
}