DEV: Autofix (w/ manual follow up) various qunit lints (#29950)

This commit is contained in:
Jarek Radosz 2024-11-27 13:02:55 +01:00 committed by GitHub
parent e4bb727d33
commit 5db0eba0a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
58 changed files with 444 additions and 487 deletions

View File

@ -53,6 +53,8 @@ export function deepEqual(obj1, obj2) {
}
}
return true;
} else {
return false;
}
}

View File

@ -153,12 +153,14 @@ acceptance("Categories - preloadStore handling", function () {
await visit(`/categories`);
assert.true(
PreloadStore.get("topic_list") === undefined,
assert.strictEqual(
PreloadStore.get("topic_list"),
undefined,
`topic_list is removed from preloadStore for ${style}`
);
assert.true(
PreloadStore.get("categories_list") === undefined,
assert.strictEqual(
PreloadStore.get("categories_list"),
undefined,
`topic_list is removed from preloadStore for ${style}`
);
});

View File

@ -16,7 +16,10 @@ acceptance("CategoryChooser", function (needs) {
await click("#create-topic");
await categoryChooser.expand();
assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized");
assert.notStrictEqual(
categoryChooser.rowByIndex(0).name(),
"uncategorized"
);
});
test("prefill category when category_id is set", async function (assert) {

View File

@ -20,7 +20,7 @@ acceptance("Composer - Edit conflict", function (needs) {
".d-editor-input",
"hello world hello world hello world hello world hello world"
);
assert.ok(!lastBody.includes("originalText"));
assert.false(lastBody.includes("originalText"));
});
test("Should send originalText when editing a reply", async function (assert) {
@ -31,6 +31,6 @@ acceptance("Composer - Edit conflict", function (needs) {
".d-editor-input",
"hello world hello world hello world hello world hello world"
);
assert.ok(lastBody.includes("originalText"));
assert.true(lastBody.includes("originalText"));
});
});

View File

@ -466,11 +466,12 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "enqueue this content please");
await click("#reply-control button.create");
assert.ok(
query(".topic-post:last-of-type .cooked p").innerText !==
assert
.dom(".topic-post:last-of-type .cooked p")
.doesNotIncludeText(
"enqueue this content please",
"it doesn't insert the post"
);
"doesn't insert the post"
);
assert.dom(".d-modal").exists("pops up a modal");
await click(".d-modal__footer button");

View File

@ -471,11 +471,7 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
"||a|b|\n|---|---|---|\n|1|2|3|\n",
"only the plain text table is pasted"
);
assert.strictEqual(
uppyEventFired,
false,
"uppy does not start uploading the file"
);
assert.false(uppyEventFired, "uppy does not start uploading the file");
done();
});
});

View File

@ -32,7 +32,7 @@ acceptance("Do not disturb", function (needs) {
assert.dom(".do-not-disturb-modal").exists("modal to choose time appears");
let tiles = queryAll(".do-not-disturb-tile");
assert.ok(tiles.length === 4, "There are 4 duration choices");
assert.strictEqual(tiles.length, 4, "There are 4 duration choices");
await click(tiles[0]);

View File

@ -98,8 +98,8 @@ acceptance("User notification schedule", function (needs) {
);
await selectKit(".day.Tuesday .ends-at .combobox").expand();
assert.ok(
!selectKit(".day.Tuesday .ends-at .combobox").rowByValue(1350).exists(),
assert.false(
selectKit(".day.Tuesday .ends-at .combobox").rowByValue(1350).exists(),
"End time options are limited to + 30 past start time"
);
});

View File

@ -113,8 +113,8 @@ module("Integration | Component | modal/dismiss-new", function (hooks) {
await click(".untrack [type='checkbox']");
await click("#dismiss-read-confirm");
assert.strictEqual(state.dismissTopics, false);
assert.strictEqual(state.dismissPosts, false);
assert.strictEqual(state.untrack, true);
assert.false(state.dismissTopics);
assert.false(state.dismissPosts);
assert.true(state.untrack);
});
});

View File

@ -72,7 +72,7 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
await render(hbs`<DMenu @inline={{true}} @onShow={{this.onShow}} />`);
await open();
assert.strictEqual(this.test, true);
assert.true(this.test);
});
test("@onClose", async function (assert) {
@ -83,7 +83,7 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
await open();
await close();
assert.strictEqual(this.test, true);
assert.true(this.test);
});
test("-expanded class", async function (assert) {

View File

@ -66,7 +66,7 @@ module("Integration | Component | FloatKit | d-tooltip", function (hooks) {
await hover();
assert.strictEqual(this.test, true);
assert.true(this.test);
});
test("@onClose", async function (assert) {
@ -77,7 +77,7 @@ module("Integration | Component | FloatKit | d-tooltip", function (hooks) {
await hover();
await close();
assert.strictEqual(this.test, true);
assert.true(this.test);
});
test("-expanded class", async function (assert) {

View File

@ -473,11 +473,10 @@ module("Integration | Component | plugin-outlet", function (hooks) {
1,
"console warn was called once"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `shouldDisplay` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the default message to the console"
);
});
@ -506,34 +505,30 @@ module("Integration | Component | plugin-outlet", function (hooks) {
1,
"console warn was called once"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
sinon.match(/The 'shouldDisplay' is deprecated on this test/)
),
true,
"logs the custom deprecation message to the console"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
sinon.match(
/deprecation id: discourse.plugin-connector.deprecated-arg.test/
)
),
true,
"logs custom deprecation id"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
sinon.match(/deprecated since Discourse 3.3.0.beta4-dev/)
),
true,
"logs deprecation since information"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
sinon.match(/removal in Discourse 3.4.0/)
),
true,
"logs dropFrom information"
);
});
@ -568,22 +563,20 @@ module("Integration | Component | plugin-outlet", function (hooks) {
1,
"console warn was called once"
);
assert.strictEqual(
assert.false(
this.consoleWarnStub.calledWith(
sinon.match(
/deprecation id: discourse.deprecation-that-should-not-be-logged/
)
),
false,
"does not log silence deprecation"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
sinon.match(
/deprecation id: discourse.plugin-connector.deprecated-arg/
)
),
true,
"logs expected deprecation"
);
});
@ -793,18 +786,16 @@ module(
2,
"console warn was called twice"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the expected message for @outletArgs.hello"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [used on connector discourse/plugins/some-plugin/templates/connectors/test-name/my-connector] [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the expected message for this.hello"
);
});
@ -827,18 +818,16 @@ module(
1,
"console warn was called once"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the expected message for @outletArgs.hello"
);
assert.strictEqual(
assert.false(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [used on connector discourse/plugins/some-plugin/templates/connectors/test-name/my-connector] [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
false,
"does not log the message for this.hello"
);
});
@ -867,18 +856,16 @@ module(
2,
"console warn was called twice"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the expected message for @outletArgs.hello"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [used on connector discourse/plugins/some-plugin/connectors/test-name/my-connector] [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the expected message for this.hello"
);
});
@ -906,18 +893,16 @@ module(
2,
"console warn was called twice"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the expected message for @outletArgs.hello"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the expected message for this.hello"
);
});
@ -941,11 +926,10 @@ module(
1,
"console warn was called twice"
);
assert.strictEqual(
assert.true(
this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]"
),
true,
"logs the expected message for @outletArgs.hello"
);
});

View File

@ -43,10 +43,10 @@ module("Integration | Component | text-field", function (hooks) {
);
await fillIn(".tf-test", "hello");
assert.ok(!this.called);
assert.false(this.called);
await fillIn(".tf-test", "new text");
assert.ok(this.called);
assert.true(this.called);
assert.strictEqual(this.newValue, "new text");
});
@ -64,10 +64,10 @@ module("Integration | Component | text-field", function (hooks) {
);
await fillIn(".tf-test", "old");
assert.ok(!this.called);
assert.false(this.called);
await fillIn(".tf-test", "no longer old");
assert.ok(this.called);
assert.true(this.called);
assert.strictEqual(this.newValue, "no longer old");
});
});

View File

@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Component | topic-list-item", function (hooks) {
setupRenderingTest(hooks);
@ -31,8 +30,8 @@ module("Integration | Component | topic-list-item", function (hooks) {
/>
`);
const checkboxes = queryAll("input.bulk-select");
assert.ok(checkboxes[0].checked);
assert.ok(!checkboxes[1].checked);
const checkboxes = [...document.querySelectorAll("input.bulk-select")];
assert.dom(checkboxes[0]).isChecked();
assert.dom(checkboxes[1]).isNotChecked();
});
});

View File

@ -4,12 +4,7 @@ import { click, render, triggerEvent } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import {
count,
exists,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { count, query, queryAll } from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n";
module(
@ -49,8 +44,8 @@ module(
@model={{this.post}}
@args={{this.args}} />`);
assert.ok(exists(".names"), "includes poster name");
assert.ok(exists("a.post-date"), "includes post date");
assert.dom(".names").exists("includes poster name");
assert.dom("a.post-date").exists("includes post date");
});
test("post - links", async function (assert) {
@ -161,6 +156,7 @@ module(
});
test("via-email without permission", async function (assert) {
this.rawEmailShown = false;
this.set("args", { via_email: true, canViewRawEmail: false });
this.set("showRawEmail", () => (this.rawEmailShown = true));
@ -170,8 +166,8 @@ module(
);
await click(".post-info.via-email");
assert.ok(
!this.rawEmailShown,
assert.false(
this.rawEmailShown,
"clicking the envelope doesn't show the raw email"
);
});
@ -190,6 +186,7 @@ module(
});
test("history without view permission", async function (assert) {
this.historyShown = false;
this.set("args", { version: 3, canViewEditHistory: false });
this.set("showHistory", () => (this.historyShown = true));
@ -199,8 +196,8 @@ module(
);
await click(".post-info.edits");
assert.ok(
!this.historyShown,
assert.false(
this.historyShown,
`clicking the pencil doesn't show the history`
);
});
@ -221,7 +218,7 @@ module(
await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`);
assert.ok(exists(".read-state.read"));
assert.dom(".read-state.read").exists();
});
test(`unread indicator`, async function (assert) {
@ -230,7 +227,7 @@ module(
await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`);
assert.ok(exists(".read-state"));
assert.dom(".read-state").exists();
});
test("reply directly above (suppressed)", async function (assert) {
@ -243,8 +240,8 @@ module(
await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`);
assert.ok(!exists("a.reply-to-tab"), "hides the tab");
assert.ok(!exists(".avoid-tab"), "doesn't have the avoid tab class");
assert.dom("a.reply-to-tab").doesNotExist("hides the tab");
assert.dom(".avoid-tab").doesNotExist("doesn't have the avoid tab class");
});
test("reply a few posts above (suppressed)", async function (assert) {
@ -257,7 +254,7 @@ module(
await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`);
assert.ok(exists("a.reply-to-tab"), "shows the tab");
assert.dom("a.reply-to-tab").exists("shows the tab");
assert.strictEqual(count(".avoid-tab"), 1, "has the avoid tab class");
});
@ -300,10 +297,9 @@ module(
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} @expandHidden={{this.expandHidden}} />`
);
assert.ok(
!exists(".topic-body .expand-hidden"),
"button is not displayed"
);
assert
.dom(".topic-body .expand-hidden")
.doesNotExist("button is not displayed");
});
test("expand first post", async function (assert) {
@ -315,7 +311,7 @@ module(
);
await click(".topic-body .expand-post");
assert.ok(!exists(".expand-post"), "button is gone");
assert.dom(".expand-post").doesNotExist("button is gone");
});
test("can't show admin menu when you can't manage", async function (assert) {
@ -324,7 +320,7 @@ module(
await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`);
assert.ok(!exists(".post-menu-area .show-post-admin-menu"));
assert.dom(".post-menu-area .show-post-admin-menu").doesNotExist();
});
test("show admin menu", async function (assert) {
@ -784,7 +780,7 @@ module(
await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`);
assert.ok(exists(".user-status-message"));
assert.dom(".user-status-message").exists();
});
test("doesn't show user status if disabled in site settings", async function (assert) {
@ -800,7 +796,7 @@ module(
await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`);
assert.notOk(exists(".user-status-message"));
assert.dom(".user-status-message").doesNotExist();
});
}
);

View File

@ -133,6 +133,7 @@ module("Integration | Component | Widget | post", function (hooks) {
});
test("via-email without permission", async function (assert) {
this.rawEmailShown = false;
this.set("args", { via_email: true, canViewRawEmail: false });
this.set("showRawEmail", () => (this.rawEmailShown = true));
@ -142,8 +143,8 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".post-info.via-email");
assert.ok(
!this.rawEmailShown,
assert.false(
this.rawEmailShown,
"clicking the envelope doesn't show the raw email"
);
});
@ -162,6 +163,7 @@ module("Integration | Component | Widget | post", function (hooks) {
});
test("history without view permission", async function (assert) {
this.historyShown = false;
this.set("args", { version: 3, canViewEditHistory: false });
this.set("showHistory", () => (this.historyShown = true));
@ -171,9 +173,9 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".post-info.edits");
assert.ok(
!this.historyShown,
`clicking the pencil doesn't show the history`
assert.false(
this.historyShown,
"clicking the pencil doesn't show the history"
);
});

View File

@ -62,9 +62,8 @@ module("Unit | Controller | admin-customize-themes-show", function (hooks) {
"controller:admin-customize-themes-show"
);
controller.setProperties({ model: theme });
assert.deepEqual(
assert.true(
controller.hasSettings,
true,
"sets the hasSettings property to true with settings"
);
});
@ -80,9 +79,8 @@ module("Unit | Controller | admin-customize-themes-show", function (hooks) {
"controller:admin-customize-themes-show"
);
controller.setProperties({ model: theme });
assert.deepEqual(
assert.false(
controller.hasSettings,
false,
"sets the hasSettings property to true with settings"
);
});

View File

@ -23,15 +23,15 @@ module("Unit | Controller | preferences/account", function (hooks) {
},
});
assert.strictEqual(controller.canUpdateAssociatedAccounts, false);
assert.false(controller.canUpdateAssociatedAccounts);
controller.set("model.second_factor_enabled", false);
assert.strictEqual(controller.canUpdateAssociatedAccounts, false);
assert.false(controller.canUpdateAssociatedAccounts);
controller.set("model.is_anonymous", false);
assert.strictEqual(controller.canUpdateAssociatedAccounts, false);
assert.false(controller.canUpdateAssociatedAccounts);
controller.set("model.id", 1234);
assert.strictEqual(controller.canUpdateAssociatedAccounts, true);
assert.true(controller.canUpdateAssociatedAccounts);
});
});

View File

@ -12,6 +12,6 @@ module("Unit | Controller | preferences/second-factor", function (hooks) {
"controller:preferences/second-factor"
);
assert.strictEqual(controller.displayOAuthWarning, true);
assert.true(controller.displayOAuthWarning);
});
});

View File

@ -18,10 +18,7 @@ module("Unit | Controller | user-notifications", function (hooks) {
await controller.markRead();
assert.strictEqual(
model.every(({ read }) => read === true),
true
);
assert.true(model.every(({ read }) => read === true));
});
test("Mark read does not mark models read when response is not successful", async function (assert) {
@ -56,6 +53,6 @@ module("Unit | Controller | user-notifications", function (hooks) {
controller.send("resetNew");
assert.strictEqual(markRead, true);
assert.true(markRead);
});
});

View File

@ -8,16 +8,17 @@ module("Unit | Utility | allowLister", function (hooks) {
test("allowLister", function (assert) {
const allowLister = new AllowLister();
assert.ok(
assert.true(
Object.keys(allowLister.getAllowList().tagList).length > 1,
"should have some defaults"
"has some defaults"
);
allowLister.disable("default");
assert.ok(
Object.keys(allowLister.getAllowList().tagList).length === 0,
"should have no defaults if disabled"
assert.strictEqual(
Object.keys(allowLister.getAllowList().tagList).length,
0,
"has no defaults if disabled"
);
allowLister.allowListFeature("test", [

View File

@ -56,11 +56,11 @@ module("Unit | Utility | category-badge", function (hooks) {
const store = getOwner(this).lookup("service:store");
const category = store.createRecord("category", { name: "hello", id: 123 });
assert.ok(
!categoryBadgeHTML(category).includes("topic-count"),
assert.notOk(
categoryBadgeHTML(category).includes("topic-count"),
"it does not include topic count by default"
);
assert.ok(
assert.true(
categoryBadgeHTML(category, { topicCount: 20 }).indexOf("topic-count") >
20,
"is included when specified"
@ -137,21 +137,21 @@ module("Unit | Utility | category-badge", function (hooks) {
});
siteSettings.max_category_nesting = 0;
assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));
assert.ok(!categoryBadgeHTML(baz, { recursive: true }).includes("bar"));
assert.true(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));
assert.false(categoryBadgeHTML(baz, { recursive: true }).includes("bar"));
siteSettings.max_category_nesting = 1;
assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));
assert.ok(!categoryBadgeHTML(baz, { recursive: true }).includes("bar"));
assert.true(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));
assert.false(categoryBadgeHTML(baz, { recursive: true }).includes("bar"));
siteSettings.max_category_nesting = 2;
assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));
assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("bar"));
assert.ok(!categoryBadgeHTML(baz, { recursive: true }).includes("foo"));
assert.true(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));
assert.true(categoryBadgeHTML(baz, { recursive: true }).includes("bar"));
assert.false(categoryBadgeHTML(baz, { recursive: true }).includes("foo"));
siteSettings.max_category_nesting = 3;
assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));
assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("bar"));
assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("foo"));
assert.true(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));
assert.true(categoryBadgeHTML(baz, { recursive: true }).includes("bar"));
assert.true(categoryBadgeHTML(baz, { recursive: true }).includes("foo"));
});
});

View File

@ -26,7 +26,7 @@ function testOpenInANewTab(description, clickEventModifier) {
const clickEvent = generateClickEventOn("a");
clickEventModifier(clickEvent);
assert.true(track(clickEvent));
assert.strictEqual(clickEvent.defaultPrevented, false);
assert.false(clickEvent.defaultPrevented);
});
}

View File

@ -32,9 +32,10 @@ module("Unit | Utility | computed", function (hooks) {
"airplane",
"it has the value of the site setting"
);
assert.ok(
!t.missingProp,
"it is falsy when the site setting is not defined"
assert.strictEqual(
t.missingProp,
undefined,
"is falsy when the site setting is not defined"
);
});
@ -47,9 +48,9 @@ module("Unit | Utility | computed", function (hooks) {
biscuits: 10,
});
assert.ok(t.same, "it is true when the properties are the same");
assert.true(t.same, "is true when the properties are the same");
t.set("biscuits", 9);
assert.ok(!t.same, "it isn't true when one property is different");
assert.false(t.same, "isn't true when one property is different");
});
test("propertyNotEqual", function (assert) {
@ -61,9 +62,9 @@ module("Unit | Utility | computed", function (hooks) {
biscuits: 10,
});
assert.ok(!t.diff, "it isn't true when the properties are the same");
assert.false(t.diff, "isn't true when the properties are the same");
t.set("biscuits", 9);
assert.ok(t.diff, "it is true when one property is different");
assert.true(t.diff, "is true when one property is different");
});
test("fmt", function (assert) {

View File

@ -15,9 +15,9 @@ module("Unit | Utility | get-url", function (hooks) {
test("isAbsoluteURL", function (assert) {
setupURL(null, "https://example.com", "/forum");
assert.ok(isAbsoluteURL("https://example.com/test/thing"));
assert.ok(!isAbsoluteURL("http://example.com/test/thing"));
assert.ok(!isAbsoluteURL("https://discourse.org/test/thing"));
assert.true(isAbsoluteURL("https://example.com/test/thing"));
assert.false(isAbsoluteURL("http://example.com/test/thing"));
assert.false(isAbsoluteURL("https://discourse.org/test/thing"));
});
test("getAbsoluteURL", function (assert) {

View File

@ -11,7 +11,7 @@ module("Unit | Utility | icon-library", function (hooks) {
setupTest(hooks);
test("return icon markup", function (assert) {
assert.ok(iconHTML("bars").includes('use href="#bars"'));
assert.true(iconHTML("bars").includes('use href="#bars"'));
const nodeIcon = iconNode("bars");
assert.strictEqual(nodeIcon.tagName, "svg");
@ -23,10 +23,10 @@ module("Unit | Utility | icon-library", function (hooks) {
test("convert icon names", function (assert) {
const faIcon = convertIconClass("fab fa-facebook");
assert.ok(iconHTML(faIcon).includes("fab-facebook"), "FA syntax");
assert.true(iconHTML(faIcon).includes("fab-facebook"), "FA syntax");
const iconC = convertIconClass(" fab fa-facebook ");
assert.ok(!iconHTML(iconC).includes(" "), "trims whitespace");
assert.false(iconHTML(iconC).includes(" "), "trims whitespace");
});
test("escape icon names, classes, titles and aria-label", function (assert) {
@ -36,15 +36,15 @@ module("Unit | Utility | icon-library", function (hooks) {
class: "'<link href='w'>",
"aria-label": "<script>alert(1)",
});
assert.ok(html.includes("&#x27;&lt;img src=&#x27;x&#x27;&gt;"));
assert.ok(html.includes("&#x27;&lt;script src=&#x27;y&#x27;&gt;"));
assert.ok(html.includes("&lt;iframe src=&#x27;z&#x27;&gt;"));
assert.ok(html.includes("&#x27;&lt;link href=&#x27;w&#x27;&gt;"));
assert.true(html.includes("&#x27;&lt;img src=&#x27;x&#x27;&gt;"));
assert.true(html.includes("&#x27;&lt;script src=&#x27;y&#x27;&gt;"));
assert.true(html.includes("&lt;iframe src=&#x27;z&#x27;&gt;"));
assert.true(html.includes("&#x27;&lt;link href=&#x27;w&#x27;&gt;"));
html = iconHTML("'<img src='x'>", {
"aria-label": "<script>alert(1)",
});
assert.ok(html.includes("aria-label='&lt;script&gt;alert(1)'"));
assert.true(html.includes("aria-label='&lt;script&gt;alert(1)'"));
});
test("fa5 remaps", function (assert) {

View File

@ -15,9 +15,8 @@ module(
createDownloadLink(lightboxItem);
assert.strictEqual(
assert.true(
createElementSpy.calledWith("a"),
true,
"creates an anchor element"
);
@ -33,7 +32,7 @@ module(
"sets the correct download attribute"
);
assert.strictEqual(clickStub.called, true, "clicks the link element");
assert.true(clickStub.called, "clicks the link element");
createElementSpy.restore();
clickStub.restore();

View File

@ -50,14 +50,13 @@ module(
"returns 'DOWN' for swipes with a large positive y-axis difference"
);
assert.strictEqual(
assert.false(
getSwipeDirection({
touchstartX: 50,
touchstartY: 50,
touchendX: 49,
touchendY: 49,
}),
false,
"returns 'false' for swipes with a small x-axis difference and a small y-axis difference"
);
});

View File

@ -14,9 +14,8 @@ module(
await openImageInNewTab(lightboxItem);
assert.strictEqual(
assert.true(
openStub.calledWith("image.jpg", "_blank"),
true,
"calls window.open with the correct arguments"
);
@ -33,11 +32,7 @@ module(
await openImageInNewTab(lightboxItem);
assert.strictEqual(
consoleErrorStub.called,
true,
"logs an error to the console"
);
assert.true(consoleErrorStub.called, "logs an error to the console");
openStub.restore();
consoleErrorStub.restore();

View File

@ -8,7 +8,6 @@ import { cloneJSON } from "discourse-common/lib/object";
module(
"Unit | lib | Experimental Lightbox | Helpers | preloadItemImages()",
function () {
const baseLightboxItem = generateLightboxObject().items[0];
@ -17,9 +16,9 @@ module(
const result = await preloadItemImages(lightboxItem);
assert.ok(result.isLoaded, "isLoaded should be true");
assert.true(result.isLoaded, "isLoaded should be true");
assert.ok(!result.hasLoadingError, "hasLoadingError should be false");
assert.false(result.hasLoadingError, "hasLoadingError should be false");
assert.strictEqual(
result.width,
@ -39,7 +38,7 @@ module(
"aspectRatio should be equal to image width/height"
);
assert.ok(
assert.true(
result.canZoom,
"canZoom should be true if fullsizeImage width or height is greater than window inner width or height"
);
@ -53,9 +52,8 @@ module(
const result = await preloadItemImages(lightboxItem);
assert.strictEqual(
assert.true(
result.hasLoadingError,
true,
"sets hasLoadingError to true if there is an error"
);
});

View File

@ -19,10 +19,9 @@ module(
const themeColor = await getSiteThemeColor();
assert.strictEqual(
assert.true(
querySelectorSpy.calledWith('meta[name="theme-color"]'),
true,
"Queries the correct element"
"queries the correct element"
);
assert.strictEqual(
@ -40,9 +39,8 @@ module(
await setSiteThemeColor("0000ff");
assert.strictEqual(
assert.true(
querySelectorSpy.calledWith('meta[name="theme-color"]'),
true,
"queries the correct element"
);

View File

@ -24,9 +24,8 @@ module("Unit | Utility | oneboxer", function (hooks) {
await loadOnebox(element);
assert.strictEqual(
assert.true(
failedCache["http://somebadurl.com"],
true,
"stores the url as failed in a cache"
);
assert.strictEqual(

View File

@ -63,6 +63,6 @@ module("Unit | Utility | preload-store", function (hooks) {
const result = await PreloadStore.getAndRemove("falsy", () =>
assert.ok(false)
);
assert.strictEqual(result, false);
assert.false(result);
});
});

View File

@ -60,13 +60,13 @@ module("Unit | Utility | pretty-text", function (hooks) {
setupTest(hooks);
test("buildOptions", function (assert) {
assert.ok(
assert.true(
build({ siteSettings: { enable_emoji: true } }).options.discourse.features
.emoji,
"emoji enabled"
);
assert.ok(
!build({ siteSettings: { enable_emoji: false } }).options.discourse
assert.false(
build({ siteSettings: { enable_emoji: false } }).options.discourse
.features.emoji,
"emoji disabled"
);
@ -74,51 +74,51 @@ module("Unit | Utility | pretty-text", function (hooks) {
build({ siteSettings: { allowed_iframes: "https://example.com/" } })
.options.discourse.allowedIframes,
["https://example.com/"],
"it doesn't filter out valid urls"
"doesn't filter out valid urls"
);
assert.deepEqual(
build({ siteSettings: { allowed_iframes: "https://example.com" } })
.options.discourse.allowedIframes,
[],
"it filters out invalid urls. Requires 3 slashes."
"filters out invalid urls. Requires 3 slashes"
);
});
test("basic cooking", function (assert) {
assert.cooked("hello", "<p>hello</p>", "surrounds text with paragraphs");
assert.cooked("**evil**", "<p><strong>evil</strong></p>", "it bolds text.");
assert.cooked("__bold__", "<p><strong>bold</strong></p>", "it bolds text.");
assert.cooked("*trout*", "<p><em>trout</em></p>", "it italicizes text.");
assert.cooked("_trout_", "<p><em>trout</em></p>", "it italicizes text.");
assert.cooked("**evil**", "<p><strong>evil</strong></p>", "bolds text");
assert.cooked("__bold__", "<p><strong>bold</strong></p>", "bolds text");
assert.cooked("*trout*", "<p><em>trout</em></p>", "italicizes text");
assert.cooked("_trout_", "<p><em>trout</em></p>", "italicizes text");
assert.cooked(
"***hello***",
"<p><em><strong>hello</strong></em></p>",
"it can do bold and italics at once."
"can do bold and italics at once"
);
assert.cooked(
"word_with_underscores",
"<p>word_with_underscores</p>",
"it doesn't do intraword italics"
"doesn't do intraword italics"
);
assert.cooked(
"common/_special_font_face.html.erb",
"<p>common/_special_font_face.html.erb</p>",
"it doesn't intraword with a slash"
"doesn't intraword with a slash"
);
assert.cooked(
"hello \\*evil\\*",
"<p>hello *evil*</p>",
"it supports escaping of asterisks"
"supports escaping of asterisks"
);
assert.cooked(
"hello \\_evil\\_",
"<p>hello _evil_</p>",
"it supports escaping of italics"
"supports escaping of italics"
);
assert.cooked(
"brussels sprouts are *awful*.",
"<p>brussels sprouts are <em>awful</em>.</p>",
"it doesn't swallow periods."
"doesn't swallow periods"
);
});
@ -126,7 +126,7 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked(
"*this is italic **with some bold** inside*",
"<p><em>this is italic <strong>with some bold</strong> inside</em></p>",
"it handles nested bold in italics"
"handles nested bold in italics"
);
});
@ -155,7 +155,7 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked(
"[] first choice\n[] second choice",
"<p>[] first choice<br>\n[] second choice</p>",
"it handles new lines correctly with [] options"
"handles new lines correctly with [] options"
);
// note this is a change from previous engine but is correct
@ -165,13 +165,13 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked(
"<blockquote>evil</blockquote>\ntrout",
"<blockquote>evil</blockquote>\ntrout",
"it doesn't insert <br> after blockquotes"
"doesn't insert <br> after blockquotes"
);
assert.cooked(
"leading<blockquote>evil</blockquote>\ntrout",
"<p>leading<blockquote>evil</blockquote><br>\ntrout</p>",
"it doesn't insert <br> after blockquotes with leading text"
"doesn't insert <br> after blockquotes with leading text"
);
});
@ -179,22 +179,22 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked(
"<div>hello world</div>",
"<div>hello world</div>",
"it doesn't surround <div> with paragraphs"
"doesn't surround <div> with paragraphs"
);
assert.cooked(
"<p>hello world</p>",
"<p>hello world</p>",
"it doesn't surround <p> with paragraphs"
"doesn't surround <p> with paragraphs"
);
assert.cooked(
"<i>hello world</i>",
"<p><i>hello world</i></p>",
"it surrounds inline <i> html tags with paragraphs"
"surrounds inline <i> html tags with paragraphs"
);
assert.cooked(
"<b>hello world</b>",
"<p><b>hello world</b></p>",
"it surrounds inline <b> html tags with paragraphs"
"surrounds inline <b> html tags with paragraphs"
);
});
@ -263,31 +263,31 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked(
"Here's a tweet:\nhttps://twitter.com/evil_trout/status/345954894420787200",
'<p>Here\'s a tweet:<br>\n<a href="https://twitter.com/evil_trout/status/345954894420787200" class="onebox" target="_blank">https://twitter.com/evil_trout/status/345954894420787200</a></p>',
"It doesn't strip the new line."
"doesn't strip the new line"
);
assert.cooked(
"1. View @eviltrout's profile here: http://meta.discourse.org/u/eviltrout/activity<br/>next line.",
`<ol>\n<li>View <span class="mention">@eviltrout</span>\'s profile here: <a href="http://meta.discourse.org/u/eviltrout/activity" class="inline-onebox-loading">http://meta.discourse.org/u/eviltrout/activity</a><br>next line.</li>\n</ol>`,
"allows autolinking within a list without inserting a paragraph."
"allows autolinking within a list without inserting a paragraph"
);
assert.cooked(
"[3]: http://eviltrout.com",
"",
"It doesn't autolink markdown link references"
"doesn't autolink markdown link references"
);
assert.cooked(
"[]: http://eviltrout.com",
'<p>[]: <a href="http://eviltrout.com">http://eviltrout.com</a></p>',
"It doesn't accept empty link references"
"doesn't accept empty link references"
);
assert.cooked(
"[b]label[/b]: description",
'<p><span class="bbcode-b">label</span>: description</p>',
"It doesn't accept BBCode as link references"
"doesn't accept BBCode as link references"
);
assert.cooked(
@ -307,7 +307,7 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked(
"User [MOD]: Hello!",
"<p>User [MOD]: Hello!</p>",
"It does not consider references that are obviously not URLs"
"does not consider references that are obviously not URLs"
);
assert.cooked(
@ -319,31 +319,31 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked(
"[http://google.com ... wat](http://discourse.org)",
'<p><a href="http://discourse.org">http://google.com ... wat</a></p>',
"it supports links within links"
"supports links within links"
);
assert.cooked(
"[http://google.com](http://discourse.org)",
'<p><a href="http://discourse.org">http://google.com</a></p>',
"it supports markdown links where the name and link match"
"supports markdown links where the name and link match"
);
assert.cooked(
'[Link](http://www.example.com) (with an outer "description")',
'<p><a href="http://www.example.com">Link</a> (with an outer &quot;description&quot;)</p>',
"it doesn't consume closing parens as part of the url"
"doesn't consume closing parens as part of the url"
);
assert.cooked(
"A link inside parentheses (http://www.example.com)",
'<p>A link inside parentheses (<a href="http://www.example.com">http://www.example.com</a>)</p>',
"it auto-links a url within parentheses"
"auto-links a url within parentheses"
);
assert.cooked(
"[ul][1]\n\n[1]: http://eviltrout.com",
'<p><a href="http://eviltrout.com">ul</a></p>',
"it can use `ul` as a link name"
"can use `ul` as a link name"
);
});
@ -351,22 +351,22 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked(
"> nice!",
"<blockquote>\n<p>nice!</p>\n</blockquote>",
"it supports simple quotes"
"supports simple quotes"
);
assert.cooked(
" > nice!",
"<blockquote>\n<p>nice!</p>\n</blockquote>",
"it allows quotes with preceding spaces"
"allows quotes with preceding spaces"
);
assert.cooked(
"> level 1\n> > level 2",
"<blockquote>\n<p>level 1</p>\n<blockquote>\n<p>level 2</p>\n</blockquote>\n</blockquote>",
"it allows nesting of blockquotes"
"allows nesting of blockquotes"
);
assert.cooked(
"> level 1\n> > level 2",
"<blockquote>\n<p>level 1</p>\n<blockquote>\n<p>level 2</p>\n</blockquote>\n</blockquote>",
"it allows nesting of blockquotes with spaces"
"allows nesting of blockquotes with spaces"
);
assert.cooked(
@ -380,13 +380,13 @@ eviltrout</p>
</blockquote>
</li>
</ul>`,
"it allows quotes within a list."
"allows quotes within a list"
);
assert.cooked(
"- <p>eviltrout</p>",
"<ul>\n<li>\n<p>eviltrout</p></li>\n</ul>",
"it allows paragraphs within a list."
"allows paragraphs within a list"
);
assert.cooked(
@ -459,19 +459,19 @@ eviltrout</p>
assert.cooked(
"[quote]\ntest\n[/quote]",
'<aside class="quote no-group">\n<blockquote>\n<p>test</p>\n</blockquote>\n</aside>',
"it supports quotes without params"
"supports quotes without params"
);
assert.cooked(
"[quote]\n*test*\n[/quote]",
'<aside class="quote no-group">\n<blockquote>\n<p><em>test</em></p>\n</blockquote>\n</aside>',
"it doesn't insert a new line for italics"
"doesn't insert a new line for italics"
);
assert.cooked(
"[quote=,script='a'><script>alert('test');//':a]\n[/quote]",
'<aside class="quote no-group">\n<blockquote></blockquote>\n</aside>',
"It will not create a script tag within an attribute"
"will not create a script tag within an attribute"
);
});
@ -498,13 +498,13 @@ eviltrout</p>
assert.cooked(
"[@codinghorror](https://twitter.com/codinghorror)",
'<p><a href="https://twitter.com/codinghorror">@codinghorror</a></p>',
"it doesn't do mentions within links"
"doesn't do mentions within links"
);
assert.cooked(
"[@codinghorror](https://twitter.com/codinghorror)",
'<p><a href="https://twitter.com/codinghorror">@codinghorror</a></p>',
"it doesn't do link mentions within links"
"doesn't do link mentions within links"
);
assert.cooked(
@ -528,13 +528,13 @@ eviltrout</p>
assert.cooked(
"@EvilTrout yo",
'<p><span class="mention">@EvilTrout</span> yo</p>',
"it handles mentions at the beginning of a string"
"handles mentions at the beginning of a string"
);
assert.cooked(
"yo\n@EvilTrout",
'<p>yo<br>\n<span class="mention">@EvilTrout</span></p>',
"it handles mentions at the beginning of a new line"
"handles mentions at the beginning of a new line"
);
assert.cooked(
@ -546,7 +546,7 @@ eviltrout</p>
assert.cooked(
"```\na @test\n```",
'<pre><code class="lang-auto">a @test\n</code></pre>',
"should not do mentions within a code block."
"should not do mentions within a code block"
);
assert.cooked(
@ -588,44 +588,44 @@ eviltrout</p>
assert.cooked(
"@eviltrout and `@eviltrout`",
'<p><span class="mention">@eviltrout</span> and <code>@eviltrout</code></p>',
"you can have a mention in an inline code block following a real mention."
"you can have a mention in an inline code block following a real mention"
);
assert.cooked(
"1. this is a list\n\n2. this is an @eviltrout mention\n",
'<ol>\n<li>\n<p>this is a list</p>\n</li>\n<li>\n<p>this is an <span class="mention">@eviltrout</span> mention</p>\n</li>\n</ol>',
"it mentions properly in a list."
"mentions properly in a list"
);
assert.cooked(
"Hello @foo/@bar",
'<p>Hello <span class="mention">@foo</span>/<span class="mention">@bar</span></p>',
"handles mentions separated by a slash."
"handles mentions separated by a slash"
);
assert.cooked(
"<small>a @sam c</small>",
'<p><small>a <span class="mention">@sam</span> c</small></p>',
"it allows mentions within HTML tags"
"allows mentions within HTML tags"
);
assert.cooked(
"@_sam @1sam @ab-cd.123_ABC-xYz @sam1",
'<p><span class="mention">@_sam</span> <span class="mention">@1sam</span> <span class="mention">@ab-cd.123_ABC-xYz</span> <span class="mention">@sam1</span></p>',
"it detects mentions of valid usernames"
"detects mentions of valid usernames"
);
assert.cooked(
"@.sam @-sam @sam. @sam_ @sam-",
'<p>@.sam @-sam <span class="mention">@sam</span>. <span class="mention">@sam</span>_ <span class="mention">@sam</span>-</p>',
"it does not detect mentions of invalid usernames"
"does not detect mentions of invalid usernames"
);
assert.cookedOptions(
"Hello @狮子",
{ siteSettings: { unicode_usernames: false } },
"<p>Hello @狮子</p>",
"it does not detect mentions of Unicode usernames"
"does not detect mentions of Unicode usernames"
);
});
@ -634,21 +634,21 @@ eviltrout</p>
"Hello @狮子",
{ siteSettings: { unicode_usernames: true } },
'<p>Hello <span class="mention">@狮子</span></p>',
"it detects mentions of Unicode usernames"
"detects mentions of Unicode usernames"
);
assert.cookedOptions(
"@狮子 @_狮子 @1狮子 @狮-ø.١٢٣_Ö-ழ் @狮子1",
{ siteSettings: { unicode_usernames: true } },
'<p><span class="mention">@狮子</span> <span class="mention">@_狮子</span> <span class="mention">@1狮子</span> <span class="mention">@狮-ø.١٢٣_Ö-ழ்</span> <span class="mention">@狮子1</span></p>',
"it detects mentions of valid Unicode usernames"
"detects mentions of valid Unicode usernames"
);
assert.cookedOptions(
"@.狮子 @-狮子 @狮子. @狮子_ @狮子-",
{ siteSettings: { unicode_usernames: true } },
'<p>@.狮子 @-狮子 <span class="mention">@狮子</span>. <span class="mention">@狮子</span>_ <span class="mention">@狮子</span>-</p>',
"it does not detect mentions of invalid Unicode usernames"
"does not detect mentions of invalid Unicode usernames"
);
});
@ -664,7 +664,7 @@ eviltrout</p>
assert.cooked(
"**Bold**\n----------",
'<h2><a name="bold-1" class="anchor" href="#bold-1"></a><strong>Bold</strong></h2>',
"It will bold the heading"
"will bold the heading"
);
});
@ -674,7 +674,7 @@ eviltrout</p>
'<h1><a name="one-1" class="anchor" href="#one-1"></a>One</h1>\n' +
'<h1><a name="h-1-2" class="anchor" href="#h-1-2"></a>1</h1>\n' +
'<h1><a name="h-3" class="anchor" href="#h-3"></a>$$</h1>',
"It will bold the heading"
"will bold the heading"
);
});
@ -745,47 +745,47 @@ eviltrout</p>
assert.cooked(
"_abc\ndef_",
"<p><em>abc<br>\ndef</em></p>",
"it does allow inlines to span new lines"
"does allow inlines to span new lines"
);
assert.cooked(
"_abc\n\ndef_",
"<p>_abc</p>\n<p>def_</p>",
"it does not allow inlines to span new paragraphs"
"does not allow inlines to span new paragraphs"
);
});
test("Oneboxing", function (assert) {
function matches(input, regexp) {
return build().cook(input).match(regexp);
return !!build().cook(input).match(regexp);
}
assert.ok(
!matches(
assert.false(
matches(
"- http://www.textfiles.com/bbs/MINDVOX/FORUMS/ethics\n\n- http://drupal.org",
/class="onebox"/
),
"doesn't onebox a link within a list"
);
assert.ok(
assert.true(
matches("http://test.com", /class="onebox"/),
"adds a onebox class to a link on its own line"
);
assert.ok(
assert.true(
matches("http://test.com\nhttp://test2.com", /onebox[\s\S]+onebox/m),
"supports multiple links"
);
assert.ok(
!matches("http://test.com bob", /onebox/),
assert.false(
matches("http://test.com bob", /onebox/),
"doesn't onebox links that have trailing text"
);
assert.ok(
!matches("[Tom Cruise](http://www.tomcruise.com/)", "onebox"),
assert.false(
matches("[Tom Cruise](http://www.tomcruise.com/)", "onebox"),
"Markdown links with labels are not oneboxed"
);
assert.ok(
!matches(
assert.false(
matches(
"[http://www.tomcruise.com/](http://www.tomcruise.com/)",
"onebox"
),
@ -804,7 +804,7 @@ eviltrout</p>
assert.cooked(
"[http://eviltrout.com][1] is a url\n\n[1]: http://eviltrout.com",
'<p><a href="http://eviltrout.com">http://eviltrout.com</a> is a url</p>',
"it supports links that are full URLs"
"supports links that are full URLs"
);
});
@ -818,37 +818,37 @@ eviltrout</p>
assert.cooked(
"```\na\nb\nc\n\nd\n```",
'<pre><code class="lang-auto">a\nb\nc\n\nd\n</code></pre>',
"it treats new lines properly"
"treats new lines properly"
);
assert.cooked(
"```\ntest\n```",
'<pre><code class="lang-auto">test\n</code></pre>',
"it supports basic code blocks"
"supports basic code blocks"
);
assert.cooked(
"```json\n{hello: 'world'}\n```\ntrailing",
'<pre data-code-wrap="json"><code class="lang-json">{hello: \'world\'}\n</code></pre>\n<p>trailing</p>',
"It does not truncate text after a code block."
"does not truncate text after a code block"
);
assert.cooked(
"```json\nline 1\n\nline 2\n\n\nline3\n```",
'<pre data-code-wrap="json"><code class="lang-json">line 1\n\nline 2\n\n\nline3\n</code></pre>',
"it maintains new lines inside a code block."
"maintains new lines inside a code block"
);
assert.cooked(
"hello\nworld\n```json\nline 1\n\nline 2\n\n\nline3\n```",
'<p>hello<br>\nworld</p>\n<pre data-code-wrap="json"><code class="lang-json">line 1\n\nline 2\n\n\nline3\n</code></pre>',
"it maintains new lines inside a code block with leading content."
"maintains new lines inside a code block with leading content"
);
assert.cooked(
"```ruby\n<header>hello</header>\n```",
'<pre data-code-wrap="ruby"><code class="lang-ruby">&lt;header&gt;hello&lt;/header&gt;\n</code></pre>',
"it escapes code in the code block"
"escapes code in the code block"
);
assert.cooked(
@ -860,7 +860,7 @@ eviltrout</p>
assert.cooked(
"```ruby\n# cool\n```",
'<pre data-code-wrap="ruby"><code class="lang-ruby"># cool\n</code></pre>',
"it supports changing the language"
"supports changing the language"
);
assert.cooked(
@ -872,61 +872,61 @@ eviltrout</p>
assert.cooked(
"```ruby\ndef self.parse(text)\n\n text\nend\n```",
'<pre data-code-wrap="ruby"><code class="lang-ruby">def self.parse(text)\n\n text\nend\n</code></pre>',
"it allows leading spaces on lines in a code block."
"allows leading spaces on lines in a code block"
);
assert.cooked(
"```ruby\nhello `eviltrout`\n```",
'<pre data-code-wrap="ruby"><code class="lang-ruby">hello `eviltrout`\n</code></pre>',
"it allows code with backticks in it"
"allows code with backticks in it"
);
assert.cooked(
"```eviltrout\nhello\n```",
'<pre data-code-wrap="eviltrout"><code class="lang-eviltrout">hello\n</code></pre>',
"it converts to custom block unknown code names"
"converts to custom block unknown code names"
);
assert.cooked(
'```\n[quote="sam, post:1, topic:9441, full:true"]This is `<not>` a bug.[/quote]\n```',
'<pre><code class="lang-auto">[quote=&quot;sam, post:1, topic:9441, full:true&quot;]This is `&lt;not&gt;` a bug.[/quote]\n</code></pre>',
"it allows code with backticks in it"
"allows code with backticks in it"
);
assert.cooked(
" hello\n<blockquote>test</blockquote>",
"<pre><code>hello\n</code></pre>\n<blockquote>test</blockquote>",
"it allows an indented code block to by followed by a `<blockquote>`"
"allows an indented code block to by followed by a `<blockquote>`"
);
assert.cooked(
"``` foo bar ```",
"<p><code>foo bar</code></p>",
"it tolerates misuse of code block tags as inline code"
"tolerates misuse of code block tags as inline code"
);
assert.cooked(
"```\nline1\n```\n```\nline2\n\nline3\n```",
'<pre><code class="lang-auto">line1\n</code></pre>\n<pre><code class="lang-auto">line2\n\nline3\n</code></pre>',
"it does not consume next block's trailing newlines"
"does not consume next block's trailing newlines"
);
assert.cooked(
" <pre>test</pre>",
"<pre><code>&lt;pre&gt;test&lt;/pre&gt;\n</code></pre>",
"it does not parse other block types in markdown code blocks"
"does not parse other block types in markdown code blocks"
);
assert.cooked(
" [quote]test[/quote]",
"<pre><code>[quote]test[/quote]\n</code></pre>",
"it does not parse other block types in markdown code blocks"
"does not parse other block types in markdown code blocks"
);
assert.cooked(
"## a\nb\n```\nc\n```",
'<h2><a name="a-1" class="anchor" href="#a-1"></a>a</h2>\n<p>b</p>\n<pre><code class="lang-auto">c\n</code></pre>',
"it handles headings with code blocks after them."
"handles headings with code blocks after them"
);
});
@ -972,13 +972,13 @@ eviltrout</p>
assert.cooked(
"[![folksy logo](http://folksy.com/images/folksy-colour.png)](http://folksy.com/)",
'<p><a href="http://folksy.com/"><img src="http://folksy.com/images/folksy-colour.png" alt="folksy logo"/></a></p>',
"It allows images with links around them"
"allows images with links around them"
);
assert.cooked(
'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">',
'<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot"></p>',
"It allows data images"
"allows data images"
);
assert.cooked(
@ -991,7 +991,7 @@ eviltrout</p>
assert.cooked(
"[test.pdf|attachment](upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf)",
`<p><a class="attachment" href="/404" data-orig-href="upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf">test.pdf</a></p>`,
"It returns the correct attachment link HTML"
"returns the correct attachment link HTML"
);
});
@ -1012,7 +1012,7 @@ eviltrout</p>
lookupUploadUrls,
},
`<p><a class="attachment" href="/uploads/short-url/blah">test.pdf</a></p>`,
"It returns the correct attachment link HTML when the URL is mapped without secure uploads"
"returns the correct attachment link HTML when the URL is mapped without secure uploads"
);
});
@ -1033,7 +1033,7 @@ eviltrout</p>
lookupUploadUrls,
},
`<p><a class="attachment" href="/secure-uploads/original/3X/c/b/o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf">test.pdf</a></p>`,
"It returns the correct attachment link HTML when the URL is mapped with secure uploads"
"returns the correct attachment link HTML when the URL is mapped with secure uploads"
);
});
@ -1042,7 +1042,7 @@ eviltrout</p>
"![baby shark|video](upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4)",
`<p><div class="video-placeholder-container" data-video-src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4">
</div></p>`,
"It returns the correct video player HTML"
"returns the correct video player HTML"
);
});
@ -1064,7 +1064,7 @@ eviltrout</p>
},
`<p><div class="video-placeholder-container" data-video-src="/secure-uploads/original/3X/c/b/test.mp4">
</div></p>`,
"It returns the correct video HTML when the URL is mapped with secure uploads, removing data-orig-src"
"returns the correct video HTML when the URL is mapped with secure uploads, removing data-orig-src"
);
});
@ -1075,7 +1075,7 @@ eviltrout</p>
<source src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp3">
<a href="/404">/404</a>
</audio></p>`,
"It returns the correct audio player HTML"
"returns the correct audio player HTML"
);
});
@ -1099,7 +1099,7 @@ eviltrout</p>
<source src="/secure-uploads/original/3X/c/b/test.mp3">
<a href="/secure-uploads/original/3X/c/b/test.mp3">/secure-uploads/original/3X/c/b/test.mp3</a>
</audio></p>`,
"It returns the correct audio HTML when the URL is mapped with secure uploads, removing data-orig-src"
"returns the correct audio HTML when the URL is mapped with secure uploads, removing data-orig-src"
);
});
@ -1119,13 +1119,13 @@ eviltrout</p>
assert.cooked(
"```\n\n some code\n```",
'<pre><code class="lang-auto">\n some code\n</code></pre>',
"it works when nesting standard markdown code blocks within a fenced code block"
"works when nesting standard markdown code blocks within a fenced code block"
);
assert.cooked(
"`$&`",
"<p><code>$&amp;</code></p>",
"it works even when hoisting special replacement patterns"
"works even when hoisting special replacement patterns"
);
});
@ -1186,7 +1186,7 @@ eviltrout</p>
assert.cookedPara(
"[url]abc.com[/url]",
'<a href="https://abc.com" data-bbcode="true">abc.com</a>',
"it magically links using linkify"
"magically links using linkify"
);
assert.cookedPara(
"[url]http://bettercallsaul.com[/url]",
@ -1208,7 +1208,7 @@ eviltrout</p>
assert.cooked(
"[code]I am not closed\n\nThis text exists.",
"<p>[code]I am not closed</p>\n<p>This text exists.</p>",
"does not raise an error with an open bbcode tag."
"does not raise an error with an open bbcode tag"
);
});
@ -1226,12 +1226,12 @@ eviltrout</p>
assert.cooked(
"[code]\nabc\n#def\n[/code]",
'<pre><code class="lang-auto">abc\n#def</code></pre>',
"it handles headings in a [code] block"
"handles headings in a [code] block"
);
assert.cooked(
"[code]\n s\n[/code]",
'<pre><code class="lang-auto"> s</code></pre>',
"it doesn't trim leading whitespace"
"doesn't trim leading whitespace"
);
assert.cooked(
"> [code]\n> line 1\n> line 2\n> line 3\n> [/code]",
@ -1274,7 +1274,7 @@ eviltrout</p>
<p>[sam]</p>
</blockquote>
</aside>`,
"it allows quotes with [] inside"
"allows quotes with [] inside"
);
assert.cooked(
@ -1380,7 +1380,7 @@ var bar = 'bar';
</blockquote>
</aside>
<p><em>Test</em></p>`,
"it allows trailing formatting"
"allows trailing formatting"
);
});
@ -1516,8 +1516,11 @@ var bar = 'bar';
assert.deepEqual(extractDataAttribute("foo="), ["data-foo", ""]);
assert.deepEqual(extractDataAttribute("foo=bar"), ["data-foo", "bar"]);
assert.notOk(extractDataAttribute("foo?=bar"));
assert.notOk(extractDataAttribute("https://discourse.org/?q=hello"));
assert.strictEqual(extractDataAttribute("foo?=bar"), null);
assert.strictEqual(
extractDataAttribute("https://discourse.org/?q=hello"),
null
);
});
test("video - display placeholder when previewing", function (assert) {
@ -1572,7 +1575,7 @@ var bar = 'bar';
assert.cookedOptions("(bad)", enabledTypographer, "<p>(bad)</p>");
assert.cookedOptions("+-5", enabledTypographer, "<p>±5</p>");
assert.cookedOptions(
"test.. test... test..... test?..... test!....",
"test.. test... test..... test?..... test!...",
enabledTypographer,
"<p>test… test… test… test?.. test!..</p>"
);

View File

@ -32,21 +32,21 @@ module("Unit | Utility | text-direction", function (hooks) {
test("isRTL", function (assert) {
// Hebrew
assert.strictEqual(isRTL("זה מבחן"), true);
assert.true(isRTL("זה מבחן"));
// Arabic
assert.strictEqual(isRTL("هذا اختبار"), true);
assert.true(isRTL("هذا اختبار"));
// Persian
assert.strictEqual(isRTL("این یک امتحان است"), true);
assert.true(isRTL("این یک امتحان است"));
assert.strictEqual(isRTL("This is a test"), false);
assert.strictEqual(isRTL(""), false);
assert.false(isRTL("This is a test"));
assert.false(isRTL(""));
});
test("isLTR", function (assert) {
assert.strictEqual(isLTR("This is a test"), true);
assert.strictEqual(isLTR("זה מבחן"), false);
assert.true(isLTR("This is a test"));
assert.false(isLTR("זה מבחן"));
});
test("setTextDirections", function (assert) {

View File

@ -47,7 +47,7 @@ module("Unit | Utility | UppyMediaOptimization Plugin", function (hooks) {
},
});
assert.strictEqual(plugin.id, "uppy-media-optimization");
assert.strictEqual(plugin.runParallel, true);
assert.true(plugin.runParallel);
assert.strictEqual(plugin.optimizeFn(), "wow such optimized");
});

View File

@ -323,10 +323,9 @@ module("Unit | Utilities | clipboard", function (hooks) {
}
await clipboardCopyAsync(asyncFunction);
assert.strictEqual(
assert.true(
this.mockClipboard.writeText.calledWith("some text to copy"),
true,
"it writes to the clipboard using writeText instead of write"
"writes to the clipboard using writeText instead of write"
);
});

View File

@ -15,8 +15,8 @@ module("Unit | Model | badge", function (hooks) {
const badge1 = store.createRecord("badge", { name: "New Badge" });
const badge2 = store.createRecord("badge", { id: 1, name: "Old Badge" });
assert.ok(badge1.newBadge, "badges without ids are new");
assert.ok(!badge2.newBadge, "badges with ids are not new");
assert.true(badge1.newBadge, "badges without ids are new");
assert.false(badge2.newBadge, "badges with ids are not new");
});
test("createFromJson array", function (assert) {
@ -29,7 +29,7 @@ module("Unit | Model | badge", function (hooks) {
const badges = Badge.createFromJson(badgesJson);
assert.ok(Array.isArray(badges), "returns an array");
assert.true(Array.isArray(badges), "returns an array");
assert.strictEqual(badges[0].name, "Badge 1", "badge details are set");
assert.strictEqual(
badges[0].badge_type.name,
@ -46,7 +46,7 @@ module("Unit | Model | badge", function (hooks) {
const badge = Badge.createFromJson(badgeJson);
assert.ok(!Array.isArray(badge), "does not returns an array");
assert.false(Array.isArray(badge), "does not returns an array");
});
test("updateFromJson", function (assert) {

View File

@ -155,19 +155,19 @@ module("Unit | Model | composer", function (hooks) {
test("replyDirty", function (assert) {
const composer = createComposer.call(this);
assert.ok(!composer.replyDirty, "by default it's false");
assert.false(composer.replyDirty, "false by default");
composer.setProperties({
originalText: "hello",
reply: "hello",
});
assert.ok(
!composer.replyDirty,
"it's false when the originalText is the same as the reply"
assert.false(
composer.replyDirty,
"false when the originalText is the same as the reply"
);
composer.set("reply", "hello world");
assert.ok(composer.replyDirty, "it's true when the reply changes");
assert.true(composer.replyDirty, "true when the reply changes");
});
test("appendText", function (assert) {
@ -232,13 +232,13 @@ module("Unit | Model | composer", function (hooks) {
const composer = createComposer.call(this);
composer.set("title", "asdf");
assert.ok(!composer.titleLengthValid, "short titles are not valid");
assert.false(composer.titleLengthValid, "short titles are not valid");
composer.set("title", "this is a long title");
assert.ok(!composer.titleLengthValid, "long titles are not valid");
assert.false(composer.titleLengthValid, "long titles are not valid");
composer.set("title", "just right");
assert.ok(composer.titleLengthValid, "in the range is okay");
assert.true(composer.titleLengthValid, "in the range is okay");
});
test("Title length for private messages", function (assert) {
@ -247,13 +247,13 @@ module("Unit | Model | composer", function (hooks) {
const composer = createComposer.call(this, { action: PRIVATE_MESSAGE });
composer.set("title", "asdf");
assert.ok(!composer.titleLengthValid, "short titles are not valid");
assert.false(composer.titleLengthValid, "short titles are not valid");
composer.set("title", "this is a long title");
assert.ok(!composer.titleLengthValid, "long titles are not valid");
assert.false(composer.titleLengthValid, "long titles are not valid");
composer.set("title", "just right");
assert.ok(composer.titleLengthValid, "in the range is okay");
assert.true(composer.titleLengthValid, "in the range is okay");
});
test("Post length for private messages with non human users", function (assert) {
@ -268,21 +268,18 @@ module("Unit | Model | composer", function (hooks) {
test("editingFirstPost", function (assert) {
const composer = createComposer.call(this);
assert.ok(!composer.editingFirstPost, "it's false by default");
assert.false(composer.editingFirstPost, "false by default");
const store = getOwner(this).lookup("service:store");
const post = store.createRecord("post", { id: 123, post_number: 2 });
composer.setProperties({ post, action: EDIT });
assert.ok(
!composer.editingFirstPost,
"it's false when not editing the first post"
assert.false(
composer.editingFirstPost,
"false when not editing the first post"
);
post.set("post_number", 1);
assert.ok(
composer.editingFirstPost,
"it's true when editing the first post"
);
assert.true(composer.editingFirstPost, "true when editing the first post");
});
test("clearState", function (assert) {
@ -309,7 +306,7 @@ module("Unit | Model | composer", function (hooks) {
draftKey: "abcd",
draftSequence: 1,
});
assert.ok(!composer.categoryId, "Uncategorized by default");
assert.strictEqual(composer.categoryId, null, "Uncategorized by default");
});
test("initial category when uncategorized is not allowed", function (assert) {
@ -319,8 +316,9 @@ module("Unit | Model | composer", function (hooks) {
draftKey: "abcd",
draftSequence: 1,
});
assert.ok(
!composer.categoryId,
assert.strictEqual(
composer.categoryId,
null,
"Uncategorized by default. Must choose a category."
);
});
@ -356,9 +354,8 @@ module("Unit | Model | composer", function (hooks) {
quote,
"originalText is the quote"
);
assert.strictEqual(
assert.false(
newComposer().replyDirty,
false,
"replyDirty is initially false with a quote"
);
});
@ -377,17 +374,17 @@ module("Unit | Model | composer", function (hooks) {
composer.setProperties({ post, action: EDIT });
composer.set("title", "asdf");
assert.ok(composer.titleLengthValid, "admins can use short titles");
assert.true(composer.titleLengthValid, "admins can use short titles");
composer.set("title", "this is a long title");
assert.ok(composer.titleLengthValid, "admins can use long titles");
assert.true(composer.titleLengthValid, "admins can use long titles");
composer.set("title", "just right");
assert.ok(composer.titleLengthValid, "in the range is okay");
assert.true(composer.titleLengthValid, "in the range is okay");
composer.set("title", "");
assert.ok(
!composer.titleLengthValid,
assert.false(
composer.titleLengthValid,
"admins must set title to at least 1 character"
);
});

View File

@ -24,16 +24,16 @@ module("Unit | Model | post-stream", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
assert.ok(
store.createRecord("postStream"),
"it can be created with no parameters"
assert.true(
!!store.createRecord("postStream"),
"can be created with no parameters"
);
});
test("defaults", function (assert) {
const postStream = buildStream.call(this, 1234);
assert.blank(postStream.posts, "there are no posts in a stream by default");
assert.ok(!postStream.loaded, "it has never loaded");
assert.false(postStream.loaded, "has never loaded");
assert.present(postStream.topic);
});
@ -43,16 +43,16 @@ module("Unit | Model | post-stream", function (hooks) {
assert.strictEqual(postStream.lastPostId, 4, "the last post id is 4");
assert.ok(!postStream.hasPosts, "there are no posts by default");
assert.ok(!postStream.firstPostPresent, "the first post is not loaded");
assert.ok(!postStream.loadedAllPosts, "the last post is not loaded");
assert.false(postStream.hasPosts, "there are no posts by default");
assert.false(postStream.firstPostPresent, "the first post is not loaded");
assert.false(postStream.loadedAllPosts, "the last post is not loaded");
assert.strictEqual(postStream.posts.length, 0, "it has no posts initially");
postStream.appendPost(
store.createRecord("post", { id: 2, post_number: 2 })
);
assert.ok(
!postStream.firstPostPresent,
assert.false(
postStream.firstPostPresent,
"the first post is still not loaded"
);
assert.strictEqual(
@ -64,8 +64,8 @@ module("Unit | Model | post-stream", function (hooks) {
postStream.appendPost(
store.createRecord("post", { id: 4, post_number: 4 })
);
assert.ok(!postStream.firstPostPresent, "the first post is still loaded");
assert.ok(postStream.loadedAllPosts, "the last post is now loaded");
assert.false(postStream.firstPostPresent, "the first post is still loaded");
assert.true(postStream.loadedAllPosts, "the last post is now loaded");
assert.strictEqual(
postStream.posts.length,
2,
@ -97,11 +97,11 @@ module("Unit | Model | post-stream", function (hooks) {
// change the stream
postStream.set("stream", [1, 2, 4]);
assert.ok(
!postStream.firstPostPresent,
assert.false(
postStream.firstPostPresent,
"the first post no longer loaded since the stream changed."
);
assert.ok(
assert.true(
postStream.loadedAllPosts,
"the last post is still the last post in the new stream"
);
@ -218,7 +218,7 @@ module("Unit | Model | post-stream", function (hooks) {
postStream.set("filter", "summary");
postStream.cancelFilter();
assert.ok(!postStream.summary, "summary is cancelled");
assert.false(postStream.summary, "summary is cancelled");
postStream.filterParticipant(participant);
postStream.cancelFilter();
@ -289,7 +289,7 @@ module("Unit | Model | post-stream", function (hooks) {
);
postStream.filterParticipant(participant.username);
assert.ok(
assert.true(
postStream.userFilters.includes("eviltrout"),
"eviltrout is in the filters"
);
@ -308,9 +308,8 @@ module("Unit | Model | post-stream", function (hooks) {
sinon.stub(postStream, "refresh").resolves();
assert.strictEqual(
assert.false(
postStream.filterRepliesToPostNumber,
false,
"by default no replies are filtered"
);
@ -322,11 +321,7 @@ module("Unit | Model | post-stream", function (hooks) {
);
postStream.cancelFilter();
assert.strictEqual(
postStream.filterRepliesToPostNumber,
false,
"cancelFilter clears"
);
assert.false(postStream.filterRepliesToPostNumber, "cancelFilter clears");
});
test("filterUpwards", function (assert) {
@ -339,17 +334,13 @@ module("Unit | Model | post-stream", function (hooks) {
sinon.stub(postStream, "refresh").resolves();
assert.strictEqual(
postStream.filterUpwardsPostID,
false,
"by default filter is false"
);
assert.false(postStream.filterUpwardsPostID, "by default filter is false");
postStream.filterUpwards(2);
assert.strictEqual(postStream.filterUpwardsPostID, 2, "filter is set");
postStream.cancelFilter();
assert.strictEqual(postStream.filterUpwardsPostID, false, "filter cleared");
assert.false(postStream.filterUpwardsPostID, "filter cleared");
});
test("streamFilters", function (assert) {
@ -361,7 +352,7 @@ module("Unit | Model | post-stream", function (hooks) {
{},
"there are no postFilters by default"
);
assert.ok(postStream.hasNoFilters, "there are no filters by default");
assert.true(postStream.hasNoFilters, "there are no filters by default");
postStream.set("filter", "summary");
assert.deepEqual(
@ -369,7 +360,7 @@ module("Unit | Model | post-stream", function (hooks) {
{ filter: "summary" },
"postFilters contains the summary flag"
);
assert.ok(!postStream.hasNoFilters, "now there are filters present");
assert.false(postStream.hasNoFilters, "now there are filters present");
postStream.filterParticipant(participant.username);
assert.deepEqual(
@ -401,18 +392,18 @@ module("Unit | Model | post-stream", function (hooks) {
test("loading", function (assert) {
const postStream = buildStream.call(this, 1234);
assert.ok(!postStream.loading, "we're not loading by default");
assert.false(postStream.loading, "we're not loading by default");
postStream.set("loadingAbove", true);
assert.ok(postStream.loading, "we're loading if loading above");
assert.true(postStream.loading, "we're loading if loading above");
const postStream2 = buildStream.call(this, 1234);
postStream2.set("loadingBelow", true);
assert.ok(postStream2.loading, "we're loading if loading below");
assert.true(postStream2.loading, "we're loading if loading below");
const postStream3 = buildStream.call(this, 1234);
postStream3.set("loadingFilter", true);
assert.ok(postStream3.loading, "we're loading if loading a filter");
assert.true(postStream3.loading, "we're loading if loading a filter");
});
test("nextWindow", function (assert) {
@ -660,7 +651,7 @@ module("Unit | Model | post-stream", function (hooks) {
2,
"it updates the highest_post_number"
);
assert.ok(
assert.true(
postStream.loading,
"it is loading while the post is being staged"
);
@ -689,7 +680,7 @@ module("Unit | Model | post-stream", function (hooks) {
"it is assigned the probable post_number"
);
assert.present(stagedPost.created_at, "it is assigned a created date");
assert.ok(
assert.true(
postStream.posts.includes(stagedPost),
"the post is added to the stream"
);
@ -698,7 +689,7 @@ module("Unit | Model | post-stream", function (hooks) {
// Undoing a created post (there was an error)
postStream.undoPost(stagedPost);
assert.ok(!postStream.loading, "it is no longer loading");
assert.false(postStream.loading, "no longer loading");
assert.strictEqual(
topic.highest_post_number,
1,
@ -710,8 +701,8 @@ module("Unit | Model | post-stream", function (hooks) {
1,
"it retains the filteredPostsCount"
);
assert.ok(
!postStream.posts.includes(stagedPost),
assert.false(
postStream.posts.includes(stagedPost),
"the post is removed from the stream"
);
assert.strictEqual(
@ -754,9 +745,9 @@ module("Unit | Model | post-stream", function (hooks) {
const result = postStream.stagePost(stagedPost, user);
assert.strictEqual(result, "staged", "it returns staged");
assert.ok(
assert.true(
postStream.loading,
"it is loading while the post is being staged"
"is loading while the post is being staged"
);
stagedPost.setProperties({ id: 1234, raw: "different raw value" });
@ -773,11 +764,11 @@ module("Unit | Model | post-stream", function (hooks) {
);
postStream.commitPost(stagedPost);
assert.ok(
assert.true(
postStream.posts.includes(stagedPost),
"the post is still in the stream"
);
assert.ok(!postStream.loading, "it is no longer loading");
assert.false(postStream.loading, "it is no longer loading");
assert.strictEqual(
postStream.filteredPostsCount,
@ -787,7 +778,7 @@ module("Unit | Model | post-stream", function (hooks) {
const found = postStream.findLoadedPost(stagedPost.id);
assert.present(found, "the post is in the identity map");
assert.ok(
assert.true(
postStream.posts.includes(stagedPost),
"the post is in the stream"
);
@ -816,10 +807,10 @@ module("Unit | Model | post-stream", function (hooks) {
store.createRecord("post", { id: 1, post_number: 1 })
);
postStream.appendPost(postWithoutId);
assert.ok(!postStream.loadedAllPosts, "the last post is not loaded");
assert.false(postStream.loadedAllPosts, "the last post is not loaded");
postWithoutId.set("id", 2);
assert.ok(
assert.true(
postStream.loadedAllPosts,
"the last post is loaded now that the post has an id"
);
@ -987,10 +978,10 @@ module("Unit | Model | post-stream", function (hooks) {
"we immediately have a larger placeholder window"
);
assert.strictEqual(testProxy.length, 8);
assert.ok(!!postsWithPlaceholders.nextObject(3, p3));
assert.ok(!!postsWithPlaceholders.objectAt(4));
assert.ok(postsWithPlaceholders.objectAt(3) !== p4);
assert.ok(testProxy.objectAt(3) !== p4);
assert.true(!!postsWithPlaceholders.nextObject(3, p3));
assert.true(!!postsWithPlaceholders.objectAt(4));
assert.notStrictEqual(postsWithPlaceholders.objectAt(3), p4);
assert.notStrictEqual(testProxy.objectAt(3), p4);
await promise;
assert.strictEqual(postsWithPlaceholders.objectAt(3), p4);

View File

@ -11,7 +11,7 @@ module("Unit | Model | post", function (hooks) {
test("defaults", function (assert) {
const post = this.store.createRecord("post", { id: 1 });
assert.blank(post.deleted_at, "it has no deleted_at by default");
assert.blank(post.deleted_at, "has no deleted_at by default");
assert.blank(post.deleted_by, "there is no deleted_by by default");
});
@ -20,15 +20,15 @@ module("Unit | Model | post", function (hooks) {
assert.ok(post.new_user, "post is from a new user");
post.set("trust_level", 1);
assert.ok(!post.new_user, "post is no longer from a new user");
assert.false(post.new_user, "post is no longer from a new user");
});
test("firstPost", function (assert) {
const post = this.store.createRecord("post", { post_number: 1 });
assert.ok(post.firstPost, "it's the first post");
assert.true(post.firstPost, "is the first post");
post.set("post_number", 10);
assert.ok(!post.firstPost, "post is no longer the first post");
assert.false(post.firstPost, "post is no longer the first post");
});
test("updateFromPost", function (assert) {
@ -60,17 +60,17 @@ module("Unit | Model | post", function (hooks) {
await post.destroy(user);
assert.present(post.deleted_at, "it has a `deleted_at` field.");
assert.present(post.deleted_at, "has a `deleted_at` field.");
assert.strictEqual(
post.deleted_by,
user,
"it has the user in the `deleted_by` field"
"has the user in the `deleted_by` field"
);
await post.recover();
assert.blank(post.deleted_at, "it clears `deleted_at` when recovering");
assert.blank(post.deleted_by, "it clears `deleted_by` when recovering");
assert.blank(post.deleted_at, "clears `deleted_at` when recovering");
assert.blank(post.deleted_by, "clears `deleted_by` when recovering");
});
test("destroy by non-staff", async function (assert) {
@ -86,11 +86,15 @@ module("Unit | Model | post", function (hooks) {
await post.destroy(user);
assert.ok(
!post.can_delete,
assert.false(
post.can_delete,
"the post can't be deleted again in this session"
);
assert.ok(post.cooked !== originalCooked, "the cooked content changed");
assert.notStrictEqual(
post.cooked,
originalCooked,
"the cooked content changed"
);
assert.strictEqual(post.version, 2, "the version number increased");
});
});

View File

@ -94,7 +94,7 @@ module("Unit | Model | report", function (hooks) {
this,
[6, 8, 0, 2, 1]
).yesterdayCountTitle;
assert.ok(!title.includes("%"));
assert.false(title.includes("%"));
assert.ok(title.match(/Was 0/));
});

View File

@ -27,17 +27,17 @@ module("Unit | Model | rest-model", function (hooks) {
const store = getOwner(this).lookup("service:store");
const widget = await store.find("widget", 123);
assert.strictEqual(widget.name, "Trout Lure");
assert.ok(!widget.isSaving, "it is not saving");
assert.false(widget.isSaving, "it is not saving");
const spyBeforeUpdate = sinon.spy(widget, "beforeUpdate");
const spyAfterUpdate = sinon.spy(widget, "afterUpdate");
const promise = widget.update({ name: "new name" });
assert.ok(widget.isSaving, "it is saving");
assert.ok(spyBeforeUpdate.calledOn(widget));
assert.true(widget.isSaving, "it is saving");
assert.true(spyBeforeUpdate.calledOn(widget));
const result = await promise;
assert.ok(spyAfterUpdate.calledOn(widget));
assert.ok(!widget.isSaving, "it is no longer saving");
assert.true(spyAfterUpdate.calledOn(widget));
assert.false(widget.isSaving, "it is no longer saving");
assert.strictEqual(widget.name, "new name");
assert.ok(result.target, "it has a reference to the record");
@ -61,23 +61,23 @@ module("Unit | Model | rest-model", function (hooks) {
const store = getOwner(this).lookup("service:store");
const widget = store.createRecord("widget");
assert.ok(widget.isNew, "it is a new record");
assert.ok(!widget.isCreated, "it is not created");
assert.ok(!widget.isSaving, "it is not saving");
assert.true(widget.isNew, "it is a new record");
assert.false(widget.isCreated, "it is not created");
assert.false(widget.isSaving, "it is not saving");
const spyBeforeCreate = sinon.spy(widget, "beforeCreate");
const spyAfterCreate = sinon.spy(widget, "afterCreate");
const promise = widget.save({ name: "Evil Widget" });
assert.ok(widget.isSaving, "it is not saving");
assert.ok(spyBeforeCreate.calledOn(widget));
assert.true(widget.isSaving, "it is not saving");
assert.true(spyBeforeCreate.calledOn(widget));
const result = await promise;
assert.ok(spyAfterCreate.calledOn(widget));
assert.ok(!widget.isSaving, "it is no longer saving");
assert.true(spyAfterCreate.calledOn(widget));
assert.false(widget.isSaving, "it is no longer saving");
assert.ok(widget.id, "it has an id");
assert.ok(widget.name, "Evil Widget");
assert.ok(widget.isCreated, "it is created");
assert.ok(!widget.isNew, "it is no longer new");
assert.true(widget.isCreated, "it is created");
assert.false(widget.isNew, "it is no longer new");
assert.ok(result.target, "it has a reference to the record");
assert.strictEqual(result.target.name, widget.name);

View File

@ -10,10 +10,10 @@ module("Unit | Model | result-set", function (hooks) {
const resultSet = store.createRecord("result-set", { content: [] });
assert.strictEqual(resultSet.length, 0);
assert.strictEqual(resultSet.totalRows, 0);
assert.ok(!resultSet.loadMoreUrl);
assert.ok(!resultSet.loading);
assert.ok(!resultSet.loadingMore);
assert.ok(!resultSet.refreshing);
assert.strictEqual(resultSet.loadMoreUrl, null);
assert.false(resultSet.loading);
assert.false(resultSet.loadingMore);
assert.false(resultSet.refreshing);
});
test("pagination support", async function (assert) {
@ -21,18 +21,22 @@ module("Unit | Model | result-set", function (hooks) {
const resultSet = await store.findAll("widget");
assert.strictEqual(resultSet.length, 2);
assert.strictEqual(resultSet.totalRows, 4);
assert.ok(resultSet.loadMoreUrl, "has a url to load more");
assert.ok(!resultSet.loadingMore, "it is not loading more");
assert.ok(resultSet.canLoadMore);
assert.strictEqual(
resultSet.loadMoreUrl,
"/load-more-widgets",
"has a url to load more"
);
assert.false(resultSet.loadingMore, "not loading more");
assert.true(resultSet.canLoadMore);
const promise = resultSet.loadMore();
assert.ok(resultSet.loadingMore, "it is loading more");
assert.true(resultSet.loadingMore, "is loading more");
await promise;
assert.ok(!resultSet.loadingMore, "it finished loading more");
assert.false(resultSet.loadingMore, "finished loading more");
assert.strictEqual(resultSet.length, 4);
assert.ok(!resultSet.loadMoreUrl);
assert.ok(!resultSet.canLoadMore);
assert.strictEqual(resultSet.loadMoreUrl, null);
assert.false(resultSet.canLoadMore);
});
test("refresh support", async function (assert) {
@ -41,13 +45,13 @@ module("Unit | Model | result-set", function (hooks) {
assert.strictEqual(
resultSet.refreshUrl,
"/widgets?refresh=true",
"it has the refresh url"
"has the refresh url"
);
const promise = resultSet.refresh();
assert.ok(resultSet.refreshing, "it is refreshing");
assert.true(resultSet.refreshing, "is refreshing");
await promise;
assert.ok(!resultSet.refreshing, "it is finished refreshing");
assert.false(resultSet.refreshing, "finished refreshing");
});
});

View File

@ -12,7 +12,7 @@ module("Unit | Model | topic-details", function (hooks) {
const details = topic.details;
assert.present(details, "the details are present by default");
assert.ok(!details.loaded, "details are not loaded by default");
assert.false(details.loaded, "details are not loaded by default");
});
test("updateFromJson", function (assert) {

View File

@ -238,11 +238,11 @@ module("Unit | Model | topic", function (hooks) {
assert.strictEqual(topic.invisible, undefined);
const visibleTopic = this.store.createRecord("topic", { visible: true });
assert.strictEqual(visibleTopic.visible, true);
assert.strictEqual(visibleTopic.invisible, false);
assert.true(visibleTopic.visible);
assert.false(visibleTopic.invisible);
const invisibleTopic = this.store.createRecord("topic", { visible: false });
assert.strictEqual(invisibleTopic.visible, false);
assert.strictEqual(invisibleTopic.invisible, true);
assert.false(invisibleTopic.visible);
assert.true(invisibleTopic.invisible);
});
});

View File

@ -317,14 +317,12 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
};
trackingState.sync(list, "unread");
assert.strictEqual(
assert.false(
list.topics[0].unseen,
false,
"expect unread topic to be marked as seen"
);
assert.strictEqual(
assert.true(
list.topics[0].prevent_sync,
true,
"expect unread topic to be marked as prevent_sync"
);
});
@ -532,9 +530,8 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
await publishToMessageBus("/delete", { topic_id: 111 });
assert.strictEqual(
assert.true(
trackingState.findState(111).deleted,
true,
"marks the topic as deleted"
);
assert.strictEqual(
@ -559,9 +556,8 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
await publishToMessageBus("/recover", { topic_id: 111 });
assert.strictEqual(
assert.false(
trackingState.findState(111).deleted,
false,
"marks the topic as not deleted"
);
assert.strictEqual(
@ -824,13 +820,13 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
assert.strictEqual(currentUser.unmuted_topics[0].topicId, 2);
trackingState.pruneOldMutedAndUnmutedTopics();
assert.strictEqual(trackingState.isMutedTopic(1), true);
assert.strictEqual(trackingState.isUnmutedTopic(2), true);
assert.true(trackingState.isMutedTopic(1));
assert.true(trackingState.isUnmutedTopic(2));
this.clock.tick(60000);
trackingState.pruneOldMutedAndUnmutedTopics();
assert.strictEqual(trackingState.isMutedTopic(1), false);
assert.strictEqual(trackingState.isUnmutedTopic(2), false);
assert.false(trackingState.isMutedTopic(1));
assert.false(trackingState.isUnmutedTopic(2));
});
});
@ -1045,7 +1041,7 @@ module("Unit | Model | topic-tracking-state | /unread", function (hooks) {
payload: { topic_ids: [112] },
});
assert.strictEqual(this.trackingState.findState(112).is_seen, true);
assert.true(this.trackingState.findState(112).is_seen);
});
test("marks a topic as read", async function (assert) {
@ -1214,11 +1210,7 @@ module("Unit | Model | topic-tracking-state | /new", function (hooks) {
},
"new topic loaded into state"
);
assert.strictEqual(
stateCallbackCalled,
true,
"state change callback called"
);
assert.true(stateCallbackCalled, "state change callback called");
});
test("adds incoming so it is counted in topic lists", async function (assert) {

View File

@ -12,7 +12,7 @@ module("Unit | Model | user-badge", function (hooks) {
const userBadge = UserBadge.createFromJson(
cloneJSON(badgeFixtures["/user_badges"])
);
assert.ok(!Array.isArray(userBadge), "does not return an array");
assert.false(Array.isArray(userBadge), "does not return an array");
assert.strictEqual(
userBadge.badge.name,
"Badge 2",
@ -54,7 +54,7 @@ module("Unit | Model | user-badge", function (hooks) {
test("grant", async function (assert) {
const userBadge = await UserBadge.grant(1, "username");
assert.ok(!Array.isArray(userBadge), "does not return an array");
assert.false(Array.isArray(userBadge), "does not return an array");
});
test("revoke", async function (assert) {

View File

@ -17,7 +17,7 @@ module("Unit | Model | user-stream", function (hooks) {
assert.blank(stream.content, "no content by default");
assert.blank(stream.filter, "no filter by default");
assert.ok(!stream.loaded, "the stream is not loaded by default");
assert.false(stream.loaded, "the stream is not loaded by default");
});
test("filterParam", function (assert) {

View File

@ -13,13 +13,13 @@ module("Unit | Model | user", function (hooks) {
const store = getOwner(this).lookup("service:store");
const user = store.createRecord("user", { id: 1, username: "eviltrout" });
assert.ok(!user.staff, "user is not staff");
assert.strictEqual(user.staff, undefined, "user is not staff");
user.toggleProperty("moderator");
assert.ok(user.staff, "moderators are staff");
assert.true(user.staff, "moderators are staff");
user.setProperties({ moderator: false, admin: true });
assert.ok(user.staff, "admins are staff");
assert.true(user.staff, "admins are staff");
});
test("searchContext", function (assert) {
@ -53,27 +53,24 @@ module("Unit | Model | user", function (hooks) {
const user = store.createRecord("user", { admin: true });
const group = store.createRecord("group", { automatic: true });
assert.strictEqual(
assert.false(
user.canManageGroup(group),
false,
"automatic groups cannot be managed."
);
group.set("automatic", false);
group.setProperties({ can_admin_group: true });
assert.strictEqual(
assert.true(
user.canManageGroup(group),
true,
"an admin should be able to manage the group"
);
user.set("admin", false);
group.setProperties({ is_group_owner: true });
assert.strictEqual(
assert.true(
user.canManageGroup(group),
true,
"a group owner should be able to manage the group"
);
});

View File

@ -7,32 +7,32 @@ module("Unit | Model | Wizard | wizard-field", function (hooks) {
test("basic state", function (assert) {
const field = new Field({ type: "text" });
assert.ok(field.unchecked);
assert.ok(!field.valid);
assert.ok(!field.invalid);
assert.true(field.unchecked);
assert.false(field.valid);
assert.false(field.invalid);
});
test("text - required - validation", function (assert) {
const field = new Field({ type: "text", required: true });
assert.ok(field.unchecked);
assert.true(field.unchecked);
field.validate();
assert.ok(!field.unchecked);
assert.ok(!field.valid);
assert.ok(field.invalid);
assert.false(field.unchecked);
assert.false(field.valid);
assert.true(field.invalid);
field.value = "a value";
field.validate();
assert.ok(!field.unchecked);
assert.ok(field.valid);
assert.ok(!field.invalid);
assert.false(field.unchecked);
assert.true(field.valid);
assert.false(field.invalid);
});
test("text - optional - validation", function (assert) {
const field = new Field({ type: "text" });
assert.ok(field.unchecked);
assert.true(field.unchecked);
field.validate();
assert.ok(field.valid);
assert.true(field.valid);
});
});

View File

@ -168,7 +168,7 @@ module("Unit | Service | presence | subscribing", function (hooks) {
await channel.subscribe();
assert.strictEqual(channel.count, 3, "has the correct count");
assert.strictEqual(channel.countOnly, true, "identifies as countOnly");
assert.true(channel.countOnly, "identifies as countOnly");
assert.strictEqual(channel.users, null, "has null users list");
await publishToMessageBus(

View File

@ -21,6 +21,6 @@ module("Integration | Component | da-boolean-field", function (hooks) {
await click("input");
assert.dom("input").isChecked();
assert.strictEqual(this.field.metadata.value, true);
assert.true(this.field.metadata.value);
});
});

View File

@ -22,6 +22,6 @@ module("Integration | Component | da-date-time-field", function (hooks) {
);
await fillIn("input", "2023-10-03T12:34");
assert.ok(this.field.metadata.value !== null);
assert.notStrictEqual(this.field.metadata.value, null);
});
});

View File

@ -95,7 +95,7 @@ module("Discourse Chat | Component | chat-composer-upload", function (hooks) {
);
await click(".chat-composer-upload__remove-btn");
assert.strictEqual(this.uploadRemoved, true);
assert.true(this.uploadRemoved);
});
test("cancelling in progress upload", async function (assert) {
@ -115,6 +115,6 @@ module("Discourse Chat | Component | chat-composer-upload", function (hooks) {
);
await click(".chat-composer-upload__remove-btn");
assert.strictEqual(this.uploadRemoved, true);
assert.true(this.uploadRemoved);
});
});

View File

@ -10,18 +10,18 @@ module("Discourse Chat | Unit | Models | chat-message", function (hooks) {
test(".persisted", function (assert) {
const channel = new ChatFabricators(getOwner(this)).channel();
let message = ChatMessage.create(channel, { id: null });
assert.strictEqual(message.persisted, false);
assert.false(message.persisted);
message = ChatMessage.create(channel, {
id: 1,
staged: true,
});
assert.strictEqual(message.persisted, false);
assert.false(message.persisted);
message = ChatMessage.create(channel, {
id: 1,
staged: false,
});
assert.strictEqual(message.persisted, true);
assert.true(message.persisted);
});
});

View File

@ -62,7 +62,7 @@ module(
await settled();
assert.deepEqual(this.manager.emojis, emojisResponse());
assert.strictEqual(this.manager.loading, false);
assert.false(this.manager.loading);
});
test("closeExisting", async function (assert) {

View File

@ -82,8 +82,8 @@ module(
test("didCollapseDrawer", function (assert) {
this.subject.didCollapseDrawer();
assert.strictEqual(this.subject.isDrawerExpanded, false);
assert.strictEqual(this.subject.isDrawerActive, true);
assert.false(this.subject.isDrawerExpanded);
assert.true(this.subject.isDrawerActive);
});
test("didExpandDrawer", function (assert) {
@ -94,8 +94,8 @@ module(
this.subject.didExpandDrawer();
assert.strictEqual(this.subject.isDrawerExpanded, true);
assert.strictEqual(this.subject.isDrawerActive, true);
assert.true(this.subject.isDrawerExpanded);
assert.true(this.subject.isDrawerActive);
sinon.assert.calledOnce(stub);
});
@ -107,8 +107,8 @@ module(
this.subject.didCloseDrawer();
assert.strictEqual(this.subject.isDrawerExpanded, false);
assert.strictEqual(this.subject.isDrawerActive, false);
assert.false(this.subject.isDrawerExpanded);
assert.false(this.subject.isDrawerActive);
sinon.assert.calledOnce(stub);
});
@ -120,8 +120,8 @@ module(
this.subject.didOpenDrawer();
assert.strictEqual(this.subject.isDrawerExpanded, true);
assert.strictEqual(this.subject.isDrawerActive, true);
assert.true(this.subject.isDrawerExpanded);
assert.true(this.subject.isDrawerActive);
assert.strictEqual(this.subject.lastKnownChatURL, "/chat");
this.subject.didOpenDrawer("/foo");
@ -138,13 +138,13 @@ module(
this.subject.didOpenDrawer();
assert.strictEqual(this.state.isDrawerActive, true);
assert.strictEqual(this.state.isDrawerExpanded, true);
assert.true(this.state.isDrawerActive);
assert.true(this.state.isDrawerExpanded);
this.subject.didCloseDrawer();
assert.strictEqual(this.state.isDrawerActive, false);
assert.strictEqual(this.state.isDrawerExpanded, false);
assert.false(this.state.isDrawerActive);
assert.false(this.state.isDrawerExpanded);
resetChatDrawerStateCallbacks();
});