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