REFACTOR: Remove Discourse.__container__ from tests

This commit is contained in:
Robin Ward
2020-07-28 13:07:33 -04:00
parent 81ab62c72a
commit 01a3fa1ca8
6 changed files with 51 additions and 56 deletions
@@ -4,12 +4,11 @@ import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
acceptance("EmojiPicker", {
loggedIn: true,
beforeEach() {
const store = Discourse.__container__.lookup("service:emoji-store");
store.reset();
this.emojiStore = this.container.lookup("service:emoji-store");
this.emojiStore.reset();
},
afterEach() {
const store = Discourse.__container__.lookup("service:emoji-store");
store.reset();
this.emojiStore.reset();
}
});
@@ -3,19 +3,14 @@ import { withPluginApi } from "discourse/lib/plugin-api";
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
import KeyboardShortcutInitializer from "discourse/initializers/keyboard-shortcuts";
function initKeyboardShortcuts() {
// this is here because initializers/keyboard-shortcuts is not
// firing for this acceptance test, and it needs to be fired before
// more keyboard shortcuts can be added
KeyboardShortcutInitializer.initialize(Discourse.__container__);
}
acceptance("Plugin Keyboard Shortcuts - Logged In", {
loggedIn: true
loggedIn: true,
beforeEach() {
KeyboardShortcutInitializer.initialize(this.container);
}
});
test("a plugin can add a keyboard shortcut", async assert => {
initKeyboardShortcuts();
withPluginApi("0.8.38", api => {
api.addKeyboardShortcut("]", () => {
$("#qunit-fixture").html(
@@ -34,12 +29,14 @@ test("a plugin can add a keyboard shortcut", async assert => {
});
acceptance("Plugin Keyboard Shortcuts - Anonymous", {
loggedIn: false
loggedIn: false,
beforeEach() {
KeyboardShortcutInitializer.initialize(this.container);
}
});
test("a plugin can add a keyboard shortcut with an option", async assert => {
var spy = sandbox.spy(KeyboardShortcuts, "_bindToPath");
initKeyboardShortcuts();
let spy = sandbox.spy(KeyboardShortcuts, "_bindToPath");
withPluginApi("0.8.38", api => {
api.addKeyboardShortcut("]", () => {}, {
anonymous: true,