DEV: Consistently call `setupTest(hooks)` in unit tests (#23610)
This commit is contained in:
parent
92839dc722
commit
837cec6c3d
|
@ -1,5 +1,6 @@
|
||||||
import { buildResolver, setResolverOption } from "discourse-common/resolver";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import { buildResolver, setResolverOption } from "discourse-common/resolver";
|
||||||
import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper";
|
import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper";
|
||||||
import DiscourseTemplateMap from "discourse-common/lib/discourse-template-map";
|
import DiscourseTemplateMap from "discourse-common/lib/discourse-template-map";
|
||||||
|
|
||||||
|
@ -20,6 +21,8 @@ function setTemplates(templateModuleNames) {
|
||||||
const DiscourseResolver = buildResolver("discourse");
|
const DiscourseResolver = buildResolver("discourse");
|
||||||
|
|
||||||
module("Unit | Ember | resolver", function (hooks) {
|
module("Unit | Ember | resolver", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
DiscourseTemplateMap.setModuleNames(Object.keys(requirejs.entries));
|
DiscourseTemplateMap.setModuleNames(Object.keys(requirejs.entries));
|
||||||
resolver = DiscourseResolver.create({
|
resolver = DiscourseResolver.create({
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import AllowLister from "pretty-text/allow-lister";
|
import AllowLister from "pretty-text/allow-lister";
|
||||||
|
|
||||||
module("Unit | Utility | allowLister", function () {
|
module("Unit | Utility | allowLister", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("allowLister", function (assert) {
|
test("allowLister", function (assert) {
|
||||||
const allowLister = new AllowLister();
|
const allowLister = new AllowLister();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import autocomplete from "discourse/lib/autocomplete";
|
import autocomplete from "discourse/lib/autocomplete";
|
||||||
import { compile } from "handlebars";
|
import { compile } from "handlebars";
|
||||||
|
|
||||||
module("Unit | Utility | autocomplete", function (hooks) {
|
module("Unit | Utility | autocomplete", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
let elements = [];
|
let elements = [];
|
||||||
|
|
||||||
function textArea(value) {
|
function textArea(value) {
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
|
import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { formattedReminderTime } from "discourse/lib/bookmark";
|
import { formattedReminderTime } from "discourse/lib/bookmark";
|
||||||
|
|
||||||
module("Unit | Utility | bookmark", function (hooks) {
|
module("Unit | Utility | bookmark", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this.clock = fakeTime("2020-04-11 08:00:00", "Australia/Brisbane");
|
this.clock = fakeTime("2020-04-11 08:00:00", "Australia/Brisbane");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { fixture, logIn } from "discourse/tests/helpers/qunit-helpers";
|
import { fixture, logIn } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import { module, skip, test } from "qunit";
|
import { module, skip, test } from "qunit";
|
||||||
import ClickTrack from "discourse/lib/click-track";
|
import ClickTrack from "discourse/lib/click-track";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
@ -14,6 +15,8 @@ function generateClickEventOn(selector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module("Unit | Utility | click-track", function (hooks) {
|
module("Unit | Utility | click-track", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
logIn();
|
logIn();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import Columns from "discourse/lib/columns";
|
import Columns from "discourse/lib/columns";
|
||||||
|
|
||||||
module("Unit | Columns", function (hooks) {
|
module("Unit | Columns", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.afterEach(function () {
|
hooks.afterEach(function () {
|
||||||
document.getElementById("qunit-fixture").innerHTML = "";
|
document.getElementById("qunit-fixture").innerHTML = "";
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import deprecated, {
|
import deprecated, {
|
||||||
withSilencedDeprecations,
|
withSilencedDeprecations,
|
||||||
withSilencedDeprecationsAsync,
|
withSilencedDeprecationsAsync,
|
||||||
|
@ -7,10 +9,11 @@ import {
|
||||||
enableRaiseOnDeprecation,
|
enableRaiseOnDeprecation,
|
||||||
} from "discourse/tests/helpers/raise-on-deprecation";
|
} from "discourse/tests/helpers/raise-on-deprecation";
|
||||||
import DeprecationCounter from "discourse/tests/helpers/deprecation-counter";
|
import DeprecationCounter from "discourse/tests/helpers/deprecation-counter";
|
||||||
import { module, test } from "qunit";
|
|
||||||
import Sinon from "sinon";
|
import Sinon from "sinon";
|
||||||
|
|
||||||
module("Unit | Utility | deprecated", function (hooks) {
|
module("Unit | Utility | deprecated", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
disableRaiseOnDeprecation();
|
disableRaiseOnDeprecation();
|
||||||
this.warnStub = Sinon.stub(console, "warn");
|
this.warnStub = Sinon.stub(console, "warn");
|
||||||
|
@ -20,7 +23,7 @@ module("Unit | Utility | deprecated", function (hooks) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
hooks.afterEach(() => {
|
hooks.afterEach(function () {
|
||||||
enableRaiseOnDeprecation();
|
enableRaiseOnDeprecation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import {
|
import {
|
||||||
downloadGoogle,
|
downloadGoogle,
|
||||||
formatDates,
|
formatDates,
|
||||||
|
@ -7,6 +8,8 @@ import {
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
|
|
||||||
module("Unit | Utility | download-calendar", function (hooks) {
|
module("Unit | Utility | download-calendar", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
let win = { focus: function () {} };
|
let win = { focus: function () {} };
|
||||||
sinon.stub(window, "open").returns(win);
|
sinon.stub(window, "open").returns(win);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import getURL, {
|
import getURL, {
|
||||||
getAbsoluteURL,
|
getAbsoluteURL,
|
||||||
getURLWithCDN,
|
getURLWithCDN,
|
||||||
|
@ -7,9 +9,10 @@ import getURL, {
|
||||||
setupURL,
|
setupURL,
|
||||||
withoutPrefix,
|
withoutPrefix,
|
||||||
} from "discourse-common/lib/get-url";
|
} from "discourse-common/lib/get-url";
|
||||||
import { module, test } from "qunit";
|
|
||||||
|
|
||||||
module("Unit | Utility | get-url", function () {
|
module("Unit | Utility | get-url", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("isAbsoluteURL", function (assert) {
|
test("isAbsoluteURL", function (assert) {
|
||||||
setupURL(null, "https://example.com", "/forum");
|
setupURL(null, "https://example.com", "/forum");
|
||||||
assert.ok(isAbsoluteURL("https://example.com/test/thing"));
|
assert.ok(isAbsoluteURL("https://example.com/test/thing"));
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import highlightSearch, { CLASS_NAME } from "discourse/lib/highlight-search";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import highlightSearch, { CLASS_NAME } from "discourse/lib/highlight-search";
|
||||||
import { fixture } from "discourse/tests/helpers/qunit-helpers";
|
import { fixture } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
module("Unit | Utility | highlight-search", function () {
|
module("Unit | Utility | highlight-search", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("highlighting text", function (assert) {
|
test("highlighting text", function (assert) {
|
||||||
fixture().innerHTML = `
|
fixture().innerHTML = `
|
||||||
<p>This is some text to highlight</p>
|
<p>This is some text to highlight</p>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import highlightSyntax from "discourse/lib/highlight-syntax";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import highlightSyntax from "discourse/lib/highlight-syntax";
|
||||||
import { fixture } from "discourse/tests/helpers/qunit-helpers";
|
import { fixture } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
let siteSettings = { autohighlight_all_code: true },
|
let siteSettings = { autohighlight_all_code: true },
|
||||||
|
@ -7,7 +8,9 @@ let siteSettings = { autohighlight_all_code: true },
|
||||||
highlightJsPath: "/assets/highlightjs/highlight-test-bundle.min.js",
|
highlightJsPath: "/assets/highlightjs/highlight-test-bundle.min.js",
|
||||||
};
|
};
|
||||||
|
|
||||||
module("Unit | Utility | highlight-syntax", function () {
|
module("Unit | Utility | highlight-syntax", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("highlighting code", async function (assert) {
|
test("highlighting code", async function (assert) {
|
||||||
fixture().innerHTML = `
|
fixture().innerHTML = `
|
||||||
<pre>
|
<pre>
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
||||||
|
|
||||||
module("Unit | Utility | i18n", function (hooks) {
|
module("Unit | Utility | i18n", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
this._locale = I18n.locale;
|
this._locale = I18n.locale;
|
||||||
this._fallbackLocale = I18n.fallbackLocale;
|
this._fallbackLocale = I18n.fallbackLocale;
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import {
|
import {
|
||||||
convertIconClass,
|
convertIconClass,
|
||||||
iconHTML,
|
iconHTML,
|
||||||
iconNode,
|
iconNode,
|
||||||
} from "discourse-common/lib/icon-library";
|
} from "discourse-common/lib/icon-library";
|
||||||
import { module, test } from "qunit";
|
|
||||||
|
|
||||||
module("Unit | Utility | icon-library", function () {
|
module("Unit | Utility | icon-library", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("return icon markup", function (assert) {
|
test("return icon markup", function (assert) {
|
||||||
assert.ok(iconHTML("bars").includes('use href="#bars"'));
|
assert.ok(iconHTML("bars").includes('use href="#bars"'));
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import KeyValueStore from "discourse/lib/key-value-store";
|
import KeyValueStore from "discourse/lib/key-value-store";
|
||||||
|
|
||||||
module("Unit | Utility | key-value-store", function () {
|
module("Unit | Utility | key-value-store", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("is able to get the result back from the store", function (assert) {
|
test("is able to get the result back from the store", function (assert) {
|
||||||
const store = new KeyValueStore("example");
|
const store = new KeyValueStore("example");
|
||||||
store.set({ key: "bob", value: "uncle" });
|
store.set({ key: "bob", value: "uncle" });
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
|
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
|
|
||||||
module("Unit | Utility | keyboard-shortcuts", function (hooks) {
|
module("Unit | Utility | keyboard-shortcuts", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
sinon.stub(DiscourseURL, "routeTo");
|
sinon.stub(DiscourseURL, "routeTo");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import {
|
import {
|
||||||
LIGHTBOX_IMAGE_FIXTURES,
|
LIGHTBOX_IMAGE_FIXTURES,
|
||||||
generateImageUploaderMarkup,
|
generateImageUploaderMarkup,
|
||||||
generateLightboxMarkup,
|
generateLightboxMarkup,
|
||||||
} from "discourse/tests/helpers/lightbox-helpers";
|
} from "discourse/tests/helpers/lightbox-helpers";
|
||||||
import { module, test } from "qunit";
|
|
||||||
|
|
||||||
import { SELECTORS } from "discourse/lib/lightbox/constants";
|
import { SELECTORS } from "discourse/lib/lightbox/constants";
|
||||||
import domFromString from "discourse-common/lib/dom-from-string";
|
import domFromString from "discourse-common/lib/dom-from-string";
|
||||||
import { processHTML } from "discourse/lib/lightbox/process-html";
|
import { processHTML } from "discourse/lib/lightbox/process-html";
|
||||||
|
|
||||||
module("Unit | lib | Experimental lightbox | processHTML()", function () {
|
module("Unit | lib | Experimental lightbox | processHTML()", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
const wrap = domFromString(generateLightboxMarkup())[0];
|
const wrap = domFromString(generateLightboxMarkup())[0];
|
||||||
const imageUploaderWrap = domFromString(generateImageUploaderMarkup())[0];
|
const imageUploaderWrap = domFromString(generateImageUploaderMarkup())[0];
|
||||||
const selector = SELECTORS.DEFAULT_ITEM_SELECTOR;
|
const selector = SELECTORS.DEFAULT_ITEM_SELECTOR;
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import LinkLookup from "discourse/lib/link-lookup";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import LinkLookup from "discourse/lib/link-lookup";
|
||||||
import { getOwner } from "discourse-common/lib/get-owner";
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
|
||||||
module("Unit | Utility | link-lookup", function (hooks) {
|
module("Unit | Utility | link-lookup", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
const store = getOwner(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.post = store.createRecord("post");
|
this.post = store.createRecord("post");
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import {
|
import {
|
||||||
fetchUnseenMentions,
|
fetchUnseenMentions,
|
||||||
linkSeenMentions,
|
linkSeenMentions,
|
||||||
} from "discourse/lib/link-mentions";
|
} from "discourse/lib/link-mentions";
|
||||||
import { module, test } from "qunit";
|
|
||||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import domFromString from "discourse-common/lib/dom-from-string";
|
import domFromString from "discourse-common/lib/dom-from-string";
|
||||||
|
|
||||||
module("Unit | Utility | link-mentions", function () {
|
module("Unit | Utility | link-mentions", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("linkSeenMentions replaces users and groups", async function (assert) {
|
test("linkSeenMentions replaces users and groups", async function (assert) {
|
||||||
pretender.get("/composer/mentions", () =>
|
pretender.get("/composer/mentions", () =>
|
||||||
response({
|
response({
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { cacheBuster } from "discourse/lib/load-script";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import { cacheBuster } from "discourse/lib/load-script";
|
||||||
import { PUBLIC_JS_VERSIONS as jsVersions } from "discourse/lib/public-js-versions";
|
import { PUBLIC_JS_VERSIONS as jsVersions } from "discourse/lib/public-js-versions";
|
||||||
|
|
||||||
module("Unit | Utility | load-script", function () {
|
module("Unit | Utility | load-script", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("works when a value is not present", function (assert) {
|
test("works when a value is not present", function (assert) {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
cacheBuster("/javascripts/my-script.js"),
|
cacheBuster("/javascripts/my-script.js"),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { failedCache, localCache } from "pretty-text/oneboxer-cache";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import { failedCache, localCache } from "pretty-text/oneboxer-cache";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { load } from "pretty-text/oneboxer";
|
import { load } from "pretty-text/oneboxer";
|
||||||
|
|
||||||
|
@ -14,7 +15,9 @@ function loadOnebox(element) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module("Unit | Utility | oneboxer", function () {
|
module("Unit | Utility | oneboxer", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("load - failed onebox", async function (assert) {
|
test("load - failed onebox", async function (assert) {
|
||||||
let element = document.createElement("A");
|
let element = document.createElement("A");
|
||||||
element.setAttribute("href", "http://somebadurl.com");
|
element.setAttribute("href", "http://somebadurl.com");
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import { parseBBCodeTag } from "pretty-text/engines/discourse-markdown/bbcode-block";
|
import { parseBBCodeTag } from "pretty-text/engines/discourse-markdown/bbcode-block";
|
||||||
|
|
||||||
module("Unit | Utility | parseBBCodeTag", function () {
|
module("Unit | Utility | parseBBCodeTag", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("block with multiple quoted attributes", function (assert) {
|
test("block with multiple quoted attributes", function (assert) {
|
||||||
const parsed = parseBBCodeTag('[test one="foo" two="bar bar"]', 0, 30);
|
const parsed = parseBBCodeTag('[test one="foo" two="bar bar"]', 0, 30);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import PreloadStore from "discourse/lib/preload-store";
|
import PreloadStore from "discourse/lib/preload-store";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
|
||||||
module("Unit | Utility | preload-store", function (hooks) {
|
module("Unit | Utility | preload-store", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
PreloadStore.store("bane", "evil");
|
PreloadStore.store("bane", "evil");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import QUnit, { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
||||||
import {
|
import {
|
||||||
applyCachedInlineOnebox,
|
applyCachedInlineOnebox,
|
||||||
deleteCachedInlineOnebox,
|
deleteCachedInlineOnebox,
|
||||||
} from "pretty-text/inline-oneboxer";
|
} from "pretty-text/inline-oneboxer";
|
||||||
import QUnit, { module, test } from "qunit";
|
|
||||||
import { deepMerge } from "discourse-common/lib/object";
|
import { deepMerge } from "discourse-common/lib/object";
|
||||||
import { extractDataAttribute } from "pretty-text/engines/discourse-markdown-it";
|
import { extractDataAttribute } from "pretty-text/engines/discourse-markdown-it";
|
||||||
import { registerEmoji } from "pretty-text/emoji";
|
import { registerEmoji } from "pretty-text/emoji";
|
||||||
|
@ -53,7 +54,9 @@ QUnit.assert.cookedPara = function (input, expected, message) {
|
||||||
QUnit.assert.cooked(input, `<p>${expected}</p>`, message);
|
QUnit.assert.cooked(input, `<p>${expected}</p>`, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
module("Unit | Utility | pretty-text", function () {
|
module("Unit | Utility | pretty-text", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("buildOptions", function (assert) {
|
test("buildOptions", function (assert) {
|
||||||
assert.ok(
|
assert.ok(
|
||||||
buildOptions({ siteSettings: { enable_emoji: true } }).discourse.features
|
buildOptions({ siteSettings: { enable_emoji: true } }).discourse.features
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
||||||
import { hrefAllowed, sanitize } from "pretty-text/sanitizer";
|
import { hrefAllowed, sanitize } from "pretty-text/sanitizer";
|
||||||
import AllowLister from "pretty-text/allow-lister";
|
import AllowLister from "pretty-text/allow-lister";
|
||||||
|
|
||||||
module("Unit | Utility | sanitizer", function () {
|
module("Unit | Utility | sanitizer", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("sanitize", function (assert) {
|
test("sanitize", function (assert) {
|
||||||
const pt = new PrettyText(
|
const pt = new PrettyText(
|
||||||
buildOptions({
|
buildOptions({
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import {
|
import {
|
||||||
searchContextDescription,
|
searchContextDescription,
|
||||||
translateResults,
|
translateResults,
|
||||||
} from "discourse/lib/search";
|
} from "discourse/lib/search";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
module("Unit | Utility | search", function () {
|
module("Unit | Utility | search", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("unescapesEmojisInBlurbs", async function (assert) {
|
test("unescapesEmojisInBlurbs", async function (assert) {
|
||||||
const source = {
|
const source = {
|
||||||
posts: [
|
posts: [
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import Sharing from "discourse/lib/sharing";
|
import Sharing from "discourse/lib/sharing";
|
||||||
|
|
||||||
module("Unit | Utility | sharing", function (hooks) {
|
module("Unit | Utility | sharing", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
Sharing._reset();
|
Sharing._reset();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import SuffixTrie from "discourse-common/lib/suffix-trie";
|
import SuffixTrie from "discourse-common/lib/suffix-trie";
|
||||||
|
|
||||||
module("Unit | SuffixTrie", function () {
|
module("Unit | SuffixTrie", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("SuffixTrie", function (assert) {
|
test("SuffixTrie", function (assert) {
|
||||||
const t = new SuffixTrie("/");
|
const t = new SuffixTrie("/");
|
||||||
t.add("a/b/c/d");
|
t.add("a/b/c/d");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { isLTR, isRTL, setTextDirections } from "discourse/lib/text-direction";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import { isLTR, isRTL, setTextDirections } from "discourse/lib/text-direction";
|
||||||
|
|
||||||
function quoteHtml() {
|
function quoteHtml() {
|
||||||
return `
|
return `
|
||||||
|
@ -30,7 +31,9 @@ function assertDirection(assert, elem, expected, message) {
|
||||||
assert.strictEqual(elem.getAttribute("dir"), expected, message);
|
assert.strictEqual(elem.getAttribute("dir"), expected, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
module("Unit | Utility | text-direction", function () {
|
module("Unit | Utility | text-direction", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("isRTL", function (assert) {
|
test("isRTL", function (assert) {
|
||||||
// Hebrew
|
// Hebrew
|
||||||
assert.strictEqual(isRTL("זה מבחן"), true);
|
assert.strictEqual(isRTL("זה מבחן"), true);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import {
|
import {
|
||||||
cookAsync,
|
cookAsync,
|
||||||
excerpt,
|
excerpt,
|
||||||
|
@ -6,7 +7,9 @@ import {
|
||||||
parseMentions,
|
parseMentions,
|
||||||
} from "discourse/lib/text";
|
} from "discourse/lib/text";
|
||||||
|
|
||||||
module("Unit | Utility | text", function () {
|
module("Unit | Utility | text", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("parseAsync", async function (assert) {
|
test("parseAsync", async function (assert) {
|
||||||
await parseAsync("**test**").then((tokens) => {
|
await parseAsync("**test**").then((tokens) => {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
@ -41,7 +44,9 @@ module("Unit | Utility | text", function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module("Unit | Utility | text | parseMentions", function () {
|
module("Unit | Utility | text | parseMentions", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("parses mentions from markdown", async function (assert) {
|
test("parses mentions from markdown", async function (assert) {
|
||||||
const markdown = "Hey @user1, @user2, @group1, @group2, @here, @all";
|
const markdown = "Hey @user1, @user2, @group1, @group2, @here, @all";
|
||||||
const mentions = await parseMentions(markdown);
|
const mentions = await parseMentions(markdown);
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import toMarkdown, {
|
import toMarkdown, {
|
||||||
addBlockDecorateCallback,
|
addBlockDecorateCallback,
|
||||||
addTagDecorateCallback,
|
addTagDecorateCallback,
|
||||||
} from "discourse/lib/to-markdown";
|
} from "discourse/lib/to-markdown";
|
||||||
|
|
||||||
module("Unit | Utility | to-markdown", function () {
|
module("Unit | Utility | to-markdown", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("converts styles between normal words", function (assert) {
|
test("converts styles between normal words", function (assert) {
|
||||||
const html = `Line with <s>styles</s> <b><i>between</i></b> words.`;
|
const html = `Line with <s>styles</s> <b><i>between</i></b> words.`;
|
||||||
const markdown = `Line with ~~styles~~ ***between*** words.`;
|
const markdown = `Line with ~~styles~~ ***between*** words.`;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import {
|
import {
|
||||||
lookupCachedUploadUrl,
|
lookupCachedUploadUrl,
|
||||||
resetCache,
|
resetCache,
|
||||||
resolveAllShortUrls,
|
resolveAllShortUrls,
|
||||||
} from "pretty-text/upload-short-url";
|
} from "pretty-text/upload-short-url";
|
||||||
import { module, test } from "qunit";
|
|
||||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { fixture } from "discourse/tests/helpers/qunit-helpers";
|
import { fixture } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
@ -85,6 +86,8 @@ function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module("Unit | Utility | pretty-text/upload-short-url", function (hooks) {
|
module("Unit | Utility | pretty-text/upload-short-url", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.afterEach(function () {
|
hooks.afterEach(function () {
|
||||||
resetCache();
|
resetCache();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import UppyChecksum from "discourse/lib/uppy-checksum-plugin";
|
|
||||||
import { module, skip, test } from "qunit";
|
import { module, skip, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import UppyChecksum from "discourse/lib/uppy-checksum-plugin";
|
||||||
import { createFile } from "discourse/tests/helpers/qunit-helpers";
|
import { createFile } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
|
|
||||||
|
@ -48,7 +49,9 @@ class FakeUppy {
|
||||||
|
|
||||||
let withCrypto = window.crypto.subtle ? test : skip;
|
let withCrypto = window.crypto.subtle ? test : skip;
|
||||||
|
|
||||||
module("Unit | Utility | UppyChecksum Plugin", function () {
|
module("Unit | Utility | UppyChecksum Plugin", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("sets the options passed in", function (assert) {
|
test("sets the options passed in", function (assert) {
|
||||||
const capabilities = {};
|
const capabilities = {};
|
||||||
const fakeUppy = new FakeUppy();
|
const fakeUppy = new FakeUppy();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
|
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
|
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
|
||||||
|
|
||||||
class FakeUppy {
|
class FakeUppy {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -34,7 +35,9 @@ class FakeUppy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module("Unit | Utility | UppyMediaOptimization Plugin", function () {
|
module("Unit | Utility | UppyMediaOptimization Plugin", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("sets the options passed in", function (assert) {
|
test("sets the options passed in", function (assert) {
|
||||||
const fakeUppy = new FakeUppy();
|
const fakeUppy = new FakeUppy();
|
||||||
const plugin = new UppyMediaOptimization(fakeUppy, {
|
const plugin = new UppyMediaOptimization(fakeUppy, {
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import DiscourseURL, {
|
import DiscourseURL, {
|
||||||
getCategoryAndTagUrl,
|
getCategoryAndTagUrl,
|
||||||
prefixProtocol,
|
prefixProtocol,
|
||||||
userPath,
|
userPath,
|
||||||
} from "discourse/lib/url";
|
} from "discourse/lib/url";
|
||||||
import { module, test } from "qunit";
|
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import { logIn } from "discourse/tests/helpers/qunit-helpers";
|
import { logIn } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { setPrefix } from "discourse-common/lib/get-url";
|
import { setPrefix } from "discourse-common/lib/get-url";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
|
|
||||||
module("Unit | Utility | url", function () {
|
module("Unit | Utility | url", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("isInternal with a HTTP url", function (assert) {
|
test("isInternal with a HTTP url", function (assert) {
|
||||||
sinon.stub(DiscourseURL, "origin").returns("http://eviltrout.com");
|
sinon.stub(DiscourseURL, "origin").returns("http://eviltrout.com");
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import { CANCELLED_STATUS } from "discourse/lib/autocomplete";
|
import { CANCELLED_STATUS } from "discourse/lib/autocomplete";
|
||||||
import userSearch from "discourse/lib/user-search";
|
import userSearch from "discourse/lib/user-search";
|
||||||
|
|
||||||
module("Unit | Utility | user-search", function (hooks) {
|
module("Unit | Utility | user-search", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
pretender.get("/u/search/users", (request) => {
|
pretender.get("/u/search/users", (request) => {
|
||||||
// special responder for per category search
|
// special responder for per category search
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import Setting from "admin/mixins/setting-object";
|
import Setting from "admin/mixins/setting-object";
|
||||||
|
|
||||||
module("Unit | Mixin | setting-object", function () {
|
module("Unit | Mixin | setting-object", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("flat array", function (assert) {
|
test("flat array", function (assert) {
|
||||||
const FooSetting = EmberObject.extend(Setting);
|
const FooSetting = EmberObject.extend(Setting);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import Singleton from "discourse/mixins/singleton";
|
import Singleton from "discourse/mixins/singleton";
|
||||||
|
|
||||||
module("Unit | Mixin | singleton", function () {
|
module("Unit | Mixin | singleton", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
test("current", function (assert) {
|
test("current", function (assert) {
|
||||||
let DummyModel = EmberObject.extend({});
|
let DummyModel = EmberObject.extend({});
|
||||||
DummyModel.reopenClass(Singleton);
|
DummyModel.reopenClass(Singleton);
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
import { setupTest } from "ember-qunit";
|
||||||
import { applyLocalDates } from "../initializers/discourse-local-dates";
|
import { applyLocalDates } from "../initializers/discourse-local-dates";
|
||||||
import { freezeTime } from "./local-date-builder-test";
|
import { freezeTime } from "./local-date-builder-test";
|
||||||
|
|
||||||
module("Unit | Discourse Local Dates | discourse-local-dates", function () {
|
module("Unit | discourse-local-dates", function (hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
function createElementFromHTML(htmlString) {
|
function createElementFromHTML(htmlString) {
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
div.innerHTML = htmlString.trim();
|
div.innerHTML = htmlString.trim();
|
||||||
|
@ -41,7 +44,9 @@ module("Unit | Discourse Local Dates | discourse-local-dates", function () {
|
||||||
freezeTime(
|
freezeTime(
|
||||||
{ date: "2022-10-07T10:10:10", timezone: "Asia/Singapore" },
|
{ date: "2022-10-07T10:10:10", timezone: "Asia/Singapore" },
|
||||||
() => {
|
() => {
|
||||||
applyLocalDates(dateElements, { discourse_local_dates_enabled: true });
|
applyLocalDates(dateElements, {
|
||||||
|
discourse_local_dates_enabled: true,
|
||||||
|
});
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
from.querySelector(".relative-time").textContent,
|
from.querySelector(".relative-time").textContent,
|
||||||
|
@ -64,7 +69,9 @@ module("Unit | Discourse Local Dates | discourse-local-dates", function () {
|
||||||
freezeTime(
|
freezeTime(
|
||||||
{ date: "2022-10-07T10:10:10", timezone: "Asia/Singapore" },
|
{ date: "2022-10-07T10:10:10", timezone: "Asia/Singapore" },
|
||||||
() => {
|
() => {
|
||||||
applyLocalDates(dateElements, { discourse_local_dates_enabled: true });
|
applyLocalDates(dateElements, {
|
||||||
|
discourse_local_dates_enabled: true,
|
||||||
|
});
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
from.querySelector(".relative-time").textContent,
|
from.querySelector(".relative-time").textContent,
|
||||||
|
|
Loading…
Reference in New Issue