DEV: prevents toolbar callbacks to leak between tests (#9403)

This commit is contained in:
Joffrey JAFFEUX 2020-04-10 16:47:27 +02:00 committed by GitHub
parent b57d4586d7
commit 058506bb77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -52,7 +52,7 @@ const OP = {
const FOUR_SPACES_INDENT = "4-spaces-indent";
const _createCallbacks = [];
let _createCallbacks = [];
const isInside = (text, regex) => {
const matches = text.match(regex);
@ -212,6 +212,9 @@ class Toolbar {
export function addToolbarCallback(func) {
_createCallbacks.push(func);
}
export function clearToolbarCallbacks() {
_createCallbacks = [];
}
export function onToolbarCreate(func) {
deprecated("`onToolbarCreate` is deprecated, use the plugin api instead.");

View File

@ -1,4 +1,5 @@
import { next } from "@ember/runloop";
import { clearToolbarCallbacks } from "discourse/components/d-editor";
import componentTest from "helpers/component-test";
import { withPluginApi } from "discourse/lib/plugin-api";
import formatTextWithSelection from "helpers/d-editor-helper";
@ -633,6 +634,11 @@ componentTest("emoji", {
});
this.set("value", "hello world.");
},
afterEach() {
clearToolbarCallbacks();
},
async test(assert) {
jumpEnd(find("textarea.d-editor-input")[0]);
await click("button.emoji");