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 { setupTest } from "ember-qunit";
|
||||
import { buildResolver, setResolverOption } from "discourse-common/resolver";
|
||||
import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper";
|
||||
import DiscourseTemplateMap from "discourse-common/lib/discourse-template-map";
|
||||
|
||||
|
@ -20,6 +21,8 @@ function setTemplates(templateModuleNames) {
|
|||
const DiscourseResolver = buildResolver("discourse");
|
||||
|
||||
module("Unit | Ember | resolver", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
DiscourseTemplateMap.setModuleNames(Object.keys(requirejs.entries));
|
||||
resolver = DiscourseResolver.create({
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import AllowLister from "pretty-text/allow-lister";
|
||||
|
||||
module("Unit | Utility | allowLister", function () {
|
||||
module("Unit | Utility | allowLister", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("allowLister", function (assert) {
|
||||
const allowLister = new AllowLister();
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import autocomplete from "discourse/lib/autocomplete";
|
||||
import { compile } from "handlebars";
|
||||
|
||||
module("Unit | Utility | autocomplete", function (hooks) {
|
||||
setupTest(hooks);
|
||||
let elements = [];
|
||||
|
||||
function textArea(value) {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { formattedReminderTime } from "discourse/lib/bookmark";
|
||||
|
||||
module("Unit | Utility | bookmark", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
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 { setupTest } from "ember-qunit";
|
||||
import { module, skip, test } from "qunit";
|
||||
import ClickTrack from "discourse/lib/click-track";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
|
@ -14,6 +15,8 @@ function generateClickEventOn(selector) {
|
|||
}
|
||||
|
||||
module("Unit | Utility | click-track", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
logIn();
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import Columns from "discourse/lib/columns";
|
||||
|
||||
module("Unit | Columns", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.afterEach(function () {
|
||||
document.getElementById("qunit-fixture").innerHTML = "";
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import deprecated, {
|
||||
withSilencedDeprecations,
|
||||
withSilencedDeprecationsAsync,
|
||||
|
@ -7,10 +9,11 @@ import {
|
|||
enableRaiseOnDeprecation,
|
||||
} from "discourse/tests/helpers/raise-on-deprecation";
|
||||
import DeprecationCounter from "discourse/tests/helpers/deprecation-counter";
|
||||
import { module, test } from "qunit";
|
||||
import Sinon from "sinon";
|
||||
|
||||
module("Unit | Utility | deprecated", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
disableRaiseOnDeprecation();
|
||||
this.warnStub = Sinon.stub(console, "warn");
|
||||
|
@ -20,7 +23,7 @@ module("Unit | Utility | deprecated", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
hooks.afterEach(() => {
|
||||
hooks.afterEach(function () {
|
||||
enableRaiseOnDeprecation();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import {
|
||||
downloadGoogle,
|
||||
formatDates,
|
||||
|
@ -7,6 +8,8 @@ import {
|
|||
import sinon from "sinon";
|
||||
|
||||
module("Unit | Utility | download-calendar", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
let win = { focus: function () {} };
|
||||
sinon.stub(window, "open").returns(win);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import getURL, {
|
||||
getAbsoluteURL,
|
||||
getURLWithCDN,
|
||||
|
@ -7,9 +9,10 @@ import getURL, {
|
|||
setupURL,
|
||||
withoutPrefix,
|
||||
} 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) {
|
||||
setupURL(null, "https://example.com", "/forum");
|
||||
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 { setupTest } from "ember-qunit";
|
||||
import highlightSearch, { CLASS_NAME } from "discourse/lib/highlight-search";
|
||||
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) {
|
||||
fixture().innerHTML = `
|
||||
<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 { setupTest } from "ember-qunit";
|
||||
import highlightSyntax from "discourse/lib/highlight-syntax";
|
||||
import { fixture } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
let siteSettings = { autohighlight_all_code: true },
|
||||
|
@ -7,7 +8,9 @@ let siteSettings = { autohighlight_all_code: true },
|
|||
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) {
|
||||
fixture().innerHTML = `
|
||||
<pre>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import I18n from "I18n";
|
||||
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
||||
|
||||
module("Unit | Utility | i18n", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this._locale = I18n.locale;
|
||||
this._fallbackLocale = I18n.fallbackLocale;
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import {
|
||||
convertIconClass,
|
||||
iconHTML,
|
||||
iconNode,
|
||||
} 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) {
|
||||
assert.ok(iconHTML("bars").includes('use href="#bars"'));
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
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) {
|
||||
const store = new KeyValueStore("example");
|
||||
store.set({ key: "bob", value: "uncle" });
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
|
||||
import sinon from "sinon";
|
||||
|
||||
module("Unit | Utility | keyboard-shortcuts", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
sinon.stub(DiscourseURL, "routeTo");
|
||||
});
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import {
|
||||
LIGHTBOX_IMAGE_FIXTURES,
|
||||
generateImageUploaderMarkup,
|
||||
generateLightboxMarkup,
|
||||
} from "discourse/tests/helpers/lightbox-helpers";
|
||||
import { module, test } from "qunit";
|
||||
|
||||
import { SELECTORS } from "discourse/lib/lightbox/constants";
|
||||
import domFromString from "discourse-common/lib/dom-from-string";
|
||||
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 imageUploaderWrap = domFromString(generateImageUploaderMarkup())[0];
|
||||
const selector = SELECTORS.DEFAULT_ITEM_SELECTOR;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import LinkLookup from "discourse/lib/link-lookup";
|
||||
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";
|
||||
|
||||
module("Unit | Utility | link-lookup", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
const store = getOwner(this).lookup("service:store");
|
||||
this.post = store.createRecord("post");
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import {
|
||||
fetchUnseenMentions,
|
||||
linkSeenMentions,
|
||||
} from "discourse/lib/link-mentions";
|
||||
import { module, test } from "qunit";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
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) {
|
||||
pretender.get("/composer/mentions", () =>
|
||||
response({
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { cacheBuster } from "discourse/lib/load-script";
|
||||
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";
|
||||
|
||||
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) {
|
||||
assert.strictEqual(
|
||||
cacheBuster("/javascripts/my-script.js"),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { failedCache, localCache } from "pretty-text/oneboxer-cache";
|
||||
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 { 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) {
|
||||
let element = document.createElement("A");
|
||||
element.setAttribute("href", "http://somebadurl.com");
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
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) {
|
||||
const parsed = parseBBCodeTag('[test one="foo" two="bar bar"]', 0, 30);
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import PreloadStore from "discourse/lib/preload-store";
|
||||
import { Promise } from "rsvp";
|
||||
|
||||
module("Unit | Utility | preload-store", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
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 {
|
||||
applyCachedInlineOnebox,
|
||||
deleteCachedInlineOnebox,
|
||||
} from "pretty-text/inline-oneboxer";
|
||||
import QUnit, { module, test } from "qunit";
|
||||
import { deepMerge } from "discourse-common/lib/object";
|
||||
import { extractDataAttribute } from "pretty-text/engines/discourse-markdown-it";
|
||||
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);
|
||||
};
|
||||
|
||||
module("Unit | Utility | pretty-text", function () {
|
||||
module("Unit | Utility | pretty-text", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("buildOptions", function (assert) {
|
||||
assert.ok(
|
||||
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 { setupTest } from "ember-qunit";
|
||||
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
||||
import { hrefAllowed, sanitize } from "pretty-text/sanitizer";
|
||||
import AllowLister from "pretty-text/allow-lister";
|
||||
|
||||
module("Unit | Utility | sanitizer", function () {
|
||||
module("Unit | Utility | sanitizer", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("sanitize", function (assert) {
|
||||
const pt = new PrettyText(
|
||||
buildOptions({
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import {
|
||||
searchContextDescription,
|
||||
translateResults,
|
||||
} from "discourse/lib/search";
|
||||
import I18n from "I18n";
|
||||
|
||||
module("Unit | Utility | search", function () {
|
||||
module("Unit | Utility | search", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("unescapesEmojisInBlurbs", async function (assert) {
|
||||
const source = {
|
||||
posts: [
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import Sharing from "discourse/lib/sharing";
|
||||
|
||||
module("Unit | Utility | sharing", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
Sharing._reset();
|
||||
});
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import SuffixTrie from "discourse-common/lib/suffix-trie";
|
||||
|
||||
module("Unit | SuffixTrie", function () {
|
||||
module("Unit | SuffixTrie", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("SuffixTrie", function (assert) {
|
||||
const t = new SuffixTrie("/");
|
||||
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 { setupTest } from "ember-qunit";
|
||||
import { isLTR, isRTL, setTextDirections } from "discourse/lib/text-direction";
|
||||
|
||||
function quoteHtml() {
|
||||
return `
|
||||
|
@ -30,7 +31,9 @@ function assertDirection(assert, elem, 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) {
|
||||
// Hebrew
|
||||
assert.strictEqual(isRTL("זה מבחן"), true);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import {
|
||||
cookAsync,
|
||||
excerpt,
|
||||
|
@ -6,7 +7,9 @@ import {
|
|||
parseMentions,
|
||||
} from "discourse/lib/text";
|
||||
|
||||
module("Unit | Utility | text", function () {
|
||||
module("Unit | Utility | text", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("parseAsync", async function (assert) {
|
||||
await parseAsync("**test**").then((tokens) => {
|
||||
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) {
|
||||
const markdown = "Hey @user1, @user2, @group1, @group2, @here, @all";
|
||||
const mentions = await parseMentions(markdown);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import toMarkdown, {
|
||||
addBlockDecorateCallback,
|
||||
addTagDecorateCallback,
|
||||
} 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) {
|
||||
const html = `Line with <s>styles</s> <b><i>between</i></b> words.`;
|
||||
const markdown = `Line with ~~styles~~ ***between*** words.`;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import {
|
||||
lookupCachedUploadUrl,
|
||||
resetCache,
|
||||
resolveAllShortUrls,
|
||||
} from "pretty-text/upload-short-url";
|
||||
import { module, test } from "qunit";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
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) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.afterEach(function () {
|
||||
resetCache();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import UppyChecksum from "discourse/lib/uppy-checksum-plugin";
|
||||
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 sinon from "sinon";
|
||||
|
||||
|
@ -48,7 +49,9 @@ class FakeUppy {
|
|||
|
||||
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) {
|
||||
const capabilities = {};
|
||||
const fakeUppy = new FakeUppy();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
|
||||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
|
||||
|
||||
class FakeUppy {
|
||||
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) {
|
||||
const fakeUppy = new FakeUppy();
|
||||
const plugin = new UppyMediaOptimization(fakeUppy, {
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import DiscourseURL, {
|
||||
getCategoryAndTagUrl,
|
||||
prefixProtocol,
|
||||
userPath,
|
||||
} from "discourse/lib/url";
|
||||
import { module, test } from "qunit";
|
||||
import User from "discourse/models/user";
|
||||
import { logIn } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { setPrefix } from "discourse-common/lib/get-url";
|
||||
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) {
|
||||
sinon.stub(DiscourseURL, "origin").returns("http://eviltrout.com");
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import { CANCELLED_STATUS } from "discourse/lib/autocomplete";
|
||||
import userSearch from "discourse/lib/user-search";
|
||||
|
||||
module("Unit | Utility | user-search", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
pretender.get("/u/search/users", (request) => {
|
||||
// special responder for per category search
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import EmberObject from "@ember/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) {
|
||||
const FooSetting = EmberObject.extend(Setting);
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import EmberObject from "@ember/object";
|
||||
import Singleton from "discourse/mixins/singleton";
|
||||
|
||||
module("Unit | Mixin | singleton", function () {
|
||||
module("Unit | Mixin | singleton", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("current", function (assert) {
|
||||
let DummyModel = EmberObject.extend({});
|
||||
DummyModel.reopenClass(Singleton);
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { module, test } from "qunit";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import { applyLocalDates } from "../initializers/discourse-local-dates";
|
||||
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) {
|
||||
const div = document.createElement("div");
|
||||
div.innerHTML = htmlString.trim();
|
||||
|
@ -41,7 +44,9 @@ module("Unit | Discourse Local Dates | discourse-local-dates", function () {
|
|||
freezeTime(
|
||||
{ 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(
|
||||
from.querySelector(".relative-time").textContent,
|
||||
|
@ -64,7 +69,9 @@ module("Unit | Discourse Local Dates | discourse-local-dates", function () {
|
|||
freezeTime(
|
||||
{ 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(
|
||||
from.querySelector(".relative-time").textContent,
|
||||
|
|
Loading…
Reference in New Issue