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
58 changed files with 444 additions and 487 deletions

View File

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

View File

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

View File

@ -16,7 +16,10 @@ acceptance("CategoryChooser", function (needs) {
await click("#create-topic"); await click("#create-topic");
await categoryChooser.expand(); 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) { 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", ".d-editor-input",
"hello world hello world hello world hello world hello world" "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) { test("Should send originalText when editing a reply", async function (assert) {
@ -31,6 +31,6 @@ acceptance("Composer - Edit conflict", function (needs) {
".d-editor-input", ".d-editor-input",
"hello world hello world hello world hello world hello world" "hello world hello world hello world hello world hello world"
); );
assert.ok(lastBody.includes("originalText")); assert.true(lastBody.includes("originalText"));
}); });
}); });

View File

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

View File

@ -471,11 +471,7 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
"||a|b|\n|---|---|---|\n|1|2|3|\n", "||a|b|\n|---|---|---|\n|1|2|3|\n",
"only the plain text table is pasted" "only the plain text table is pasted"
); );
assert.strictEqual( assert.false(uppyEventFired, "uppy does not start uploading the file");
uppyEventFired,
false,
"uppy does not start uploading the file"
);
done(); 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"); assert.dom(".do-not-disturb-modal").exists("modal to choose time appears");
let tiles = queryAll(".do-not-disturb-tile"); 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]); await click(tiles[0]);

View File

@ -98,8 +98,8 @@ acceptance("User notification schedule", function (needs) {
); );
await selectKit(".day.Tuesday .ends-at .combobox").expand(); await selectKit(".day.Tuesday .ends-at .combobox").expand();
assert.ok( assert.false(
!selectKit(".day.Tuesday .ends-at .combobox").rowByValue(1350).exists(), selectKit(".day.Tuesday .ends-at .combobox").rowByValue(1350).exists(),
"End time options are limited to + 30 past start time" "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(".untrack [type='checkbox']");
await click("#dismiss-read-confirm"); await click("#dismiss-read-confirm");
assert.strictEqual(state.dismissTopics, false); assert.false(state.dismissTopics);
assert.strictEqual(state.dismissPosts, false); assert.false(state.dismissPosts);
assert.strictEqual(state.untrack, true); 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 render(hbs`<DMenu @inline={{true}} @onShow={{this.onShow}} />`);
await open(); await open();
assert.strictEqual(this.test, true); assert.true(this.test);
}); });
test("@onClose", async function (assert) { test("@onClose", async function (assert) {
@ -83,7 +83,7 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
await open(); await open();
await close(); await close();
assert.strictEqual(this.test, true); assert.true(this.test);
}); });
test("-expanded class", async function (assert) { test("-expanded class", async function (assert) {

View File

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

View File

@ -473,11 +473,10 @@ module("Integration | Component | plugin-outlet", function (hooks) {
1, 1,
"console warn was called once" "console warn was called once"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `shouldDisplay` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]" "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" "logs the default message to the console"
); );
}); });
@ -506,34 +505,30 @@ module("Integration | Component | plugin-outlet", function (hooks) {
1, 1,
"console warn was called once" "console warn was called once"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
sinon.match(/The 'shouldDisplay' is deprecated on this test/) sinon.match(/The 'shouldDisplay' is deprecated on this test/)
), ),
true,
"logs the custom deprecation message to the console" "logs the custom deprecation message to the console"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
sinon.match( sinon.match(
/deprecation id: discourse.plugin-connector.deprecated-arg.test/ /deprecation id: discourse.plugin-connector.deprecated-arg.test/
) )
), ),
true,
"logs custom deprecation id" "logs custom deprecation id"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
sinon.match(/deprecated since Discourse 3.3.0.beta4-dev/) sinon.match(/deprecated since Discourse 3.3.0.beta4-dev/)
), ),
true,
"logs deprecation since information" "logs deprecation since information"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
sinon.match(/removal in Discourse 3.4.0/) sinon.match(/removal in Discourse 3.4.0/)
), ),
true,
"logs dropFrom information" "logs dropFrom information"
); );
}); });
@ -568,22 +563,20 @@ module("Integration | Component | plugin-outlet", function (hooks) {
1, 1,
"console warn was called once" "console warn was called once"
); );
assert.strictEqual( assert.false(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
sinon.match( sinon.match(
/deprecation id: discourse.deprecation-that-should-not-be-logged/ /deprecation id: discourse.deprecation-that-should-not-be-logged/
) )
), ),
false,
"does not log silence deprecation" "does not log silence deprecation"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
sinon.match( sinon.match(
/deprecation id: discourse.plugin-connector.deprecated-arg/ /deprecation id: discourse.plugin-connector.deprecated-arg/
) )
), ),
true,
"logs expected deprecation" "logs expected deprecation"
); );
}); });
@ -793,18 +786,16 @@ module(
2, 2,
"console warn was called twice" "console warn was called twice"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]" "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" "logs the expected message for @outletArgs.hello"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( 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]" "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" "logs the expected message for this.hello"
); );
}); });
@ -827,18 +818,16 @@ module(
1, 1,
"console warn was called once" "console warn was called once"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]" "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" "logs the expected message for @outletArgs.hello"
); );
assert.strictEqual( assert.false(
this.consoleWarnStub.calledWith( 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]" "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" "does not log the message for this.hello"
); );
}); });
@ -867,18 +856,16 @@ module(
2, 2,
"console warn was called twice" "console warn was called twice"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]" "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" "logs the expected message for @outletArgs.hello"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( 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]" "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" "logs the expected message for this.hello"
); );
}); });
@ -906,18 +893,16 @@ module(
2, 2,
"console warn was called twice" "console warn was called twice"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]" "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" "logs the expected message for @outletArgs.hello"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]" "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" "logs the expected message for this.hello"
); );
}); });
@ -941,11 +926,10 @@ module(
1, 1,
"console warn was called twice" "console warn was called twice"
); );
assert.strictEqual( assert.true(
this.consoleWarnStub.calledWith( this.consoleWarnStub.calledWith(
"Deprecation notice: outlet arg `hello` is deprecated on the outlet `test-name` [deprecation id: discourse.plugin-connector.deprecated-arg]" "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" "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"); await fillIn(".tf-test", "hello");
assert.ok(!this.called); assert.false(this.called);
await fillIn(".tf-test", "new text"); await fillIn(".tf-test", "new text");
assert.ok(this.called); assert.true(this.called);
assert.strictEqual(this.newValue, "new text"); assert.strictEqual(this.newValue, "new text");
}); });
@ -64,10 +64,10 @@ module("Integration | Component | text-field", function (hooks) {
); );
await fillIn(".tf-test", "old"); await fillIn(".tf-test", "old");
assert.ok(!this.called); assert.false(this.called);
await fillIn(".tf-test", "no longer old"); await fillIn(".tf-test", "no longer old");
assert.ok(this.called); assert.true(this.called);
assert.strictEqual(this.newValue, "no longer old"); 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 { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Component | topic-list-item", function (hooks) { module("Integration | Component | topic-list-item", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -31,8 +30,8 @@ module("Integration | Component | topic-list-item", function (hooks) {
/> />
`); `);
const checkboxes = queryAll("input.bulk-select"); const checkboxes = [...document.querySelectorAll("input.bulk-select")];
assert.ok(checkboxes[0].checked); assert.dom(checkboxes[0]).isChecked();
assert.ok(!checkboxes[1].checked); 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 { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { import { count, query, queryAll } from "discourse/tests/helpers/qunit-helpers";
count,
exists,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n"; import { i18n } from "discourse-i18n";
module( module(
@ -49,8 +44,8 @@ module(
@model={{this.post}} @model={{this.post}}
@args={{this.args}} />`); @args={{this.args}} />`);
assert.ok(exists(".names"), "includes poster name"); assert.dom(".names").exists("includes poster name");
assert.ok(exists("a.post-date"), "includes post date"); assert.dom("a.post-date").exists("includes post date");
}); });
test("post - links", async function (assert) { test("post - links", async function (assert) {
@ -161,6 +156,7 @@ module(
}); });
test("via-email without permission", async function (assert) { test("via-email without permission", async function (assert) {
this.rawEmailShown = false;
this.set("args", { via_email: true, canViewRawEmail: false }); this.set("args", { via_email: true, canViewRawEmail: false });
this.set("showRawEmail", () => (this.rawEmailShown = true)); this.set("showRawEmail", () => (this.rawEmailShown = true));
@ -170,8 +166,8 @@ module(
); );
await click(".post-info.via-email"); await click(".post-info.via-email");
assert.ok( assert.false(
!this.rawEmailShown, this.rawEmailShown,
"clicking the envelope doesn't show the raw email" "clicking the envelope doesn't show the raw email"
); );
}); });
@ -190,6 +186,7 @@ module(
}); });
test("history without view permission", async function (assert) { test("history without view permission", async function (assert) {
this.historyShown = false;
this.set("args", { version: 3, canViewEditHistory: false }); this.set("args", { version: 3, canViewEditHistory: false });
this.set("showHistory", () => (this.historyShown = true)); this.set("showHistory", () => (this.historyShown = true));
@ -199,8 +196,8 @@ module(
); );
await click(".post-info.edits"); await click(".post-info.edits");
assert.ok( assert.false(
!this.historyShown, this.historyShown,
`clicking the pencil doesn't show the history` `clicking the pencil doesn't show the history`
); );
}); });
@ -221,7 +218,7 @@ module(
await render(hbs` await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`); <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) { test(`unread indicator`, async function (assert) {
@ -230,7 +227,7 @@ module(
await render(hbs` await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`); <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) { test("reply directly above (suppressed)", async function (assert) {
@ -243,8 +240,8 @@ module(
await render(hbs` await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`); <MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`);
assert.ok(!exists("a.reply-to-tab"), "hides the tab"); assert.dom("a.reply-to-tab").doesNotExist("hides the tab");
assert.ok(!exists(".avoid-tab"), "doesn't have the avoid tab class"); assert.dom(".avoid-tab").doesNotExist("doesn't have the avoid tab class");
}); });
test("reply a few posts above (suppressed)", async function (assert) { test("reply a few posts above (suppressed)", async function (assert) {
@ -257,7 +254,7 @@ module(
await render(hbs` await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`); <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"); 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}} />` <MountWidget @widget="post" @model={{this.post}} @args={{this.args}} @expandHidden={{this.expandHidden}} />`
); );
assert.ok( assert
!exists(".topic-body .expand-hidden"), .dom(".topic-body .expand-hidden")
"button is not displayed" .doesNotExist("button is not displayed");
);
}); });
test("expand first post", async function (assert) { test("expand first post", async function (assert) {
@ -315,7 +311,7 @@ module(
); );
await click(".topic-body .expand-post"); 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) { test("can't show admin menu when you can't manage", async function (assert) {
@ -324,7 +320,7 @@ module(
await render(hbs` await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`); <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) { test("show admin menu", async function (assert) {
@ -784,7 +780,7 @@ module(
await render(hbs` await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`); <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) { test("doesn't show user status if disabled in site settings", async function (assert) {
@ -800,7 +796,7 @@ module(
await render(hbs` await render(hbs`
<MountWidget @widget="post" @model={{this.post}} @args={{this.args}} />`); <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) { test("via-email without permission", async function (assert) {
this.rawEmailShown = false;
this.set("args", { via_email: true, canViewRawEmail: false }); this.set("args", { via_email: true, canViewRawEmail: false });
this.set("showRawEmail", () => (this.rawEmailShown = true)); this.set("showRawEmail", () => (this.rawEmailShown = true));
@ -142,8 +143,8 @@ module("Integration | Component | Widget | post", function (hooks) {
); );
await click(".post-info.via-email"); await click(".post-info.via-email");
assert.ok( assert.false(
!this.rawEmailShown, this.rawEmailShown,
"clicking the envelope doesn't show the raw email" "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) { test("history without view permission", async function (assert) {
this.historyShown = false;
this.set("args", { version: 3, canViewEditHistory: false }); this.set("args", { version: 3, canViewEditHistory: false });
this.set("showHistory", () => (this.historyShown = true)); this.set("showHistory", () => (this.historyShown = true));
@ -171,9 +173,9 @@ module("Integration | Component | Widget | post", function (hooks) {
); );
await click(".post-info.edits"); await click(".post-info.edits");
assert.ok( assert.false(
!this.historyShown, this.historyShown,
`clicking the pencil doesn't show the history` "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:admin-customize-themes-show"
); );
controller.setProperties({ model: theme }); controller.setProperties({ model: theme });
assert.deepEqual( assert.true(
controller.hasSettings, controller.hasSettings,
true,
"sets the hasSettings property to true with settings" "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:admin-customize-themes-show"
); );
controller.setProperties({ model: theme }); controller.setProperties({ model: theme });
assert.deepEqual( assert.false(
controller.hasSettings, controller.hasSettings,
false,
"sets the hasSettings property to true with settings" "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); controller.set("model.second_factor_enabled", false);
assert.strictEqual(controller.canUpdateAssociatedAccounts, false); assert.false(controller.canUpdateAssociatedAccounts);
controller.set("model.is_anonymous", false); controller.set("model.is_anonymous", false);
assert.strictEqual(controller.canUpdateAssociatedAccounts, false); assert.false(controller.canUpdateAssociatedAccounts);
controller.set("model.id", 1234); 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" "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(); await controller.markRead();
assert.strictEqual( assert.true(model.every(({ read }) => read === true));
model.every(({ read }) => read === true),
true
);
}); });
test("Mark read does not mark models read when response is not successful", async function (assert) { 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"); 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) { test("allowLister", function (assert) {
const allowLister = new AllowLister(); const allowLister = new AllowLister();
assert.ok( assert.true(
Object.keys(allowLister.getAllowList().tagList).length > 1, Object.keys(allowLister.getAllowList().tagList).length > 1,
"should have some defaults" "has some defaults"
); );
allowLister.disable("default"); allowLister.disable("default");
assert.ok( assert.strictEqual(
Object.keys(allowLister.getAllowList().tagList).length === 0, Object.keys(allowLister.getAllowList().tagList).length,
"should have no defaults if disabled" 0,
"has no defaults if disabled"
); );
allowLister.allowListFeature("test", [ allowLister.allowListFeature("test", [

View File

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

View File

@ -26,7 +26,7 @@ function testOpenInANewTab(description, clickEventModifier) {
const clickEvent = generateClickEventOn("a"); const clickEvent = generateClickEventOn("a");
clickEventModifier(clickEvent); clickEventModifier(clickEvent);
assert.true(track(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", "airplane",
"it has the value of the site setting" "it has the value of the site setting"
); );
assert.ok( assert.strictEqual(
!t.missingProp, t.missingProp,
"it is falsy when the site setting is not defined" undefined,
"is falsy when the site setting is not defined"
); );
}); });
@ -47,9 +48,9 @@ module("Unit | Utility | computed", function (hooks) {
biscuits: 10, 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); 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) { test("propertyNotEqual", function (assert) {
@ -61,9 +62,9 @@ module("Unit | Utility | computed", function (hooks) {
biscuits: 10, 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); 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) { test("fmt", function (assert) {

View File

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

View File

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

View File

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

View File

@ -50,14 +50,13 @@ module(
"returns 'DOWN' for swipes with a large positive y-axis difference" "returns 'DOWN' for swipes with a large positive y-axis difference"
); );
assert.strictEqual( assert.false(
getSwipeDirection({ getSwipeDirection({
touchstartX: 50, touchstartX: 50,
touchstartY: 50, touchstartY: 50,
touchendX: 49, touchendX: 49,
touchendY: 49, touchendY: 49,
}), }),
false,
"returns 'false' for swipes with a small x-axis difference and a small y-axis difference" "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); await openImageInNewTab(lightboxItem);
assert.strictEqual( assert.true(
openStub.calledWith("image.jpg", "_blank"), openStub.calledWith("image.jpg", "_blank"),
true,
"calls window.open with the correct arguments" "calls window.open with the correct arguments"
); );
@ -33,11 +32,7 @@ module(
await openImageInNewTab(lightboxItem); await openImageInNewTab(lightboxItem);
assert.strictEqual( assert.true(consoleErrorStub.called, "logs an error to the console");
consoleErrorStub.called,
true,
"logs an error to the console"
);
openStub.restore(); openStub.restore();
consoleErrorStub.restore(); consoleErrorStub.restore();

View File

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

View File

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

View File

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

View File

@ -63,6 +63,6 @@ module("Unit | Utility | preload-store", function (hooks) {
const result = await PreloadStore.getAndRemove("falsy", () => const result = await PreloadStore.getAndRemove("falsy", () =>
assert.ok(false) 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); setupTest(hooks);
test("buildOptions", function (assert) { test("buildOptions", function (assert) {
assert.ok( assert.true(
build({ siteSettings: { enable_emoji: true } }).options.discourse.features build({ siteSettings: { enable_emoji: true } }).options.discourse.features
.emoji, .emoji,
"emoji enabled" "emoji enabled"
); );
assert.ok( assert.false(
!build({ siteSettings: { enable_emoji: false } }).options.discourse build({ siteSettings: { enable_emoji: false } }).options.discourse
.features.emoji, .features.emoji,
"emoji disabled" "emoji disabled"
); );
@ -74,51 +74,51 @@ module("Unit | Utility | pretty-text", function (hooks) {
build({ siteSettings: { allowed_iframes: "https://example.com/" } }) build({ siteSettings: { allowed_iframes: "https://example.com/" } })
.options.discourse.allowedIframes, .options.discourse.allowedIframes,
["https://example.com/"], ["https://example.com/"],
"it doesn't filter out valid urls" "doesn't filter out valid urls"
); );
assert.deepEqual( assert.deepEqual(
build({ siteSettings: { allowed_iframes: "https://example.com" } }) build({ siteSettings: { allowed_iframes: "https://example.com" } })
.options.discourse.allowedIframes, .options.discourse.allowedIframes,
[], [],
"it filters out invalid urls. Requires 3 slashes." "filters out invalid urls. Requires 3 slashes"
); );
}); });
test("basic cooking", function (assert) { test("basic cooking", function (assert) {
assert.cooked("hello", "<p>hello</p>", "surrounds text with paragraphs"); assert.cooked("hello", "<p>hello</p>", "surrounds text with paragraphs");
assert.cooked("**evil**", "<p><strong>evil</strong></p>", "it bolds text."); assert.cooked("**evil**", "<p><strong>evil</strong></p>", "bolds text");
assert.cooked("__bold__", "<p><strong>bold</strong></p>", "it bolds text."); assert.cooked("__bold__", "<p><strong>bold</strong></p>", "bolds text");
assert.cooked("*trout*", "<p><em>trout</em></p>", "it italicizes text."); assert.cooked("*trout*", "<p><em>trout</em></p>", "italicizes text");
assert.cooked("_trout_", "<p><em>trout</em></p>", "it italicizes text."); assert.cooked("_trout_", "<p><em>trout</em></p>", "italicizes text");
assert.cooked( assert.cooked(
"***hello***", "***hello***",
"<p><em><strong>hello</strong></em></p>", "<p><em><strong>hello</strong></em></p>",
"it can do bold and italics at once." "can do bold and italics at once"
); );
assert.cooked( assert.cooked(
"word_with_underscores", "word_with_underscores",
"<p>word_with_underscores</p>", "<p>word_with_underscores</p>",
"it doesn't do intraword italics" "doesn't do intraword italics"
); );
assert.cooked( assert.cooked(
"common/_special_font_face.html.erb", "common/_special_font_face.html.erb",
"<p>common/_special_font_face.html.erb</p>", "<p>common/_special_font_face.html.erb</p>",
"it doesn't intraword with a slash" "doesn't intraword with a slash"
); );
assert.cooked( assert.cooked(
"hello \\*evil\\*", "hello \\*evil\\*",
"<p>hello *evil*</p>", "<p>hello *evil*</p>",
"it supports escaping of asterisks" "supports escaping of asterisks"
); );
assert.cooked( assert.cooked(
"hello \\_evil\\_", "hello \\_evil\\_",
"<p>hello _evil_</p>", "<p>hello _evil_</p>",
"it supports escaping of italics" "supports escaping of italics"
); );
assert.cooked( assert.cooked(
"brussels sprouts are *awful*.", "brussels sprouts are *awful*.",
"<p>brussels sprouts are <em>awful</em>.</p>", "<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( assert.cooked(
"*this is italic **with some bold** inside*", "*this is italic **with some bold** inside*",
"<p><em>this is italic <strong>with some bold</strong> inside</em></p>", "<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( assert.cooked(
"[] first choice\n[] second choice", "[] first choice\n[] second choice",
"<p>[] first choice<br>\n[] second choice</p>", "<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 // note this is a change from previous engine but is correct
@ -165,13 +165,13 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked( assert.cooked(
"<blockquote>evil</blockquote>\ntrout", "<blockquote>evil</blockquote>\ntrout",
"<blockquote>evil</blockquote>\ntrout", "<blockquote>evil</blockquote>\ntrout",
"it doesn't insert <br> after blockquotes" "doesn't insert <br> after blockquotes"
); );
assert.cooked( assert.cooked(
"leading<blockquote>evil</blockquote>\ntrout", "leading<blockquote>evil</blockquote>\ntrout",
"<p>leading<blockquote>evil</blockquote><br>\ntrout</p>", "<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( assert.cooked(
"<div>hello world</div>", "<div>hello world</div>",
"<div>hello world</div>", "<div>hello world</div>",
"it doesn't surround <div> with paragraphs" "doesn't surround <div> with paragraphs"
); );
assert.cooked( assert.cooked(
"<p>hello world</p>", "<p>hello world</p>",
"<p>hello world</p>", "<p>hello world</p>",
"it doesn't surround <p> with paragraphs" "doesn't surround <p> with paragraphs"
); );
assert.cooked( assert.cooked(
"<i>hello world</i>", "<i>hello world</i>",
"<p><i>hello world</i></p>", "<p><i>hello world</i></p>",
"it surrounds inline <i> html tags with paragraphs" "surrounds inline <i> html tags with paragraphs"
); );
assert.cooked( assert.cooked(
"<b>hello world</b>", "<b>hello world</b>",
"<p><b>hello world</b></p>", "<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( assert.cooked(
"Here's a tweet:\nhttps://twitter.com/evil_trout/status/345954894420787200", "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>', '<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( assert.cooked(
"1. View @eviltrout's profile here: http://meta.discourse.org/u/eviltrout/activity<br/>next line.", "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>`, `<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( assert.cooked(
"[3]: http://eviltrout.com", "[3]: http://eviltrout.com",
"", "",
"It doesn't autolink markdown link references" "doesn't autolink markdown link references"
); );
assert.cooked( assert.cooked(
"[]: http://eviltrout.com", "[]: http://eviltrout.com",
'<p>[]: <a href="http://eviltrout.com">http://eviltrout.com</a></p>', '<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( assert.cooked(
"[b]label[/b]: description", "[b]label[/b]: description",
'<p><span class="bbcode-b">label</span>: description</p>', '<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( assert.cooked(
@ -307,7 +307,7 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked( assert.cooked(
"User [MOD]: Hello!", "User [MOD]: Hello!",
"<p>User [MOD]: Hello!</p>", "<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( assert.cooked(
@ -319,31 +319,31 @@ module("Unit | Utility | pretty-text", function (hooks) {
assert.cooked( assert.cooked(
"[http://google.com ... wat](http://discourse.org)", "[http://google.com ... wat](http://discourse.org)",
'<p><a href="http://discourse.org">http://google.com ... wat</a></p>', '<p><a href="http://discourse.org">http://google.com ... wat</a></p>',
"it supports links within links" "supports links within links"
); );
assert.cooked( assert.cooked(
"[http://google.com](http://discourse.org)", "[http://google.com](http://discourse.org)",
'<p><a href="http://discourse.org">http://google.com</a></p>', '<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( assert.cooked(
'[Link](http://www.example.com) (with an outer "description")', '[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>', '<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( assert.cooked(
"A link inside parentheses (http://www.example.com)", "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>', '<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( assert.cooked(
"[ul][1]\n\n[1]: http://eviltrout.com", "[ul][1]\n\n[1]: http://eviltrout.com",
'<p><a href="http://eviltrout.com">ul</a></p>', '<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( assert.cooked(
"> nice!", "> nice!",
"<blockquote>\n<p>nice!</p>\n</blockquote>", "<blockquote>\n<p>nice!</p>\n</blockquote>",
"it supports simple quotes" "supports simple quotes"
); );
assert.cooked( assert.cooked(
" > nice!", " > nice!",
"<blockquote>\n<p>nice!</p>\n</blockquote>", "<blockquote>\n<p>nice!</p>\n</blockquote>",
"it allows quotes with preceding spaces" "allows quotes with preceding spaces"
); );
assert.cooked( assert.cooked(
"> level 1\n> > level 2", "> level 1\n> > level 2",
"<blockquote>\n<p>level 1</p>\n<blockquote>\n<p>level 2</p>\n</blockquote>\n</blockquote>", "<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( assert.cooked(
"> level 1\n> > level 2", "> level 1\n> > level 2",
"<blockquote>\n<p>level 1</p>\n<blockquote>\n<p>level 2</p>\n</blockquote>\n</blockquote>", "<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( assert.cooked(
@ -380,13 +380,13 @@ eviltrout</p>
</blockquote> </blockquote>
</li> </li>
</ul>`, </ul>`,
"it allows quotes within a list." "allows quotes within a list"
); );
assert.cooked( assert.cooked(
"- <p>eviltrout</p>", "- <p>eviltrout</p>",
"<ul>\n<li>\n<p>eviltrout</p></li>\n</ul>", "<ul>\n<li>\n<p>eviltrout</p></li>\n</ul>",
"it allows paragraphs within a list." "allows paragraphs within a list"
); );
assert.cooked( assert.cooked(
@ -459,19 +459,19 @@ eviltrout</p>
assert.cooked( assert.cooked(
"[quote]\ntest\n[/quote]", "[quote]\ntest\n[/quote]",
'<aside class="quote no-group">\n<blockquote>\n<p>test</p>\n</blockquote>\n</aside>', '<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( assert.cooked(
"[quote]\n*test*\n[/quote]", "[quote]\n*test*\n[/quote]",
'<aside class="quote no-group">\n<blockquote>\n<p><em>test</em></p>\n</blockquote>\n</aside>', '<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( assert.cooked(
"[quote=,script='a'><script>alert('test');//':a]\n[/quote]", "[quote=,script='a'><script>alert('test');//':a]\n[/quote]",
'<aside class="quote no-group">\n<blockquote></blockquote>\n</aside>', '<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( assert.cooked(
"[@codinghorror](https://twitter.com/codinghorror)", "[@codinghorror](https://twitter.com/codinghorror)",
'<p><a href="https://twitter.com/codinghorror">@codinghorror</a></p>', '<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( assert.cooked(
"[@codinghorror](https://twitter.com/codinghorror)", "[@codinghorror](https://twitter.com/codinghorror)",
'<p><a href="https://twitter.com/codinghorror">@codinghorror</a></p>', '<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( assert.cooked(
@ -528,13 +528,13 @@ eviltrout</p>
assert.cooked( assert.cooked(
"@EvilTrout yo", "@EvilTrout yo",
'<p><span class="mention">@EvilTrout</span> yo</p>', '<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( assert.cooked(
"yo\n@EvilTrout", "yo\n@EvilTrout",
'<p>yo<br>\n<span class="mention">@EvilTrout</span></p>', '<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( assert.cooked(
@ -546,7 +546,7 @@ eviltrout</p>
assert.cooked( assert.cooked(
"```\na @test\n```", "```\na @test\n```",
'<pre><code class="lang-auto">a @test\n</code></pre>', '<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( assert.cooked(
@ -588,44 +588,44 @@ eviltrout</p>
assert.cooked( assert.cooked(
"@eviltrout and `@eviltrout`", "@eviltrout and `@eviltrout`",
'<p><span class="mention">@eviltrout</span> and <code>@eviltrout</code></p>', '<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( assert.cooked(
"1. this is a list\n\n2. this is an @eviltrout mention\n", "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>', '<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( assert.cooked(
"Hello @foo/@bar", "Hello @foo/@bar",
'<p>Hello <span class="mention">@foo</span>/<span class="mention">@bar</span></p>', '<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( assert.cooked(
"<small>a @sam c</small>", "<small>a @sam c</small>",
'<p><small>a <span class="mention">@sam</span> c</small></p>', '<p><small>a <span class="mention">@sam</span> c</small></p>',
"it allows mentions within HTML tags" "allows mentions within HTML tags"
); );
assert.cooked( assert.cooked(
"@_sam @1sam @ab-cd.123_ABC-xYz @sam1", "@_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>', '<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( assert.cooked(
"@.sam @-sam @sam. @sam_ @sam-", "@.sam @-sam @sam. @sam_ @sam-",
'<p>@.sam @-sam <span class="mention">@sam</span>. <span class="mention">@sam</span>_ <span class="mention">@sam</span>-</p>', '<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( assert.cookedOptions(
"Hello @狮子", "Hello @狮子",
{ siteSettings: { unicode_usernames: false } }, { siteSettings: { unicode_usernames: false } },
"<p>Hello @狮子</p>", "<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 @狮子", "Hello @狮子",
{ siteSettings: { unicode_usernames: true } }, { siteSettings: { unicode_usernames: true } },
'<p>Hello <span class="mention">@狮子</span></p>', '<p>Hello <span class="mention">@狮子</span></p>',
"it detects mentions of Unicode usernames" "detects mentions of Unicode usernames"
); );
assert.cookedOptions( assert.cookedOptions(
"@狮子 @_狮子 @1狮子 @狮-ø.١٢٣_Ö-ழ் @狮子1", "@狮子 @_狮子 @1狮子 @狮-ø.١٢٣_Ö-ழ் @狮子1",
{ siteSettings: { unicode_usernames: true } }, { 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>', '<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( assert.cookedOptions(
"@.狮子 @-狮子 @狮子. @狮子_ @狮子-", "@.狮子 @-狮子 @狮子. @狮子_ @狮子-",
{ siteSettings: { unicode_usernames: true } }, { siteSettings: { unicode_usernames: true } },
'<p>@.狮子 @-狮子 <span class="mention">@狮子</span>. <span class="mention">@狮子</span>_ <span class="mention">@狮子</span>-</p>', '<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( assert.cooked(
"**Bold**\n----------", "**Bold**\n----------",
'<h2><a name="bold-1" class="anchor" href="#bold-1"></a><strong>Bold</strong></h2>', '<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="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-1-2" class="anchor" href="#h-1-2"></a>1</h1>\n' +
'<h1><a name="h-3" class="anchor" href="#h-3"></a>$$</h1>', '<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( assert.cooked(
"_abc\ndef_", "_abc\ndef_",
"<p><em>abc<br>\ndef</em></p>", "<p><em>abc<br>\ndef</em></p>",
"it does allow inlines to span new lines" "does allow inlines to span new lines"
); );
assert.cooked( assert.cooked(
"_abc\n\ndef_", "_abc\n\ndef_",
"<p>_abc</p>\n<p>def_</p>", "<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) { test("Oneboxing", function (assert) {
function matches(input, regexp) { function matches(input, regexp) {
return build().cook(input).match(regexp); return !!build().cook(input).match(regexp);
} }
assert.ok( assert.false(
!matches( matches(
"- http://www.textfiles.com/bbs/MINDVOX/FORUMS/ethics\n\n- http://drupal.org", "- http://www.textfiles.com/bbs/MINDVOX/FORUMS/ethics\n\n- http://drupal.org",
/class="onebox"/ /class="onebox"/
), ),
"doesn't onebox a link within a list" "doesn't onebox a link within a list"
); );
assert.ok( assert.true(
matches("http://test.com", /class="onebox"/), matches("http://test.com", /class="onebox"/),
"adds a onebox class to a link on its own line" "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), matches("http://test.com\nhttp://test2.com", /onebox[\s\S]+onebox/m),
"supports multiple links" "supports multiple links"
); );
assert.ok( assert.false(
!matches("http://test.com bob", /onebox/), matches("http://test.com bob", /onebox/),
"doesn't onebox links that have trailing text" "doesn't onebox links that have trailing text"
); );
assert.ok( assert.false(
!matches("[Tom Cruise](http://www.tomcruise.com/)", "onebox"), matches("[Tom Cruise](http://www.tomcruise.com/)", "onebox"),
"Markdown links with labels are not oneboxed" "Markdown links with labels are not oneboxed"
); );
assert.ok( assert.false(
!matches( matches(
"[http://www.tomcruise.com/](http://www.tomcruise.com/)", "[http://www.tomcruise.com/](http://www.tomcruise.com/)",
"onebox" "onebox"
), ),
@ -804,7 +804,7 @@ eviltrout</p>
assert.cooked( assert.cooked(
"[http://eviltrout.com][1] is a url\n\n[1]: http://eviltrout.com", "[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>', '<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( assert.cooked(
"```\na\nb\nc\n\nd\n```", "```\na\nb\nc\n\nd\n```",
'<pre><code class="lang-auto">a\nb\nc\n\nd\n</code></pre>', '<pre><code class="lang-auto">a\nb\nc\n\nd\n</code></pre>',
"it treats new lines properly" "treats new lines properly"
); );
assert.cooked( assert.cooked(
"```\ntest\n```", "```\ntest\n```",
'<pre><code class="lang-auto">test\n</code></pre>', '<pre><code class="lang-auto">test\n</code></pre>',
"it supports basic code blocks" "supports basic code blocks"
); );
assert.cooked( assert.cooked(
"```json\n{hello: 'world'}\n```\ntrailing", "```json\n{hello: 'world'}\n```\ntrailing",
'<pre data-code-wrap="json"><code class="lang-json">{hello: \'world\'}\n</code></pre>\n<p>trailing</p>', '<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( assert.cooked(
"```json\nline 1\n\nline 2\n\n\nline3\n```", "```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>', '<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( assert.cooked(
"hello\nworld\n```json\nline 1\n\nline 2\n\n\nline3\n```", "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>', '<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( assert.cooked(
"```ruby\n<header>hello</header>\n```", "```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>', '<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( assert.cooked(
@ -860,7 +860,7 @@ eviltrout</p>
assert.cooked( assert.cooked(
"```ruby\n# cool\n```", "```ruby\n# cool\n```",
'<pre data-code-wrap="ruby"><code class="lang-ruby"># cool\n</code></pre>', '<pre data-code-wrap="ruby"><code class="lang-ruby"># cool\n</code></pre>',
"it supports changing the language" "supports changing the language"
); );
assert.cooked( assert.cooked(
@ -872,61 +872,61 @@ eviltrout</p>
assert.cooked( assert.cooked(
"```ruby\ndef self.parse(text)\n\n text\nend\n```", "```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>', '<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( assert.cooked(
"```ruby\nhello `eviltrout`\n```", "```ruby\nhello `eviltrout`\n```",
'<pre data-code-wrap="ruby"><code class="lang-ruby">hello `eviltrout`\n</code></pre>', '<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( assert.cooked(
"```eviltrout\nhello\n```", "```eviltrout\nhello\n```",
'<pre data-code-wrap="eviltrout"><code class="lang-eviltrout">hello\n</code></pre>', '<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( assert.cooked(
'```\n[quote="sam, post:1, topic:9441, full:true"]This is `<not>` a bug.[/quote]\n```', '```\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>', '<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( assert.cooked(
" hello\n<blockquote>test</blockquote>", " hello\n<blockquote>test</blockquote>",
"<pre><code>hello\n</code></pre>\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( assert.cooked(
"``` foo bar ```", "``` foo bar ```",
"<p><code>foo bar</code></p>", "<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( assert.cooked(
"```\nline1\n```\n```\nline2\n\nline3\n```", "```\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>', '<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( assert.cooked(
" <pre>test</pre>", " <pre>test</pre>",
"<pre><code>&lt;pre&gt;test&lt;/pre&gt;\n</code></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( assert.cooked(
" [quote]test[/quote]", " [quote]test[/quote]",
"<pre><code>[quote]test[/quote]\n</code></pre>", "<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( assert.cooked(
"## a\nb\n```\nc\n```", "## 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>', '<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( assert.cooked(
"[![folksy logo](http://folksy.com/images/folksy-colour.png)](http://folksy.com/)", "[![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>', '<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( assert.cooked(
'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">', '<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>', '<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot"></p>',
"It allows data images" "allows data images"
); );
assert.cooked( assert.cooked(
@ -991,7 +991,7 @@ eviltrout</p>
assert.cooked( assert.cooked(
"[test.pdf|attachment](upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf)", "[test.pdf|attachment](upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf)",
`<p><a class="attachment" href="/404" data-orig-href="upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf">test.pdf</a></p>`, `<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, lookupUploadUrls,
}, },
`<p><a class="attachment" href="/uploads/short-url/blah">test.pdf</a></p>`, `<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, lookupUploadUrls,
}, },
`<p><a class="attachment" href="/secure-uploads/original/3X/c/b/o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf">test.pdf</a></p>`, `<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)", "![baby shark|video](upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4)",
`<p><div class="video-placeholder-container" data-video-src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4"> `<p><div class="video-placeholder-container" data-video-src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4">
</div></p>`, </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"> `<p><div class="video-placeholder-container" data-video-src="/secure-uploads/original/3X/c/b/test.mp4">
</div></p>`, </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"> <source src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp3">
<a href="/404">/404</a> <a href="/404">/404</a>
</audio></p>`, </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"> <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> <a href="/secure-uploads/original/3X/c/b/test.mp3">/secure-uploads/original/3X/c/b/test.mp3</a>
</audio></p>`, </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( assert.cooked(
"```\n\n some code\n```", "```\n\n some code\n```",
'<pre><code class="lang-auto">\n some code\n</code></pre>', '<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( assert.cooked(
"`$&`", "`$&`",
"<p><code>$&amp;</code></p>", "<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( assert.cookedPara(
"[url]abc.com[/url]", "[url]abc.com[/url]",
'<a href="https://abc.com" data-bbcode="true">abc.com</a>', '<a href="https://abc.com" data-bbcode="true">abc.com</a>',
"it magically links using linkify" "magically links using linkify"
); );
assert.cookedPara( assert.cookedPara(
"[url]http://bettercallsaul.com[/url]", "[url]http://bettercallsaul.com[/url]",
@ -1208,7 +1208,7 @@ eviltrout</p>
assert.cooked( assert.cooked(
"[code]I am not closed\n\nThis text exists.", "[code]I am not closed\n\nThis text exists.",
"<p>[code]I am not closed</p>\n<p>This text exists.</p>", "<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( assert.cooked(
"[code]\nabc\n#def\n[/code]", "[code]\nabc\n#def\n[/code]",
'<pre><code class="lang-auto">abc\n#def</code></pre>', '<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( assert.cooked(
"[code]\n s\n[/code]", "[code]\n s\n[/code]",
'<pre><code class="lang-auto"> s</code></pre>', '<pre><code class="lang-auto"> s</code></pre>',
"it doesn't trim leading whitespace" "doesn't trim leading whitespace"
); );
assert.cooked( assert.cooked(
"> [code]\n> line 1\n> line 2\n> line 3\n> [/code]", "> [code]\n> line 1\n> line 2\n> line 3\n> [/code]",
@ -1274,7 +1274,7 @@ eviltrout</p>
<p>[sam]</p> <p>[sam]</p>
</blockquote> </blockquote>
</aside>`, </aside>`,
"it allows quotes with [] inside" "allows quotes with [] inside"
); );
assert.cooked( assert.cooked(
@ -1380,7 +1380,7 @@ var bar = 'bar';
</blockquote> </blockquote>
</aside> </aside>
<p><em>Test</em></p>`, <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="), ["data-foo", ""]);
assert.deepEqual(extractDataAttribute("foo=bar"), ["data-foo", "bar"]); assert.deepEqual(extractDataAttribute("foo=bar"), ["data-foo", "bar"]);
assert.notOk(extractDataAttribute("foo?=bar")); assert.strictEqual(extractDataAttribute("foo?=bar"), null);
assert.notOk(extractDataAttribute("https://discourse.org/?q=hello")); assert.strictEqual(
extractDataAttribute("https://discourse.org/?q=hello"),
null
);
}); });
test("video - display placeholder when previewing", function (assert) { test("video - display placeholder when previewing", function (assert) {
@ -1572,7 +1575,7 @@ var bar = 'bar';
assert.cookedOptions("(bad)", enabledTypographer, "<p>(bad)</p>"); assert.cookedOptions("(bad)", enabledTypographer, "<p>(bad)</p>");
assert.cookedOptions("+-5", enabledTypographer, "<p>±5</p>"); assert.cookedOptions("+-5", enabledTypographer, "<p>±5</p>");
assert.cookedOptions( assert.cookedOptions(
"test.. test... test..... test?..... test!....", "test.. test... test..... test?..... test!...",
enabledTypographer, enabledTypographer,
"<p>test… test… test… test?.. test!..</p>" "<p>test… test… test… test?.. test!..</p>"
); );

View File

@ -32,21 +32,21 @@ module("Unit | Utility | text-direction", function (hooks) {
test("isRTL", function (assert) { test("isRTL", function (assert) {
// Hebrew // Hebrew
assert.strictEqual(isRTL("זה מבחן"), true); assert.true(isRTL("זה מבחן"));
// Arabic // Arabic
assert.strictEqual(isRTL("هذا اختبار"), true); assert.true(isRTL("هذا اختبار"));
// Persian // Persian
assert.strictEqual(isRTL("این یک امتحان است"), true); assert.true(isRTL("این یک امتحان است"));
assert.strictEqual(isRTL("This is a test"), false); assert.false(isRTL("This is a test"));
assert.strictEqual(isRTL(""), false); assert.false(isRTL(""));
}); });
test("isLTR", function (assert) { test("isLTR", function (assert) {
assert.strictEqual(isLTR("This is a test"), true); assert.true(isLTR("This is a test"));
assert.strictEqual(isLTR("זה מבחן"), false); assert.false(isLTR("זה מבחן"));
}); });
test("setTextDirections", function (assert) { 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.id, "uppy-media-optimization");
assert.strictEqual(plugin.runParallel, true); assert.true(plugin.runParallel);
assert.strictEqual(plugin.optimizeFn(), "wow such optimized"); assert.strictEqual(plugin.optimizeFn(), "wow such optimized");
}); });

View File

@ -323,10 +323,9 @@ module("Unit | Utilities | clipboard", function (hooks) {
} }
await clipboardCopyAsync(asyncFunction); await clipboardCopyAsync(asyncFunction);
assert.strictEqual( assert.true(
this.mockClipboard.writeText.calledWith("some text to copy"), this.mockClipboard.writeText.calledWith("some text to copy"),
true, "writes to the clipboard using writeText instead of write"
"it 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 badge1 = store.createRecord("badge", { name: "New Badge" });
const badge2 = store.createRecord("badge", { id: 1, name: "Old Badge" }); const badge2 = store.createRecord("badge", { id: 1, name: "Old Badge" });
assert.ok(badge1.newBadge, "badges without ids are new"); assert.true(badge1.newBadge, "badges without ids are new");
assert.ok(!badge2.newBadge, "badges with ids are not new"); assert.false(badge2.newBadge, "badges with ids are not new");
}); });
test("createFromJson array", function (assert) { test("createFromJson array", function (assert) {
@ -29,7 +29,7 @@ module("Unit | Model | badge", function (hooks) {
const badges = Badge.createFromJson(badgesJson); 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].name, "Badge 1", "badge details are set");
assert.strictEqual( assert.strictEqual(
badges[0].badge_type.name, badges[0].badge_type.name,
@ -46,7 +46,7 @@ module("Unit | Model | badge", function (hooks) {
const badge = Badge.createFromJson(badgeJson); 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) { test("updateFromJson", function (assert) {

View File

@ -155,19 +155,19 @@ module("Unit | Model | composer", function (hooks) {
test("replyDirty", function (assert) { test("replyDirty", function (assert) {
const composer = createComposer.call(this); const composer = createComposer.call(this);
assert.ok(!composer.replyDirty, "by default it's false"); assert.false(composer.replyDirty, "false by default");
composer.setProperties({ composer.setProperties({
originalText: "hello", originalText: "hello",
reply: "hello", reply: "hello",
}); });
assert.ok( assert.false(
!composer.replyDirty, composer.replyDirty,
"it's false when the originalText is the same as the reply" "false when the originalText is the same as the reply"
); );
composer.set("reply", "hello world"); 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) { test("appendText", function (assert) {
@ -232,13 +232,13 @@ module("Unit | Model | composer", function (hooks) {
const composer = createComposer.call(this); const composer = createComposer.call(this);
composer.set("title", "asdf"); 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"); 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"); 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) { 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 }); const composer = createComposer.call(this, { action: PRIVATE_MESSAGE });
composer.set("title", "asdf"); 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"); 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"); 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) { 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) { test("editingFirstPost", function (assert) {
const composer = createComposer.call(this); 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 store = getOwner(this).lookup("service:store");
const post = store.createRecord("post", { id: 123, post_number: 2 }); const post = store.createRecord("post", { id: 123, post_number: 2 });
composer.setProperties({ post, action: EDIT }); composer.setProperties({ post, action: EDIT });
assert.ok( assert.false(
!composer.editingFirstPost, composer.editingFirstPost,
"it's false when not editing the first post" "false when not editing the first post"
); );
post.set("post_number", 1); post.set("post_number", 1);
assert.ok( assert.true(composer.editingFirstPost, "true when editing the first post");
composer.editingFirstPost,
"it's true when editing the first post"
);
}); });
test("clearState", function (assert) { test("clearState", function (assert) {
@ -309,7 +306,7 @@ module("Unit | Model | composer", function (hooks) {
draftKey: "abcd", draftKey: "abcd",
draftSequence: 1, 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) { test("initial category when uncategorized is not allowed", function (assert) {
@ -319,8 +316,9 @@ module("Unit | Model | composer", function (hooks) {
draftKey: "abcd", draftKey: "abcd",
draftSequence: 1, draftSequence: 1,
}); });
assert.ok( assert.strictEqual(
!composer.categoryId, composer.categoryId,
null,
"Uncategorized by default. Must choose a category." "Uncategorized by default. Must choose a category."
); );
}); });
@ -356,9 +354,8 @@ module("Unit | Model | composer", function (hooks) {
quote, quote,
"originalText is the quote" "originalText is the quote"
); );
assert.strictEqual( assert.false(
newComposer().replyDirty, newComposer().replyDirty,
false,
"replyDirty is initially false with a quote" "replyDirty is initially false with a quote"
); );
}); });
@ -377,17 +374,17 @@ module("Unit | Model | composer", function (hooks) {
composer.setProperties({ post, action: EDIT }); composer.setProperties({ post, action: EDIT });
composer.set("title", "asdf"); 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"); 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"); 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", ""); composer.set("title", "");
assert.ok( assert.false(
!composer.titleLengthValid, composer.titleLengthValid,
"admins must set title to at least 1 character" "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) { test("create", function (assert) {
const store = getOwner(this).lookup("service:store"); const store = getOwner(this).lookup("service:store");
assert.ok( assert.true(
store.createRecord("postStream"), !!store.createRecord("postStream"),
"it can be created with no parameters" "can be created with no parameters"
); );
}); });
test("defaults", function (assert) { test("defaults", function (assert) {
const postStream = buildStream.call(this, 1234); const postStream = buildStream.call(this, 1234);
assert.blank(postStream.posts, "there are no posts in a stream by default"); 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); 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.strictEqual(postStream.lastPostId, 4, "the last post id is 4");
assert.ok(!postStream.hasPosts, "there are no posts by default"); assert.false(postStream.hasPosts, "there are no posts by default");
assert.ok(!postStream.firstPostPresent, "the first post is not loaded"); assert.false(postStream.firstPostPresent, "the first post is not loaded");
assert.ok(!postStream.loadedAllPosts, "the last 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"); assert.strictEqual(postStream.posts.length, 0, "it has no posts initially");
postStream.appendPost( postStream.appendPost(
store.createRecord("post", { id: 2, post_number: 2 }) store.createRecord("post", { id: 2, post_number: 2 })
); );
assert.ok( assert.false(
!postStream.firstPostPresent, postStream.firstPostPresent,
"the first post is still not loaded" "the first post is still not loaded"
); );
assert.strictEqual( assert.strictEqual(
@ -64,8 +64,8 @@ module("Unit | Model | post-stream", function (hooks) {
postStream.appendPost( postStream.appendPost(
store.createRecord("post", { id: 4, post_number: 4 }) store.createRecord("post", { id: 4, post_number: 4 })
); );
assert.ok(!postStream.firstPostPresent, "the first post is still loaded"); assert.false(postStream.firstPostPresent, "the first post is still loaded");
assert.ok(postStream.loadedAllPosts, "the last post is now loaded"); assert.true(postStream.loadedAllPosts, "the last post is now loaded");
assert.strictEqual( assert.strictEqual(
postStream.posts.length, postStream.posts.length,
2, 2,
@ -97,11 +97,11 @@ module("Unit | Model | post-stream", function (hooks) {
// change the stream // change the stream
postStream.set("stream", [1, 2, 4]); postStream.set("stream", [1, 2, 4]);
assert.ok( assert.false(
!postStream.firstPostPresent, postStream.firstPostPresent,
"the first post no longer loaded since the stream changed." "the first post no longer loaded since the stream changed."
); );
assert.ok( assert.true(
postStream.loadedAllPosts, postStream.loadedAllPosts,
"the last post is still the last post in the new stream" "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.set("filter", "summary");
postStream.cancelFilter(); postStream.cancelFilter();
assert.ok(!postStream.summary, "summary is cancelled"); assert.false(postStream.summary, "summary is cancelled");
postStream.filterParticipant(participant); postStream.filterParticipant(participant);
postStream.cancelFilter(); postStream.cancelFilter();
@ -289,7 +289,7 @@ module("Unit | Model | post-stream", function (hooks) {
); );
postStream.filterParticipant(participant.username); postStream.filterParticipant(participant.username);
assert.ok( assert.true(
postStream.userFilters.includes("eviltrout"), postStream.userFilters.includes("eviltrout"),
"eviltrout is in the filters" "eviltrout is in the filters"
); );
@ -308,9 +308,8 @@ module("Unit | Model | post-stream", function (hooks) {
sinon.stub(postStream, "refresh").resolves(); sinon.stub(postStream, "refresh").resolves();
assert.strictEqual( assert.false(
postStream.filterRepliesToPostNumber, postStream.filterRepliesToPostNumber,
false,
"by default no replies are filtered" "by default no replies are filtered"
); );
@ -322,11 +321,7 @@ module("Unit | Model | post-stream", function (hooks) {
); );
postStream.cancelFilter(); postStream.cancelFilter();
assert.strictEqual( assert.false(postStream.filterRepliesToPostNumber, "cancelFilter clears");
postStream.filterRepliesToPostNumber,
false,
"cancelFilter clears"
);
}); });
test("filterUpwards", function (assert) { test("filterUpwards", function (assert) {
@ -339,17 +334,13 @@ module("Unit | Model | post-stream", function (hooks) {
sinon.stub(postStream, "refresh").resolves(); sinon.stub(postStream, "refresh").resolves();
assert.strictEqual( assert.false(postStream.filterUpwardsPostID, "by default filter is false");
postStream.filterUpwardsPostID,
false,
"by default filter is false"
);
postStream.filterUpwards(2); postStream.filterUpwards(2);
assert.strictEqual(postStream.filterUpwardsPostID, 2, "filter is set"); assert.strictEqual(postStream.filterUpwardsPostID, 2, "filter is set");
postStream.cancelFilter(); postStream.cancelFilter();
assert.strictEqual(postStream.filterUpwardsPostID, false, "filter cleared"); assert.false(postStream.filterUpwardsPostID, "filter cleared");
}); });
test("streamFilters", function (assert) { test("streamFilters", function (assert) {
@ -361,7 +352,7 @@ module("Unit | Model | post-stream", function (hooks) {
{}, {},
"there are no postFilters by default" "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"); postStream.set("filter", "summary");
assert.deepEqual( assert.deepEqual(
@ -369,7 +360,7 @@ module("Unit | Model | post-stream", function (hooks) {
{ filter: "summary" }, { filter: "summary" },
"postFilters contains the summary flag" "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); postStream.filterParticipant(participant.username);
assert.deepEqual( assert.deepEqual(
@ -401,18 +392,18 @@ module("Unit | Model | post-stream", function (hooks) {
test("loading", function (assert) { test("loading", function (assert) {
const postStream = buildStream.call(this, 1234); 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); 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); const postStream2 = buildStream.call(this, 1234);
postStream2.set("loadingBelow", true); 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); const postStream3 = buildStream.call(this, 1234);
postStream3.set("loadingFilter", true); 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) { test("nextWindow", function (assert) {
@ -660,7 +651,7 @@ module("Unit | Model | post-stream", function (hooks) {
2, 2,
"it updates the highest_post_number" "it updates the highest_post_number"
); );
assert.ok( assert.true(
postStream.loading, postStream.loading,
"it is loading while the post is being staged" "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" "it is assigned the probable post_number"
); );
assert.present(stagedPost.created_at, "it is assigned a created date"); assert.present(stagedPost.created_at, "it is assigned a created date");
assert.ok( assert.true(
postStream.posts.includes(stagedPost), postStream.posts.includes(stagedPost),
"the post is added to the stream" "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) // Undoing a created post (there was an error)
postStream.undoPost(stagedPost); postStream.undoPost(stagedPost);
assert.ok(!postStream.loading, "it is no longer loading"); assert.false(postStream.loading, "no longer loading");
assert.strictEqual( assert.strictEqual(
topic.highest_post_number, topic.highest_post_number,
1, 1,
@ -710,8 +701,8 @@ module("Unit | Model | post-stream", function (hooks) {
1, 1,
"it retains the filteredPostsCount" "it retains the filteredPostsCount"
); );
assert.ok( assert.false(
!postStream.posts.includes(stagedPost), postStream.posts.includes(stagedPost),
"the post is removed from the stream" "the post is removed from the stream"
); );
assert.strictEqual( assert.strictEqual(
@ -754,9 +745,9 @@ module("Unit | Model | post-stream", function (hooks) {
const result = postStream.stagePost(stagedPost, user); const result = postStream.stagePost(stagedPost, user);
assert.strictEqual(result, "staged", "it returns staged"); assert.strictEqual(result, "staged", "it returns staged");
assert.ok( assert.true(
postStream.loading, 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" }); stagedPost.setProperties({ id: 1234, raw: "different raw value" });
@ -773,11 +764,11 @@ module("Unit | Model | post-stream", function (hooks) {
); );
postStream.commitPost(stagedPost); postStream.commitPost(stagedPost);
assert.ok( assert.true(
postStream.posts.includes(stagedPost), postStream.posts.includes(stagedPost),
"the post is still in the stream" "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( assert.strictEqual(
postStream.filteredPostsCount, postStream.filteredPostsCount,
@ -787,7 +778,7 @@ module("Unit | Model | post-stream", function (hooks) {
const found = postStream.findLoadedPost(stagedPost.id); const found = postStream.findLoadedPost(stagedPost.id);
assert.present(found, "the post is in the identity map"); assert.present(found, "the post is in the identity map");
assert.ok( assert.true(
postStream.posts.includes(stagedPost), postStream.posts.includes(stagedPost),
"the post is in the stream" "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 }) store.createRecord("post", { id: 1, post_number: 1 })
); );
postStream.appendPost(postWithoutId); 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); postWithoutId.set("id", 2);
assert.ok( assert.true(
postStream.loadedAllPosts, postStream.loadedAllPosts,
"the last post is loaded now that the post has an id" "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" "we immediately have a larger placeholder window"
); );
assert.strictEqual(testProxy.length, 8); assert.strictEqual(testProxy.length, 8);
assert.ok(!!postsWithPlaceholders.nextObject(3, p3)); assert.true(!!postsWithPlaceholders.nextObject(3, p3));
assert.ok(!!postsWithPlaceholders.objectAt(4)); assert.true(!!postsWithPlaceholders.objectAt(4));
assert.ok(postsWithPlaceholders.objectAt(3) !== p4); assert.notStrictEqual(postsWithPlaceholders.objectAt(3), p4);
assert.ok(testProxy.objectAt(3) !== p4); assert.notStrictEqual(testProxy.objectAt(3), p4);
await promise; await promise;
assert.strictEqual(postsWithPlaceholders.objectAt(3), p4); assert.strictEqual(postsWithPlaceholders.objectAt(3), p4);

View File

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

View File

@ -94,7 +94,7 @@ module("Unit | Model | report", function (hooks) {
this, this,
[6, 8, 0, 2, 1] [6, 8, 0, 2, 1]
).yesterdayCountTitle; ).yesterdayCountTitle;
assert.ok(!title.includes("%")); assert.false(title.includes("%"));
assert.ok(title.match(/Was 0/)); 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 store = getOwner(this).lookup("service:store");
const widget = await store.find("widget", 123); const widget = await store.find("widget", 123);
assert.strictEqual(widget.name, "Trout Lure"); 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 spyBeforeUpdate = sinon.spy(widget, "beforeUpdate");
const spyAfterUpdate = sinon.spy(widget, "afterUpdate"); const spyAfterUpdate = sinon.spy(widget, "afterUpdate");
const promise = widget.update({ name: "new name" }); const promise = widget.update({ name: "new name" });
assert.ok(widget.isSaving, "it is saving"); assert.true(widget.isSaving, "it is saving");
assert.ok(spyBeforeUpdate.calledOn(widget)); assert.true(spyBeforeUpdate.calledOn(widget));
const result = await promise; const result = await promise;
assert.ok(spyAfterUpdate.calledOn(widget)); assert.true(spyAfterUpdate.calledOn(widget));
assert.ok(!widget.isSaving, "it is no longer saving"); assert.false(widget.isSaving, "it is no longer saving");
assert.strictEqual(widget.name, "new name"); assert.strictEqual(widget.name, "new name");
assert.ok(result.target, "it has a reference to the record"); 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 store = getOwner(this).lookup("service:store");
const widget = store.createRecord("widget"); const widget = store.createRecord("widget");
assert.ok(widget.isNew, "it is a new record"); assert.true(widget.isNew, "it is a new record");
assert.ok(!widget.isCreated, "it is not created"); assert.false(widget.isCreated, "it is not created");
assert.ok(!widget.isSaving, "it is not saving"); assert.false(widget.isSaving, "it is not saving");
const spyBeforeCreate = sinon.spy(widget, "beforeCreate"); const spyBeforeCreate = sinon.spy(widget, "beforeCreate");
const spyAfterCreate = sinon.spy(widget, "afterCreate"); const spyAfterCreate = sinon.spy(widget, "afterCreate");
const promise = widget.save({ name: "Evil Widget" }); const promise = widget.save({ name: "Evil Widget" });
assert.ok(widget.isSaving, "it is not saving"); assert.true(widget.isSaving, "it is not saving");
assert.ok(spyBeforeCreate.calledOn(widget)); assert.true(spyBeforeCreate.calledOn(widget));
const result = await promise; const result = await promise;
assert.ok(spyAfterCreate.calledOn(widget)); assert.true(spyAfterCreate.calledOn(widget));
assert.ok(!widget.isSaving, "it is no longer saving"); assert.false(widget.isSaving, "it is no longer saving");
assert.ok(widget.id, "it has an id"); assert.ok(widget.id, "it has an id");
assert.ok(widget.name, "Evil Widget"); assert.ok(widget.name, "Evil Widget");
assert.ok(widget.isCreated, "it is created"); assert.true(widget.isCreated, "it is created");
assert.ok(!widget.isNew, "it is no longer new"); assert.false(widget.isNew, "it is no longer new");
assert.ok(result.target, "it has a reference to the record"); assert.ok(result.target, "it has a reference to the record");
assert.strictEqual(result.target.name, widget.name); 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: [] }); const resultSet = store.createRecord("result-set", { content: [] });
assert.strictEqual(resultSet.length, 0); assert.strictEqual(resultSet.length, 0);
assert.strictEqual(resultSet.totalRows, 0); assert.strictEqual(resultSet.totalRows, 0);
assert.ok(!resultSet.loadMoreUrl); assert.strictEqual(resultSet.loadMoreUrl, null);
assert.ok(!resultSet.loading); assert.false(resultSet.loading);
assert.ok(!resultSet.loadingMore); assert.false(resultSet.loadingMore);
assert.ok(!resultSet.refreshing); assert.false(resultSet.refreshing);
}); });
test("pagination support", async function (assert) { test("pagination support", async function (assert) {
@ -21,18 +21,22 @@ module("Unit | Model | result-set", function (hooks) {
const resultSet = await store.findAll("widget"); const resultSet = await store.findAll("widget");
assert.strictEqual(resultSet.length, 2); assert.strictEqual(resultSet.length, 2);
assert.strictEqual(resultSet.totalRows, 4); assert.strictEqual(resultSet.totalRows, 4);
assert.ok(resultSet.loadMoreUrl, "has a url to load more"); assert.strictEqual(
assert.ok(!resultSet.loadingMore, "it is not loading more"); resultSet.loadMoreUrl,
assert.ok(resultSet.canLoadMore); "/load-more-widgets",
"has a url to load more"
);
assert.false(resultSet.loadingMore, "not loading more");
assert.true(resultSet.canLoadMore);
const promise = resultSet.loadMore(); const promise = resultSet.loadMore();
assert.ok(resultSet.loadingMore, "it is loading more"); assert.true(resultSet.loadingMore, "is loading more");
await promise; await promise;
assert.ok(!resultSet.loadingMore, "it finished loading more"); assert.false(resultSet.loadingMore, "finished loading more");
assert.strictEqual(resultSet.length, 4); assert.strictEqual(resultSet.length, 4);
assert.ok(!resultSet.loadMoreUrl); assert.strictEqual(resultSet.loadMoreUrl, null);
assert.ok(!resultSet.canLoadMore); assert.false(resultSet.canLoadMore);
}); });
test("refresh support", async function (assert) { test("refresh support", async function (assert) {
@ -41,13 +45,13 @@ module("Unit | Model | result-set", function (hooks) {
assert.strictEqual( assert.strictEqual(
resultSet.refreshUrl, resultSet.refreshUrl,
"/widgets?refresh=true", "/widgets?refresh=true",
"it has the refresh url" "has the refresh url"
); );
const promise = resultSet.refresh(); const promise = resultSet.refresh();
assert.ok(resultSet.refreshing, "it is refreshing"); assert.true(resultSet.refreshing, "is refreshing");
await promise; 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; const details = topic.details;
assert.present(details, "the details are present by default"); 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) { test("updateFromJson", function (assert) {

View File

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

View File

@ -317,14 +317,12 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
}; };
trackingState.sync(list, "unread"); trackingState.sync(list, "unread");
assert.strictEqual( assert.false(
list.topics[0].unseen, list.topics[0].unseen,
false,
"expect unread topic to be marked as seen" "expect unread topic to be marked as seen"
); );
assert.strictEqual( assert.true(
list.topics[0].prevent_sync, list.topics[0].prevent_sync,
true,
"expect unread topic to be marked as prevent_sync" "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 }); await publishToMessageBus("/delete", { topic_id: 111 });
assert.strictEqual( assert.true(
trackingState.findState(111).deleted, trackingState.findState(111).deleted,
true,
"marks the topic as deleted" "marks the topic as deleted"
); );
assert.strictEqual( assert.strictEqual(
@ -559,9 +556,8 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
await publishToMessageBus("/recover", { topic_id: 111 }); await publishToMessageBus("/recover", { topic_id: 111 });
assert.strictEqual( assert.false(
trackingState.findState(111).deleted, trackingState.findState(111).deleted,
false,
"marks the topic as not deleted" "marks the topic as not deleted"
); );
assert.strictEqual( assert.strictEqual(
@ -824,13 +820,13 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
assert.strictEqual(currentUser.unmuted_topics[0].topicId, 2); assert.strictEqual(currentUser.unmuted_topics[0].topicId, 2);
trackingState.pruneOldMutedAndUnmutedTopics(); trackingState.pruneOldMutedAndUnmutedTopics();
assert.strictEqual(trackingState.isMutedTopic(1), true); assert.true(trackingState.isMutedTopic(1));
assert.strictEqual(trackingState.isUnmutedTopic(2), true); assert.true(trackingState.isUnmutedTopic(2));
this.clock.tick(60000); this.clock.tick(60000);
trackingState.pruneOldMutedAndUnmutedTopics(); trackingState.pruneOldMutedAndUnmutedTopics();
assert.strictEqual(trackingState.isMutedTopic(1), false); assert.false(trackingState.isMutedTopic(1));
assert.strictEqual(trackingState.isUnmutedTopic(2), false); assert.false(trackingState.isUnmutedTopic(2));
}); });
}); });
@ -1045,7 +1041,7 @@ module("Unit | Model | topic-tracking-state | /unread", function (hooks) {
payload: { topic_ids: [112] }, 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) { 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" "new topic loaded into state"
); );
assert.strictEqual( assert.true(stateCallbackCalled, "state change callback called");
stateCallbackCalled,
true,
"state change callback called"
);
}); });
test("adds incoming so it is counted in topic lists", async function (assert) { 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( const userBadge = UserBadge.createFromJson(
cloneJSON(badgeFixtures["/user_badges"]) 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( assert.strictEqual(
userBadge.badge.name, userBadge.badge.name,
"Badge 2", "Badge 2",
@ -54,7 +54,7 @@ module("Unit | Model | user-badge", function (hooks) {
test("grant", async function (assert) { test("grant", async function (assert) {
const userBadge = await UserBadge.grant(1, "username"); 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) { 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.content, "no content by default");
assert.blank(stream.filter, "no filter 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) { test("filterParam", function (assert) {

View File

@ -13,13 +13,13 @@ module("Unit | Model | user", function (hooks) {
const store = getOwner(this).lookup("service:store"); const store = getOwner(this).lookup("service:store");
const user = store.createRecord("user", { id: 1, username: "eviltrout" }); 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"); user.toggleProperty("moderator");
assert.ok(user.staff, "moderators are staff"); assert.true(user.staff, "moderators are staff");
user.setProperties({ moderator: false, admin: true }); user.setProperties({ moderator: false, admin: true });
assert.ok(user.staff, "admins are staff"); assert.true(user.staff, "admins are staff");
}); });
test("searchContext", function (assert) { test("searchContext", function (assert) {
@ -53,27 +53,24 @@ module("Unit | Model | user", function (hooks) {
const user = store.createRecord("user", { admin: true }); const user = store.createRecord("user", { admin: true });
const group = store.createRecord("group", { automatic: true }); const group = store.createRecord("group", { automatic: true });
assert.strictEqual( assert.false(
user.canManageGroup(group), user.canManageGroup(group),
false,
"automatic groups cannot be managed." "automatic groups cannot be managed."
); );
group.set("automatic", false); group.set("automatic", false);
group.setProperties({ can_admin_group: true }); group.setProperties({ can_admin_group: true });
assert.strictEqual( assert.true(
user.canManageGroup(group), user.canManageGroup(group),
true,
"an admin should be able to manage the group" "an admin should be able to manage the group"
); );
user.set("admin", false); user.set("admin", false);
group.setProperties({ is_group_owner: true }); group.setProperties({ is_group_owner: true });
assert.strictEqual( assert.true(
user.canManageGroup(group), user.canManageGroup(group),
true,
"a group owner should be able to manage the group" "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) { test("basic state", function (assert) {
const field = new Field({ type: "text" }); const field = new Field({ type: "text" });
assert.ok(field.unchecked); assert.true(field.unchecked);
assert.ok(!field.valid); assert.false(field.valid);
assert.ok(!field.invalid); assert.false(field.invalid);
}); });
test("text - required - validation", function (assert) { test("text - required - validation", function (assert) {
const field = new Field({ type: "text", required: true }); const field = new Field({ type: "text", required: true });
assert.ok(field.unchecked); assert.true(field.unchecked);
field.validate(); field.validate();
assert.ok(!field.unchecked); assert.false(field.unchecked);
assert.ok(!field.valid); assert.false(field.valid);
assert.ok(field.invalid); assert.true(field.invalid);
field.value = "a value"; field.value = "a value";
field.validate(); field.validate();
assert.ok(!field.unchecked); assert.false(field.unchecked);
assert.ok(field.valid); assert.true(field.valid);
assert.ok(!field.invalid); assert.false(field.invalid);
}); });
test("text - optional - validation", function (assert) { test("text - optional - validation", function (assert) {
const field = new Field({ type: "text" }); const field = new Field({ type: "text" });
assert.ok(field.unchecked); assert.true(field.unchecked);
field.validate(); 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(); await channel.subscribe();
assert.strictEqual(channel.count, 3, "has the correct count"); 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"); assert.strictEqual(channel.users, null, "has null users list");
await publishToMessageBus( await publishToMessageBus(

View File

@ -21,6 +21,6 @@ module("Integration | Component | da-boolean-field", function (hooks) {
await click("input"); await click("input");
assert.dom("input").isChecked(); 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"); 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"); await click(".chat-composer-upload__remove-btn");
assert.strictEqual(this.uploadRemoved, true); assert.true(this.uploadRemoved);
}); });
test("cancelling in progress upload", async function (assert) { 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"); 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) { test(".persisted", function (assert) {
const channel = new ChatFabricators(getOwner(this)).channel(); const channel = new ChatFabricators(getOwner(this)).channel();
let message = ChatMessage.create(channel, { id: null }); let message = ChatMessage.create(channel, { id: null });
assert.strictEqual(message.persisted, false); assert.false(message.persisted);
message = ChatMessage.create(channel, { message = ChatMessage.create(channel, {
id: 1, id: 1,
staged: true, staged: true,
}); });
assert.strictEqual(message.persisted, false); assert.false(message.persisted);
message = ChatMessage.create(channel, { message = ChatMessage.create(channel, {
id: 1, id: 1,
staged: false, staged: false,
}); });
assert.strictEqual(message.persisted, true); assert.true(message.persisted);
}); });
}); });

View File

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

View File

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