DEV: Keep global state reset in a single place (#18049)
This commit is contained in:
parent
851bd78347
commit
87f5715878
|
@ -3,7 +3,6 @@ import {
|
|||
count,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { clearCache } from "discourse/lib/plugin-connectors";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { test } from "qunit";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
|
@ -14,7 +13,6 @@ const GOODBYE =
|
|||
|
||||
acceptance("Plugin Outlet - Multi Template", function (needs) {
|
||||
needs.hooks.beforeEach(() => {
|
||||
clearCache();
|
||||
// eslint-disable-next-line no-undef
|
||||
Ember.TEMPLATES[HELLO] = hbs`<span class='hello-span'>Hello</span>`;
|
||||
// eslint-disable-next-line no-undef
|
||||
|
@ -26,7 +24,6 @@ acceptance("Plugin Outlet - Multi Template", function (needs) {
|
|||
delete Ember.TEMPLATES[HELLO];
|
||||
// eslint-disable-next-line no-undef
|
||||
delete Ember.TEMPLATES[GOODBYE];
|
||||
clearCache();
|
||||
});
|
||||
|
||||
test("Renders a template into the outlet", async function (assert) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { test } from "qunit";
|
||||
import I18n from "I18n";
|
||||
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
|
@ -9,7 +8,6 @@ import {
|
|||
queryAll,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { resetSidebarSection } from "discourse/lib/sidebar/user/custom-sections";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
||||
acceptance("Sidebar - Plugin API", function (needs) {
|
||||
|
@ -21,7 +19,6 @@ acceptance("Sidebar - Plugin API", function (needs) {
|
|||
});
|
||||
|
||||
needs.hooks.afterEach(() => {
|
||||
resetSidebarSection();
|
||||
linkDestroy = undefined;
|
||||
sectionDestroy = undefined;
|
||||
});
|
||||
|
|
|
@ -74,6 +74,7 @@ import { clearExtraHeaderIcons } from "discourse/widgets/header";
|
|||
import { resetSidebarSection } from "discourse/lib/sidebar/user/custom-sections";
|
||||
import { resetNotificationTypeRenderers } from "discourse/lib/notification-types-manager";
|
||||
import { resetUserMenuTabs } from "discourse/lib/user-menu/tab";
|
||||
import { reset as resetLinkLookup } from "discourse/lib/link-lookup";
|
||||
|
||||
export function currentUser() {
|
||||
return User.create(sessionFixtures["/session/current.json"].current_user);
|
||||
|
@ -204,6 +205,7 @@ export function testCleanup(container, app) {
|
|||
resetNotificationTypeRenderers();
|
||||
clearExtraHeaderIcons();
|
||||
resetUserMenuTabs();
|
||||
resetLinkLookup();
|
||||
}
|
||||
|
||||
export function discourseModule(name, options) {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import LinkLookup, { reset } from "discourse/lib/link-lookup";
|
||||
import LinkLookup from "discourse/lib/link-lookup";
|
||||
import { module, test } from "qunit";
|
||||
import Post from "discourse/models/post";
|
||||
|
||||
module("Unit | Utility | link-lookup", function (hooks) {
|
||||
hooks.afterEach(() => reset());
|
||||
hooks.beforeEach(function () {
|
||||
this.post = Post.create();
|
||||
this.linkLookup = new LinkLookup({
|
||||
|
@ -21,6 +20,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
|
|||
)[0]
|
||||
);
|
||||
});
|
||||
|
||||
test("works with http", function (assert) {
|
||||
assert.ok(
|
||||
this.linkLookup.check(
|
||||
|
@ -29,6 +29,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
|
|||
)[0]
|
||||
);
|
||||
});
|
||||
|
||||
test("works with trailing slash", function (assert) {
|
||||
assert.ok(
|
||||
this.linkLookup.check(
|
||||
|
@ -37,6 +38,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
|
|||
)[0]
|
||||
);
|
||||
});
|
||||
|
||||
test("works with uppercase characters", function (assert) {
|
||||
assert.ok(
|
||||
this.linkLookup.check(
|
||||
|
|
Loading…
Reference in New Issue