DEV: apply new coding standards (#10592)

This commit is contained in:
Joffrey JAFFEUX
2020-09-04 13:42:47 +02:00
committed by GitHub
parent 80dfaeb0d2
commit 52672b9eab
1473 changed files with 9386 additions and 9958 deletions
@@ -8,7 +8,7 @@ componentTest("css editor", {
test(assert) {
assert.expect(1);
assert.ok(find(".ace_editor").length, "it renders the ace editor");
}
},
});
componentTest("html editor", {
@@ -17,7 +17,7 @@ componentTest("html editor", {
test(assert) {
assert.expect(1);
assert.ok(find(".ace_editor").length, "it renders the ace editor");
}
},
});
componentTest("sql editor", {
@@ -26,7 +26,7 @@ componentTest("sql editor", {
test(assert) {
assert.expect(1);
assert.ok(find(".ace_editor").length, "it renders the ace editor");
}
},
});
componentTest("disabled editor", {
@@ -38,10 +38,7 @@ componentTest("disabled editor", {
assert.expect(3);
assert.ok($ace.length, "it renders the ace editor");
assert.equal(
$ace
.parent()
.data()
.editor.getReadOnly(),
$ace.parent().data().editor.getReadOnly(),
true,
"it sets ACE to read-only mode"
);
@@ -50,5 +47,5 @@ componentTest("disabled editor", {
"true",
"ACE wrapper has `data-disabled` attribute set to true"
);
}
},
});
@@ -2,7 +2,7 @@ import componentTest from "helpers/component-test";
import pretender from "helpers/create-pretender";
moduleForComponent("admin-report", {
integration: true
integration: true,
});
componentTest("default", {
@@ -14,9 +14,7 @@ componentTest("default", {
assert.ok(exists(".admin-report.signups", "it defaults to table mode"));
assert.equal(
find(".header .item.report")
.text()
.trim(),
find(".header .item.report").text().trim(),
"Signups",
"it has a title"
);
@@ -28,17 +26,13 @@ componentTest("default", {
);
assert.equal(
find(".admin-report-table thead tr th:first-child .title")
.text()
.trim(),
find(".admin-report-table thead tr th:first-child .title").text().trim(),
"Day",
"it has col headers"
);
assert.equal(
find(".admin-report-table thead tr th:nth-child(2) .title")
.text()
.trim(),
find(".admin-report-table thead tr th:nth-child(2) .title").text().trim(),
"Count",
"it has col headers"
);
@@ -70,7 +64,7 @@ componentTest("default", {
"7",
"it can sort rows"
);
}
},
});
componentTest("options", {
@@ -80,8 +74,8 @@ componentTest("options", {
this.set("options", {
table: {
perPage: 4,
total: false
}
total: false,
},
});
},
@@ -94,7 +88,7 @@ componentTest("options", {
);
assert.notOk(exists(".totals-sample-table"), "it hides totals");
}
},
});
componentTest("switch modes", {
@@ -105,7 +99,7 @@ componentTest("switch modes", {
assert.notOk(exists(".admin-report-table"), "it removes the table");
assert.ok(exists(".admin-report-chart"), "it shows the chart");
}
},
});
componentTest("timeout", {
@@ -113,7 +107,7 @@ componentTest("timeout", {
test(assert) {
assert.ok(exists(".alert-error.timeout"), "it displays a timeout error");
}
},
});
componentTest("no data", {
@@ -121,7 +115,7 @@ componentTest("no data", {
test(assert) {
assert.ok(exists(".no-data"), "it displays a no data alert");
}
},
});
componentTest("exception", {
@@ -129,7 +123,7 @@ componentTest("exception", {
test(assert) {
assert.ok(exists(".alert-error.exception"), "it displays an error");
}
},
});
componentTest("rate limited", {
@@ -140,11 +134,11 @@ componentTest("rate limited", {
{ "Content-Type": "application/json" },
{
errors: [
"Youve performed this action too many times. Please wait 10 seconds before trying again."
"Youve performed this action too many times. Please wait 10 seconds before trying again.",
],
error_type: "rate_limit",
extras: { wait_seconds: 10 }
}
extras: { wait_seconds: 10 },
},
];
});
},
@@ -156,7 +150,7 @@ componentTest("rate limited", {
exists(".alert-error.rate-limited"),
"it displays a rate limited error"
);
}
},
});
componentTest("not found", {
@@ -167,5 +161,5 @@ componentTest("not found", {
exists(".alert-error.not-found"),
"it displays a not found error"
);
}
},
});
@@ -14,13 +14,13 @@ componentTest("badge title", {
this.set("selectableUserBadges", [
EmberObject.create({
id: 0,
badge: { name: "(none)" }
badge: { name: "(none)" },
}),
EmberObject.create({
id: 42,
badge_id: 102,
badge: { name: "Test" }
})
badge: { name: "Test" },
}),
]);
},
@@ -28,11 +28,11 @@ componentTest("badge title", {
pretender.put("/u/eviltrout/preferences/badge_title", () => [
200,
{ "Content-Type": "application/json" },
{}
{},
]);
await this.subject.expand();
await this.subject.selectRowByValue(42);
await click(".btn");
assert.equal(this.currentUser.title, "Test");
}
},
});
@@ -10,7 +10,7 @@ componentTest("renders markdown", {
test(assert) {
const html = find(".post-body")[0].innerHTML.trim();
assert.equal(html, "<p><em>foo</em></p>");
}
},
});
componentTest("resolves short URLs", {
@@ -25,9 +25,9 @@ componentTest("resolves short URLs", {
{
short_url: "upload://a.png",
url: "/images/avatar.png",
short_path: "/images/d-logo-sketch.png"
}
]
short_path: "/images/d-logo-sketch.png",
},
],
];
});
},
@@ -39,5 +39,5 @@ componentTest("resolves short URLs", {
test(assert) {
const html = find(".post-body")[0].innerHTML.trim();
assert.equal(html, '<p><img src="/images/avatar.png" alt="an image"></p>');
}
},
});
+13 -13
View File
@@ -12,7 +12,7 @@ componentTest("icon only button", {
);
assert.ok(find("button .d-icon.d-icon-plus").length, "it has the icon");
assert.equal(find("button").attr("tabindex"), "3", "it has the tabindex");
}
},
});
componentTest("icon and text button", {
@@ -25,7 +25,7 @@ componentTest("icon and text button", {
);
assert.ok(find("button .d-icon.d-icon-plus").length, "it has the icon");
assert.ok(find("button span.d-button-label").length, "it has the label");
}
},
});
componentTest("text only button", {
@@ -34,7 +34,7 @@ componentTest("text only button", {
test(assert) {
assert.ok(find("button.btn.btn-text").length, "it has all the classes");
assert.ok(find("button span.d-button-label").length, "it has the label");
}
},
});
componentTest("form attribute", {
@@ -42,7 +42,7 @@ componentTest("form attribute", {
test(assert) {
assert.ok(exists("button[form=login-form]"), "it has the form attribute");
}
},
});
componentTest("link-styled button", {
@@ -53,7 +53,7 @@ componentTest("link-styled button", {
find("button.btn-link:not(.btn)").length,
"it has the right classes"
);
}
},
});
componentTest("isLoading button", {
@@ -83,7 +83,7 @@ componentTest("isLoading button", {
find("button:not([disabled])").length,
"while not loading the button is enabled"
);
}
},
});
componentTest("disabled button", {
@@ -99,7 +99,7 @@ componentTest("disabled button", {
this.set("disabled", false);
assert.ok(find("button:not([disabled])").length, "the button is enabled");
}
},
});
componentTest("aria-label", {
@@ -120,11 +120,11 @@ componentTest("aria-label", {
this.setProperties({
ariaLabel: null,
translatedAriaLabel: "bar"
translatedAriaLabel: "bar",
});
assert.equal(find("button")[0].getAttribute("aria-label"), "bar");
}
},
});
componentTest("title", {
@@ -143,11 +143,11 @@ componentTest("title", {
this.setProperties({
title: null,
translatedTitle: "bar"
translatedTitle: "bar",
});
assert.equal(find("button")[0].getAttribute("title"), "bar");
}
},
});
componentTest("label", {
@@ -167,9 +167,9 @@ componentTest("label", {
this.setProperties({
label: null,
translatedLabel: "bar"
translatedLabel: "bar",
});
assert.equal(find("button .d-button-label").text(), "bar");
}
},
});
+56 -67
View File
@@ -6,7 +6,7 @@ import { withPluginApi } from "discourse/lib/plugin-api";
import formatTextWithSelection from "helpers/d-editor-helper";
import {
setTextareaSelection,
getTextareaSelection
getTextareaSelection,
} from "helpers/textarea-selection-helper";
moduleForComponent("d-editor", { integration: true });
@@ -20,12 +20,10 @@ componentTest("preview updates with markdown", {
assert.equal(this.value, "hello **world**");
assert.equal(
find(".d-editor-preview")
.html()
.trim(),
find(".d-editor-preview").html().trim(),
"<p>hello <strong>world</strong></p>"
);
}
},
});
componentTest("preview sanitizes HTML", {
@@ -33,13 +31,8 @@ componentTest("preview sanitizes HTML", {
async test(assert) {
await fillIn(".d-editor-input", `"><svg onload="prompt(/xss/)"></svg>`);
assert.equal(
find(".d-editor-preview")
.html()
.trim(),
'<p>"&gt;</p>'
);
}
assert.equal(find(".d-editor-preview").html().trim(), '<p>"&gt;</p>');
},
});
componentTest("updating the value refreshes the preview", {
@@ -50,21 +43,11 @@ componentTest("updating the value refreshes the preview", {
},
async test(assert) {
assert.equal(
find(".d-editor-preview")
.html()
.trim(),
"<p>evil trout</p>"
);
assert.equal(find(".d-editor-preview").html().trim(), "<p>evil trout</p>");
await this.set("value", "zogstrip");
assert.equal(
find(".d-editor-preview")
.html()
.trim(),
"<p>zogstrip</p>"
);
}
assert.equal(find(".d-editor-preview").html().trim(), "<p>zogstrip</p>");
},
});
function jumpEnd(textarea) {
@@ -82,7 +65,7 @@ function testCase(title, testFunc) {
test(assert) {
const textarea = jumpEnd(find("textarea.d-editor-input")[0]);
testFunc.call(this, assert, textarea);
}
},
});
}
@@ -95,11 +78,14 @@ function composerTestCase(title, testFunc) {
test(assert) {
const textarea = jumpEnd(find("textarea.d-editor-input")[0]);
testFunc.call(this, assert, textarea);
}
},
});
}
testCase(`selecting the space before a word`, async function(assert, textarea) {
testCase(`selecting the space before a word`, async function (
assert,
textarea
) {
textarea.selectionStart = 5;
textarea.selectionEnd = 7;
@@ -110,7 +96,7 @@ testCase(`selecting the space before a word`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 9);
});
testCase(`selecting the space after a word`, async function(assert, textarea) {
testCase(`selecting the space after a word`, async function (assert, textarea) {
textarea.selectionStart = 0;
textarea.selectionEnd = 6;
@@ -121,7 +107,7 @@ testCase(`selecting the space after a word`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 7);
});
testCase(`bold button with no selection`, async function(assert, textarea) {
testCase(`bold button with no selection`, async function (assert, textarea) {
await click(`button.bold`);
const example = I18n.t(`composer.bold_text`);
@@ -130,7 +116,7 @@ testCase(`bold button with no selection`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 14 + example.length);
});
testCase(`bold button with a selection`, async function(assert, textarea) {
testCase(`bold button with a selection`, async function (assert, textarea) {
textarea.selectionStart = 6;
textarea.selectionEnd = 11;
@@ -145,7 +131,7 @@ testCase(`bold button with a selection`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 11);
});
testCase(`bold with a multiline selection`, async function(assert, textarea) {
testCase(`bold with a multiline selection`, async function (assert, textarea) {
this.set("value", "hello\n\nworld\n\ntest.");
textarea.selectionStart = 0;
@@ -162,7 +148,7 @@ testCase(`bold with a multiline selection`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 12);
});
testCase(`italic button with no selection`, async function(assert, textarea) {
testCase(`italic button with no selection`, async function (assert, textarea) {
await click(`button.italic`);
const example = I18n.t(`composer.italic_text`);
assert.equal(this.value, `hello world.*${example}*`);
@@ -171,7 +157,7 @@ testCase(`italic button with no selection`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 13 + example.length);
});
testCase(`italic button with a selection`, async function(assert, textarea) {
testCase(`italic button with a selection`, async function (assert, textarea) {
textarea.selectionStart = 6;
textarea.selectionEnd = 11;
@@ -186,7 +172,10 @@ testCase(`italic button with a selection`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 11);
});
testCase(`italic with a multiline selection`, async function(assert, textarea) {
testCase(`italic with a multiline selection`, async function (
assert,
textarea
) {
this.set("value", "hello\n\nworld\n\ntest.");
textarea.selectionStart = 0;
@@ -235,7 +224,7 @@ function xyz(x, y, z) {
}
`
);
}
},
});
componentTest("code button", {
@@ -317,7 +306,7 @@ third line`
assert.equal(this.value, "first line\n\nsecond line\n\nthird line");
assert.equal(textarea.selectionStart, 0);
assert.equal(textarea.selectionEnd, 23);
}
},
});
componentTest("code fences", {
@@ -430,7 +419,7 @@ third line`
assert.equal(textarea.selectionStart, 27);
assert.equal(textarea.selectionEnd, 27);
}
},
});
componentTest("quote button - empty lines", {
@@ -451,7 +440,7 @@ componentTest("quote button - empty lines", {
await click("button.quote");
assert.equal(this.value, "one\n\ntwo\n\nthree");
}
},
});
componentTest("quote button - selecting empty lines", {
@@ -467,10 +456,10 @@ componentTest("quote button - selecting empty lines", {
await click("button.quote");
assert.equal(this.value, "one\n\n\n> \n> two");
}
},
});
testCase("quote button", async function(assert, textarea) {
testCase("quote button", async function (assert, textarea) {
textarea.selectionStart = 6;
textarea.selectionEnd = 9;
@@ -492,7 +481,7 @@ testCase("quote button", async function(assert, textarea) {
assert.equal(this.value, "hello\n\nwor\n\nld.\n\n> Blockquote");
});
testCase(`bullet button with no selection`, async function(assert, textarea) {
testCase(`bullet button with no selection`, async function (assert, textarea) {
const example = I18n.t("composer.list_item");
await click(`button.bullet`);
@@ -504,7 +493,7 @@ testCase(`bullet button with no selection`, async function(assert, textarea) {
assert.equal(this.value, `hello world.\n\n${example}`);
});
testCase(`bullet button with a selection`, async function(assert, textarea) {
testCase(`bullet button with a selection`, async function (assert, textarea) {
textarea.selectionStart = 6;
textarea.selectionEnd = 11;
@@ -519,7 +508,7 @@ testCase(`bullet button with a selection`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 12);
});
testCase(`bullet button with a multiple line selection`, async function(
testCase(`bullet button with a multiple line selection`, async function (
assert,
textarea
) {
@@ -539,7 +528,7 @@ testCase(`bullet button with a multiple line selection`, async function(
assert.equal(textarea.selectionEnd, 24);
});
testCase(`list button with no selection`, async function(assert, textarea) {
testCase(`list button with no selection`, async function (assert, textarea) {
const example = I18n.t("composer.list_item");
await click(`button.list`);
@@ -553,7 +542,7 @@ testCase(`list button with no selection`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 14 + example.length);
});
testCase(`list button with a selection`, async function(assert, textarea) {
testCase(`list button with a selection`, async function (assert, textarea) {
textarea.selectionStart = 6;
textarea.selectionEnd = 11;
@@ -568,7 +557,7 @@ testCase(`list button with a selection`, async function(assert, textarea) {
assert.equal(textarea.selectionEnd, 12);
});
testCase(`list button with line sequence`, async function(assert, textarea) {
testCase(`list button with line sequence`, async function (assert, textarea) {
this.set("value", "Hello\n\nWorld\n\nEvil");
textarea.selectionStart = 0;
@@ -596,7 +585,7 @@ componentTest("clicking the toggle-direction changes dir from ltr to rtl", {
const textarea = find("textarea.d-editor-input");
await click("button.toggle-direction");
assert.equal(textarea.attr("dir"), "rtl");
}
},
});
componentTest("clicking the toggle-direction changes dir from ltr to rtl", {
@@ -611,10 +600,10 @@ componentTest("clicking the toggle-direction changes dir from ltr to rtl", {
textarea.attr("dir", "ltr");
await click("button.toggle-direction");
assert.equal(textarea.attr("dir"), "rtl");
}
},
});
testCase(`doesn't jump to bottom with long text`, async function(
testCase(`doesn't jump to bottom with long text`, async function (
assert,
textarea
) {
@@ -636,13 +625,13 @@ componentTest("emoji", {
template: "{{d-editor value=value}}",
beforeEach() {
// Test adding a custom button
withPluginApi("0.1", api => {
api.onToolbarCreate(toolbar => {
withPluginApi("0.1", (api) => {
api.onToolbarCreate((toolbar) => {
toolbar.addButton({
id: "emoji",
group: "extras",
icon: "far-smile",
action: () => toolbar.context.send("emoji")
action: () => toolbar.context.send("emoji"),
});
});
});
@@ -661,10 +650,10 @@ componentTest("emoji", {
'.emoji-picker .section[data-section="smileys_&_emotion"] img.emoji[title="grinning"]'
);
assert.equal(this.value, "hello world. :grinning:");
}
},
});
testCase("replace-text event by default", async function(assert) {
testCase("replace-text event by default", async function (assert) {
this.set("value", "red green blue");
await this.container
@@ -674,7 +663,7 @@ testCase("replace-text event by default", async function(assert) {
assert.equal(this.value, "red green blue");
});
composerTestCase("replace-text event for composer", async function(assert) {
composerTestCase("replace-text event for composer", async function (assert) {
this.set("value", "red green blue");
await this.container
@@ -695,56 +684,56 @@ composerTestCase("replace-text event for composer", async function(assert) {
{
description: "cursor at start remains there",
before: [0, 0],
after: [0, 0]
after: [0, 0],
},
{
description: "cursor before needle becomes cursor before replacement",
before: [BEFORE.indexOf(NEEDLE), 0],
after: [AFTER.indexOf(REPLACE), 0]
after: [AFTER.indexOf(REPLACE), 0],
},
{
description: "cursor at needle start + 1 moves behind replacement",
before: [BEFORE.indexOf(NEEDLE) + 1, 0],
after: [AFTER.indexOf(REPLACE) + REPLACE.length, 0]
after: [AFTER.indexOf(REPLACE) + REPLACE.length, 0],
},
{
description: "cursor at needle end - 1 stays behind replacement",
before: [BEFORE.indexOf(NEEDLE) + NEEDLE.length - 1, 0],
after: [AFTER.indexOf(REPLACE) + REPLACE.length, 0]
after: [AFTER.indexOf(REPLACE) + REPLACE.length, 0],
},
{
description: "cursor behind needle becomes cursor behind replacement",
before: [BEFORE.indexOf(NEEDLE) + NEEDLE.length, 0],
after: [AFTER.indexOf(REPLACE) + REPLACE.length, 0]
after: [AFTER.indexOf(REPLACE) + REPLACE.length, 0],
},
{
description: "cursor at end remains there",
before: [BEFORE.length, 0],
after: [AFTER.length, 0]
after: [AFTER.length, 0],
},
{
description:
"selection spanning needle start becomes selection until replacement start",
before: [BEFORE.indexOf(NEEDLE) - 1, 2],
after: [AFTER.indexOf(REPLACE) - 1, 1]
after: [AFTER.indexOf(REPLACE) - 1, 1],
},
{
description:
"selection spanning needle end becomes selection from replacement end",
before: [BEFORE.indexOf(NEEDLE) + NEEDLE.length - 1, 2],
after: [AFTER.indexOf(REPLACE) + REPLACE.length, 1]
after: [AFTER.indexOf(REPLACE) + REPLACE.length, 1],
},
{
description:
"selection spanning needle becomes selection spanning replacement",
before: [BEFORE.indexOf(NEEDLE) - 1, NEEDLE.length + 2],
after: [AFTER.indexOf(REPLACE) - 1, REPLACE.length + 2]
after: [AFTER.indexOf(REPLACE) - 1, REPLACE.length + 2],
},
{
description: "complete selection remains complete",
before: [0, BEFORE.length],
after: [0, AFTER.length]
}
after: [0, AFTER.length],
},
];
for (let i = 0; i < CASES.length; i++) {
+4 -8
View File
@@ -6,26 +6,22 @@ componentTest("default", {
template: '<div class="test">{{d-icon "bars"}}</div>',
test(assert) {
const html = find(".test")
.html()
.trim();
const html = find(".test").html().trim();
assert.equal(
html,
'<svg class="fa d-icon d-icon-bars svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use xlink:href="#bars"></use></svg>'
);
}
},
});
componentTest("with replacement", {
template: '<div class="test">{{d-icon "d-watching"}}</div>',
test(assert) {
const html = find(".test")
.html()
.trim();
const html = find(".test").html().trim();
assert.equal(
html,
'<svg class="fa d-icon d-icon-d-watching svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use xlink:href="#discourse-bell-exclamation"></use></svg>'
);
}
},
});
@@ -29,7 +29,7 @@ componentTest("default", {
test(assert) {
assert.equal(dateInput().val(), "January 29, 2019");
}
},
});
componentTest("prevents mutations", {
@@ -45,7 +45,7 @@ componentTest("prevents mutations", {
await pika(2019, 0, 2);
assert.ok(this.date.isSame(DEFAULT_DATE));
}
},
});
componentTest("allows mutations through actions", {
@@ -61,5 +61,5 @@ componentTest("allows mutations through actions", {
await pika(2019, 0, 2);
assert.ok(this.date.isSame(moment("2019-01-02")));
}
},
});
@@ -32,5 +32,5 @@ componentTest("default", {
assert.equal(fromTimeInput().dataset.name, "14:45");
assert.equal(toDateInput().value, "");
assert.equal(toTimeInput().dataset.name, "--:--");
}
},
});
@@ -32,7 +32,7 @@ componentTest("default", {
test(assert) {
assert.equal(dateInput().value, "January 29, 2019");
assert.equal(timeInput().dataset.name, "14:45");
}
},
});
componentTest("prevents mutations", {
@@ -47,7 +47,7 @@ componentTest("prevents mutations", {
await pika(2019, 0, 2);
assert.ok(this.date.isSame(DEFAULT_DATE_TIME));
}
},
});
componentTest("allows mutations through actions", {
@@ -63,7 +63,7 @@ componentTest("allows mutations through actions", {
await pika(2019, 0, 2);
assert.ok(this.date.isSame(moment("2019-01-02 14:45")));
}
},
});
componentTest("can hide time", {
@@ -75,5 +75,5 @@ componentTest("can hide time", {
async test(assert) {
assert.notOk(exists(timeInput()));
}
},
});
@@ -1,8 +1,8 @@
moduleFor("component:group-membership-button");
QUnit.test("canJoinGroup", function(assert) {
QUnit.test("canJoinGroup", function (assert) {
this.subject().setProperties({
model: { public_admission: false, is_group_user: true }
model: { public_admission: false, is_group_user: true },
});
assert.equal(
@@ -28,9 +28,9 @@ QUnit.test("canJoinGroup", function(assert) {
);
});
QUnit.test("canLeaveGroup", function(assert) {
QUnit.test("canLeaveGroup", function (assert) {
this.subject().setProperties({
model: { public_exit: false, is_group_user: false }
model: { public_exit: false, is_group_user: false },
});
assert.equal(
@@ -56,9 +56,9 @@ QUnit.test("canLeaveGroup", function(assert) {
);
});
QUnit.test("canRequestMembership", function(assert) {
QUnit.test("canRequestMembership", function (assert) {
this.subject().setProperties({
model: { allow_membership_requests: true, is_group_user: true }
model: { allow_membership_requests: true, is_group_user: true },
});
assert.equal(
@@ -76,9 +76,9 @@ QUnit.test("canRequestMembership", function(assert) {
);
});
QUnit.test("userIsGroupUser", function(assert) {
QUnit.test("userIsGroupUser", function (assert) {
this.subject().setProperties({
model: { is_group_user: true }
model: { is_group_user: true },
});
assert.equal(this.subject().get("userIsGroupUser"), true);
@@ -15,12 +15,10 @@ componentTest("highlighting code", {
test(assert) {
assert.equal(
find("code.ruby.hljs .hljs-function .hljs-keyword")
.text()
.trim(),
find("code.ruby.hljs .hljs-function .hljs-keyword").text().trim(),
"def"
);
}
},
});
componentTest("large code blocks are not highlighted", {
@@ -33,11 +31,6 @@ componentTest("large code blocks are not highlighted", {
},
test(assert) {
assert.equal(
find("code")
.text()
.trim(),
LONG_CODE_BLOCK.trim()
);
}
assert.equal(find("code").text().trim(), LONG_CODE_BLOCK.trim());
},
});
@@ -10,5 +10,5 @@ componentTest("default", {
async test(assert) {
assert.ok(exists("p.cookies"), "it displays the string as html");
}
},
});
@@ -19,5 +19,5 @@ componentTest("appends the html into the iframe", {
1,
"inserts the passed in html into the iframe"
);
}
},
});
@@ -31,7 +31,7 @@ componentTest("with image", {
1,
"it displays the image lightbox"
);
}
},
});
componentTest("without image", {
@@ -55,7 +55,7 @@ componentTest("without image", {
0,
"it does not display the button to open image lightbox"
);
}
},
});
componentTest("with placeholder", {
@@ -85,5 +85,5 @@ componentTest("with placeholder", {
1,
"it displays the placeholder image"
);
}
},
});
@@ -8,8 +8,8 @@ QUnit.module("lib:keyboard-shortcuts", {
var _bindings = {};
testMouseTrap = {
bind: function(bindings, callback) {
var registerBinding = function(binding) {
bind: function (bindings, callback) {
var registerBinding = function (binding) {
_bindings[binding] = callback;
}.bind(this);
@@ -20,9 +20,9 @@ QUnit.module("lib:keyboard-shortcuts", {
}
},
trigger: function(binding) {
trigger: function (binding) {
_bindings[binding].call();
}
},
};
sandbox.stub(DiscourseURL, "routeTo");
@@ -57,7 +57,7 @@ QUnit.module("lib:keyboard-shortcuts", {
"<div id='toggle-hamburger-menu'></div>",
"<div id='search-button'></div>",
"<div id='current-user'></div>",
"<div id='keyboard-help'></div>"
"<div id='keyboard-help'></div>",
].join("\n")
);
},
@@ -65,15 +65,15 @@ QUnit.module("lib:keyboard-shortcuts", {
afterEach() {
$("#qunit-scratch").html("");
testMouseTrap = undefined;
}
},
});
var pathBindings = KeyboardShortcuts.PATH_BINDINGS || {};
Object.keys(pathBindings).forEach(path => {
Object.keys(pathBindings).forEach((path) => {
const binding = pathBindings[path];
var testName = binding + " goes to " + path;
test(testName, function(assert) {
test(testName, function (assert) {
KeyboardShortcuts.bindEvents();
testMouseTrap.trigger(binding);
@@ -82,31 +82,31 @@ Object.keys(pathBindings).forEach(path => {
});
var clickBindings = KeyboardShortcuts.CLICK_BINDINGS || {};
Object.keys(clickBindings).forEach(selector => {
Object.keys(clickBindings).forEach((selector) => {
const binding = clickBindings[selector];
var bindings = binding.split(",");
var testName = binding + " clicks on " + selector;
test(testName, function(assert) {
test(testName, function (assert) {
KeyboardShortcuts.bindEvents();
$(selector).on("click", function() {
$(selector).on("click", function () {
assert.ok(true, selector + " was clicked");
});
bindings.forEach(function(b) {
bindings.forEach(function (b) {
testMouseTrap.trigger(b);
}, this);
});
});
var functionBindings = KeyboardShortcuts.FUNCTION_BINDINGS || {};
Object.keys(functionBindings).forEach(func => {
Object.keys(functionBindings).forEach((func) => {
const binding = functionBindings[func];
var testName = binding + " calls " + func;
test(testName, function(assert) {
sandbox.stub(KeyboardShortcuts, func, function() {
test(testName, function (assert) {
sandbox.stub(KeyboardShortcuts, func, function () {
assert.ok(true, func + " is called when " + binding + " is triggered");
});
KeyboardShortcuts.bindEvents();
@@ -115,23 +115,23 @@ Object.keys(functionBindings).forEach(func => {
});
});
QUnit.test("selectDown calls _moveSelection with 1", assert => {
QUnit.test("selectDown calls _moveSelection with 1", (assert) => {
var stub = sandbox.stub(KeyboardShortcuts, "_moveSelection");
KeyboardShortcuts.selectDown();
assert.ok(stub.calledWith(1), "_moveSelection is called with 1");
});
QUnit.test("selectUp calls _moveSelection with -1", assert => {
QUnit.test("selectUp calls _moveSelection with -1", (assert) => {
var stub = sandbox.stub(KeyboardShortcuts, "_moveSelection");
KeyboardShortcuts.selectUp();
assert.ok(stub.calledWith(-1), "_moveSelection is called with -1");
});
QUnit.test("goBack calls history.back", assert => {
QUnit.test("goBack calls history.back", (assert) => {
var called = false;
sandbox.stub(history, "back").callsFake(function() {
sandbox.stub(history, "back").callsFake(function () {
called = true;
});
@@ -139,14 +139,14 @@ QUnit.test("goBack calls history.back", assert => {
assert.ok(called, "history.back is called");
});
QUnit.test("nextSection calls _changeSection with 1", assert => {
QUnit.test("nextSection calls _changeSection with 1", (assert) => {
var spy = sandbox.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.nextSection();
assert.ok(spy.calledWith(1), "_changeSection is called with 1");
});
QUnit.test("prevSection calls _changeSection with -1", assert => {
QUnit.test("prevSection calls _changeSection with -1", (assert) => {
var spy = sandbox.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.prevSection();
@@ -13,7 +13,7 @@ componentTest("updates once after initialization", {
this.set("loadMore", () => this.set("loadedMore", true));
configureEyeline({
skipUpdate: false,
rootElement: "#ember-testing"
rootElement: "#ember-testing",
});
},
@@ -23,5 +23,5 @@ componentTest("updates once after initialization", {
test(assert) {
assert.ok(this.loadedMore);
}
},
});
@@ -39,7 +39,7 @@ componentTest("adding a value", {
"firstKey|FirstValue\nsecondKey|secondValue\nthirdKey|thirdValue",
"it adds the value to the list of values"
);
}
},
});
componentTest("adding an invalid value", {
@@ -67,7 +67,7 @@ componentTest("adding an invalid value", {
.indexOf(I18n.t("admin.site_settings.secret_list.invalid_input")) > -1,
"it shows validation error"
);
}
},
});
componentTest("removing a value", {
@@ -88,5 +88,5 @@ componentTest("removing a value", {
"secondKey|secondValue",
"it removes the expected value"
);
}
},
});
@@ -2,7 +2,7 @@ import componentTest from "helpers/component-test";
import selectKit, {
testSelectKitModule,
setDefaultState,
DEFAULT_CONTENT
DEFAULT_CONTENT,
} from "helpers/select-kit-helper";
import { withPluginApi } from "discourse/lib/plugin-api";
import { clearCallbacks } from "select-kit/mixins/plugin-api";
@@ -11,13 +11,13 @@ testSelectKitModule("select-kit:api", {
beforeEach() {
this.setProperties({
comboBox: selectKit(".combo-box"),
singleSelect: selectKit(".single-select:not(.combo-box)")
singleSelect: selectKit(".single-select:not(.combo-box)"),
});
},
afterEach() {
clearCallbacks();
}
},
});
componentTest("modifySelectKit(identifier).appendContent", {
@@ -29,11 +29,11 @@ componentTest("modifySelectKit(identifier).appendContent", {
beforeEach() {
setDefaultState(this, null, { content: DEFAULT_CONTENT });
withPluginApi("0.8.43", api => {
withPluginApi("0.8.43", (api) => {
api.modifySelectKit("combo-box").appendContent(() => {
return {
id: "alpaca",
name: "Alpaca"
name: "Alpaca",
};
});
api.modifySelectKit("combo-box").appendContent(() => {});
@@ -52,7 +52,7 @@ componentTest("modifySelectKit(identifier).appendContent", {
await this.comboBox.collapse();
assert.notOk(this.singleSelect.rowByValue("alpaca").exists());
}
},
});
componentTest("modifySelectKit(identifier).prependContent", {
@@ -64,11 +64,11 @@ componentTest("modifySelectKit(identifier).prependContent", {
beforeEach() {
setDefaultState(this, null, { content: DEFAULT_CONTENT });
withPluginApi("0.8.43", api => {
withPluginApi("0.8.43", (api) => {
api.modifySelectKit("combo-box").prependContent(() => {
return {
id: "alpaca",
name: "Alpaca"
name: "Alpaca",
};
});
api.modifySelectKit("combo-box").prependContent(() => {});
@@ -87,7 +87,7 @@ componentTest("modifySelectKit(identifier).prependContent", {
await this.comboBox.collapse();
assert.notOk(this.singleSelect.rowByValue("alpaca").exists());
}
},
});
componentTest("modifySelectKit(identifier).onChange", {
@@ -99,7 +99,7 @@ componentTest("modifySelectKit(identifier).onChange", {
beforeEach() {
setDefaultState(this, null, { content: DEFAULT_CONTENT });
withPluginApi("0.8.43", api => {
withPluginApi("0.8.43", (api) => {
api.modifySelectKit("combo-box").onChange((component, value, item) => {
find("#test").text(item.name);
});
@@ -111,5 +111,5 @@ componentTest("modifySelectKit(identifier).onChange", {
await this.comboBox.selectRowByIndex(0);
assert.equal(find("#test").text(), "foo");
}
},
});
@@ -25,7 +25,7 @@ componentTest("with value", {
async test(assert) {
assert.equal(this.subject.header().value(), 2);
assert.equal(this.subject.header().label(), "feature");
}
},
});
componentTest("with excludeCategoryId", {
@@ -34,7 +34,7 @@ componentTest("with excludeCategoryId", {
await this.subject.expand();
assert.notOk(this.subject.rowByValue(2).exists());
}
},
});
componentTest("with scopedCategoryId", {
@@ -62,7 +62,7 @@ componentTest("with scopedCategoryId", {
"bug",
"search finds outside of scope"
);
}
},
});
componentTest("with allowUncategorized=null", {
@@ -75,7 +75,7 @@ componentTest("with allowUncategorized=null", {
test(assert) {
assert.equal(this.subject.header().value(), null);
assert.equal(this.subject.header().label(), "category…");
}
},
});
componentTest("with allowUncategorized=null rootNone=true", {
@@ -88,7 +88,7 @@ componentTest("with allowUncategorized=null rootNone=true", {
test(assert) {
assert.equal(this.subject.header().value(), null);
assert.equal(this.subject.header().label(), "(no category)");
}
},
});
componentTest("with disallowed uncategorized, none", {
@@ -102,7 +102,7 @@ componentTest("with disallowed uncategorized, none", {
test(assert) {
assert.equal(this.subject.header().value(), null);
assert.equal(this.subject.header().label(), "root none label");
}
},
});
componentTest("with allowed uncategorized", {
@@ -115,7 +115,7 @@ componentTest("with allowed uncategorized", {
test(assert) {
assert.equal(this.subject.header().value(), null);
assert.equal(this.subject.header().label(), "uncategorized");
}
},
});
componentTest("with allowed uncategorized and none=true", {
@@ -128,7 +128,7 @@ componentTest("with allowed uncategorized and none=true", {
test(assert) {
assert.equal(this.subject.header().value(), null);
assert.equal(this.subject.header().label(), "(no category)");
}
},
});
componentTest("with allowed uncategorized and none", {
@@ -142,5 +142,5 @@ componentTest("with allowed uncategorized and none", {
test(assert) {
assert.equal(this.subject.header().value(), null);
assert.equal(this.subject.header().label(), "root none label");
}
},
});
@@ -5,7 +5,7 @@ import componentTest from "helpers/component-test";
import { testSelectKitModule } from "helpers/select-kit-helper";
import {
NO_CATEGORIES_ID,
ALL_CATEGORIES_ID
ALL_CATEGORIES_ID,
} from "select-kit/components/category-drop";
import { set } from "@ember/object";
@@ -15,20 +15,20 @@ function initCategories(context) {
const categories = context.site.categoriesList;
context.setProperties({
category: categories.firstObject,
categories
categories,
});
}
function initCategoriesWithParentCategory(context) {
const parentCategory = Category.findById(2);
const childCategories = context.site.categoriesList.filter(c => {
const childCategories = context.site.categoriesList.filter((c) => {
return c.parentCategory === parentCategory;
});
context.setProperties({
parentCategory,
category: null,
categories: childCategories
categories: childCategories,
});
}
@@ -60,7 +60,7 @@ componentTest("caretUpIcon", {
exists($header.find(`.d-icon-caret-right`)),
"it uses the correct default icon"
);
}
},
});
componentTest("none", {
@@ -78,7 +78,7 @@ componentTest("none", {
I18n.t("category.all").toLowerCase(),
"it uses the noneLabel"
);
}
},
});
componentTest("[not staff - TL0] displayCategoryDescription", {
@@ -99,7 +99,7 @@ componentTest("[not staff - TL0] displayCategoryDescription", {
exists(row.el().find(".category-desc")),
"it shows category description for newcomers"
);
}
},
});
componentTest("[not staff - TL1] displayCategoryDescription", {
@@ -120,7 +120,7 @@ componentTest("[not staff - TL1] displayCategoryDescription", {
!exists(row.el().find(".category-desc")),
"it doesn't shows category description for TL0+"
);
}
},
});
componentTest("[staff - TL0] displayCategoryDescription", {
@@ -141,7 +141,7 @@ componentTest("[staff - TL0] displayCategoryDescription", {
!exists(row.el().find(".category-desc")),
"it doesn't show category description for staff"
);
}
},
});
componentTest("hideParentCategory (default: false)", {
@@ -157,7 +157,7 @@ componentTest("hideParentCategory (default: false)", {
const row = this.subject.rowByValue(this.category.id);
assert.equal(row.value(), this.category.id);
assert.equal(this.category.parent_category_id, null);
}
},
});
componentTest("hideParentCategory (true)", {
@@ -179,13 +179,8 @@ componentTest("hideParentCategory (true)", {
assert.ok(childRow.exists(), "the child row is showing");
const $categoryStatus = childRow.el().find(".category-status");
assert.ok(
$categoryStatus
.text()
.trim()
.match(/^spec/)
);
}
assert.ok($categoryStatus.text().trim().match(/^spec/));
},
});
componentTest("allow_uncategorized_topics (true)", {
@@ -202,7 +197,7 @@ componentTest("allow_uncategorized_topics (true)", {
const uncategorizedCategoryId = this.site.uncategorized_category_id;
const row = this.subject.rowByValue(uncategorizedCategoryId);
assert.ok(row.exists(), "the uncategorized row is showing");
}
},
});
componentTest("allow_uncategorized_topics (false)", {
@@ -219,7 +214,7 @@ componentTest("allow_uncategorized_topics (false)", {
const uncategorizedCategoryId = this.site.uncategorized_category_id;
const row = this.subject.rowByValue(uncategorizedCategoryId);
assert.notOk(row.exists(), "the uncategorized row is not showing");
}
},
});
componentTest("countSubcategories (default: false)", {
@@ -234,18 +229,14 @@ componentTest("countSubcategories (default: false)", {
const category = Category.findById(7);
const row = this.subject.rowByValue(category.id);
const topicCount = row
.el()
.find(".topic-count")
.text()
.trim();
const topicCount = row.el().find(".topic-count").text().trim();
assert.equal(
topicCount,
"× 481",
"it doesn't include the topic count of subcategories"
);
}
},
});
componentTest("countSubcategories (true)", {
@@ -260,18 +251,14 @@ componentTest("countSubcategories (true)", {
const category = Category.findById(7);
const row = this.subject.rowByValue(category.id);
const topicCount = row
.el()
.find(".topic-count")
.text()
.trim();
const topicCount = row.el().find(".topic-count").text().trim();
assert.equal(
topicCount,
"× 584",
"it includes the topic count of subcategories"
);
}
},
});
componentTest("shortcuts:default", {
@@ -290,7 +277,7 @@ componentTest("shortcuts:default", {
this.categories.firstObject.id,
"Shortcuts are not prepended when no category is selected"
);
}
},
});
componentTest("shortcuts:category is set", {
@@ -304,7 +291,7 @@ componentTest("shortcuts:category is set", {
await this.subject.expand();
assert.equal(this.subject.rowByIndex(0).value(), ALL_CATEGORIES_ID);
}
},
});
componentTest("shortcuts with parentCategory/subCategory=true:default", {
@@ -318,7 +305,7 @@ componentTest("shortcuts with parentCategory/subCategory=true:default", {
await this.subject.expand();
assert.equal(this.subject.rowByIndex(0).value(), NO_CATEGORIES_ID);
}
},
});
componentTest(
@@ -336,7 +323,7 @@ componentTest(
assert.equal(this.subject.rowByIndex(0).value(), ALL_CATEGORIES_ID);
assert.equal(this.subject.rowByIndex(1).value(), NO_CATEGORIES_ID);
}
},
}
);
@@ -356,5 +343,5 @@ componentTest("category url", {
DiscourseURL.routeTo.calledWith("/c/feature/spec/26"),
"it builds a correct URL"
);
}
},
});
@@ -5,13 +5,13 @@ moduleForComponent("select-kit/combo-box", {
integration: true,
beforeEach() {
this.set("subject", selectKit());
}
},
});
const DEFAULT_CONTENT = [
{ id: 1, name: "foo" },
{ id: 2, name: "bar" },
{ id: 3, name: "baz" }
{ id: 3, name: "baz" },
];
const DEFAULT_VALUE = 1;
@@ -20,7 +20,7 @@ const setDefaultState = (ctx, options) => {
const properties = Object.assign(
{
content: DEFAULT_CONTENT,
value: DEFAULT_VALUE
value: DEFAULT_VALUE,
},
options || {}
);
@@ -40,9 +40,9 @@ componentTest("options.clearable", {
beforeEach() {
setDefaultState(this, {
clearable: true,
onChange: value => {
onChange: (value) => {
this.set("value", value);
}
},
});
},
@@ -62,7 +62,7 @@ componentTest("options.clearable", {
"it hides the clear button"
);
assert.equal($header.value(), null);
}
},
});
componentTest("options.{caretUpIcon,caretDownIcon}", {
@@ -80,7 +80,7 @@ componentTest("options.{caretUpIcon,caretDownIcon}", {
beforeEach() {
setDefaultState(this, {
caretUpIcon: "pencil-alt",
caretDownIcon: "trash-alt"
caretDownIcon: "trash-alt",
});
},
@@ -98,5 +98,5 @@ componentTest("options.{caretUpIcon,caretDownIcon}", {
exists($header.find(`.d-icon-${this.caretUpIcon}`)),
"it uses the icon provided"
);
}
},
});
@@ -5,13 +5,13 @@ moduleForComponent("select-kit/dropdown-select-box", {
integration: true,
beforeEach() {
this.set("subject", selectKit());
}
},
});
const DEFAULT_CONTENT = [
{ id: 1, name: "foo" },
{ id: 2, name: "bar" },
{ id: 3, name: "baz" }
{ id: 3, name: "baz" },
];
const DEFAULT_VALUE = 1;
@@ -21,9 +21,9 @@ const setDefaultState = (ctx, options) => {
{
content: DEFAULT_CONTENT,
value: DEFAULT_VALUE,
onChange: value => {
onChange: (value) => {
this.set("value", value);
}
},
},
options || {}
);
@@ -51,7 +51,7 @@ componentTest("selection behavior", {
this.subject.isExpanded(),
"it collapses the dropdown on select"
);
}
},
});
componentTest("options.showFullTitle=false", {
@@ -71,30 +71,22 @@ componentTest("options.showFullTitle=false", {
setDefaultState(this, {
value: null,
showFullTitle: false,
none: "test_none"
none: "test_none",
});
},
async test(assert) {
assert.ok(
!exists(
this.subject
.header()
.el()
.find(".selected-name")
),
!exists(this.subject.header().el().find(".selected-name")),
"it hides the text of the selected item"
);
assert.equal(
this.subject
.header()
.el()
.attr("title"),
this.subject.header().el().attr("title"),
"[en_US.test_none]",
"it adds a title attribute to the button"
);
}
},
});
componentTest("options.showFullTitle=true", {
@@ -114,13 +106,8 @@ componentTest("options.showFullTitle=true", {
async test(assert) {
assert.ok(
exists(
this.subject
.header()
.el()
.find(".selected-name")
),
exists(this.subject.header().el().find(".selected-name")),
"it shows the text of the selected item"
);
}
},
});
@@ -31,5 +31,5 @@ componentTest("default", {
assert.equal(this.subject.rows().length, 1);
assert.equal(this.subject.rowByIndex(0).value(), "underline");
}
},
});
@@ -17,7 +17,7 @@ componentTest("displays tags", {
async test(assert) {
assert.equal(this.subject.header().value(), "foo,bar");
}
},
});
componentTest("create a tag", {
@@ -32,23 +32,13 @@ componentTest("create a tag", {
await this.subject.expand();
await this.subject.fillInFilter("mon");
assert.equal(
find(".select-kit-row")
.text()
.trim(),
"monkey x1"
);
assert.equal(find(".select-kit-row").text().trim(), "monkey x1");
await this.subject.fillInFilter("key");
assert.equal(
find(".select-kit-row")
.text()
.trim(),
"monkey x1"
);
assert.equal(find(".select-kit-row").text().trim(), "monkey x1");
await this.subject.keyboard("enter");
assert.equal(this.subject.header().value(), "foo,bar,monkey");
}
},
});
componentTest("max_tags_per_topic", {
@@ -70,8 +60,8 @@ componentTest("max_tags_per_topic", {
assert.equal(
error,
I18n.t("select_kit.max_content_reached", {
count: this.siteSettings.max_tags_per_topic
count: this.siteSettings.max_tags_per_topic,
})
);
}
},
});
@@ -18,14 +18,14 @@ function template(options = []) {
const DEFAULT_CONTENT = [
{ id: 1, name: "foo" },
{ id: 2, name: "bar" },
{ id: 3, name: "baz" }
{ id: 3, name: "baz" },
];
const setDefaultState = (ctx, options) => {
const properties = Object.assign(
{
content: DEFAULT_CONTENT,
value: null
value: null,
},
options || {}
);
@@ -59,5 +59,5 @@ componentTest("content", {
null,
"it doesn't set a value from the content"
);
}
},
});
@@ -1,7 +1,7 @@
import componentTest from "helpers/component-test";
import {
testSelectKitModule,
setDefaultState
setDefaultState,
} from "helpers/select-kit-helper";
testSelectKitModule("notifications-button");
@@ -39,5 +39,5 @@ componentTest("default", {
icon.classList.contains("d-icon-d-regular"),
"it shows the correct icon"
);
}
},
});
@@ -2,20 +2,20 @@ import selectKit from "helpers/select-kit-helper";
import componentTest from "helpers/component-test";
import Topic from "discourse/models/topic";
const buildTopic = function(pinned = true) {
const buildTopic = function (pinned = true) {
return Topic.create({
id: 1234,
title: "Qunit Test Topic",
deleted_at: new Date(),
pinned
pinned,
});
};
moduleForComponent("select-kit/pinned-options", {
integration: true,
beforeEach: function() {
beforeEach: function () {
this.set("subject", selectKit());
}
},
});
componentTest("unpinning", {
@@ -33,7 +33,7 @@ componentTest("unpinning", {
await this.subject.selectRowByValue("unpinned");
assert.equal(this.subject.header().name(), "unpinned");
}
},
});
componentTest("pinning", {
@@ -51,5 +51,5 @@ componentTest("pinning", {
await this.subject.selectRowByValue("pinned");
assert.equal(this.subject.header().name(), "pinned");
}
},
});
@@ -22,7 +22,7 @@ function template(options = []) {
const DEFAULT_CONTENT = [
{ id: 1, name: "foo" },
{ id: 2, name: "bar" },
{ id: 3, name: "baz" }
{ id: 3, name: "baz" },
];
const DEFAULT_VALUE = 1;
@@ -34,9 +34,9 @@ const setDefaultState = (ctx, options) => {
value: DEFAULT_VALUE,
nameProperty: "name",
valueProperty: "id",
onChange: value => {
onChange: (value) => {
ctx.set("value", value);
}
},
},
options || {}
);
@@ -70,7 +70,7 @@ componentTest("content", {
null,
"it doesn't set a value from the content"
);
}
},
});
componentTest("value", {
@@ -86,7 +86,7 @@ componentTest("value", {
1,
"it selects the correct content to display"
);
}
},
});
componentTest("options.filterable", {
@@ -107,7 +107,7 @@ componentTest("options.filterable", {
filter,
"it filters the list"
);
}
},
});
componentTest("options.limitMatches", {
@@ -126,7 +126,7 @@ componentTest("options.limitMatches", {
1,
"it returns only 1 result"
);
}
},
});
componentTest("valueAttribute (deprecated)", {
@@ -146,7 +146,7 @@ componentTest("valueAttribute (deprecated)", {
{ name: "Smaller", value: "smaller" },
{ name: "Normal", value: "normal" },
{ name: "Larger", value: "larger" },
{ name: "Largest", value: "largest" }
{ name: "Largest", value: "largest" },
];
this.set("content", content);
},
@@ -155,7 +155,7 @@ componentTest("valueAttribute (deprecated)", {
await this.subject.expand();
assert.equal(this.subject.selectedRow().value(), this.value);
}
},
});
componentTest("none:string", {
@@ -172,7 +172,7 @@ componentTest("none:string", {
const noneRow = this.subject.rowByIndex(0);
assert.equal(noneRow.value(), null);
assert.equal(noneRow.name(), I18n.t("test.none"));
}
},
});
componentTest("none:object", {
@@ -188,7 +188,7 @@ componentTest("none:object", {
const noneRow = this.subject.rowByIndex(0);
assert.equal(noneRow.value(), null);
assert.equal(noneRow.name(), "(default)");
}
},
});
componentTest("content is a basic array", {
@@ -200,7 +200,7 @@ componentTest("content is a basic array", {
nameProperty: null,
valueProperty: null,
value: "foo",
content: ["foo", "bar", "baz"]
content: ["foo", "bar", "baz"],
});
},
@@ -215,7 +215,7 @@ componentTest("content is a basic array", {
await this.subject.selectRowByIndex(0);
assert.equal(this.value, null);
}
},
});
componentTest("selected value can be 0", {
@@ -226,8 +226,8 @@ componentTest("selected value can be 0", {
value: 1,
content: [
{ id: 0, name: "foo" },
{ id: 1, name: "bar" }
]
{ id: 1, name: "bar" },
],
});
},
@@ -238,7 +238,7 @@ componentTest("selected value can be 0", {
await this.subject.selectRowByValue(0);
assert.equal(this.subject.header().value(), 0);
}
},
});
componentTest("prevents propagating click event on header", {
@@ -249,7 +249,7 @@ componentTest("prevents propagating click event on header", {
this.setProperties({
onClick: () => this.set("value", "foo"),
content: DEFAULT_CONTENT,
value: DEFAULT_VALUE
value: DEFAULT_VALUE,
});
},
@@ -257,7 +257,7 @@ componentTest("prevents propagating click event on header", {
assert.equal(this.value, DEFAULT_VALUE);
await this.subject.expand();
assert.equal(this.value, DEFAULT_VALUE);
}
},
});
componentTest("labelProperty", {
@@ -266,7 +266,7 @@ componentTest("labelProperty", {
beforeEach() {
this.setProperties({
content: [{ id: 1, name: "john", foo: "JACKSON" }],
value: 1
value: 1,
});
},
@@ -278,7 +278,7 @@ componentTest("labelProperty", {
const row = this.subject.rowByValue(1);
assert.equal(row.label(), "JACKSON");
}
},
});
componentTest("titleProperty", {
@@ -287,7 +287,7 @@ componentTest("titleProperty", {
beforeEach() {
this.setProperties({
content: [{ id: 1, name: "john", foo: "JACKSON" }],
value: 1
value: 1,
});
},
@@ -299,5 +299,5 @@ componentTest("titleProperty", {
const row = this.subject.rowByValue(1);
assert.equal(row.title(), "JACKSON");
}
},
});
@@ -10,36 +10,36 @@ testSelectKitModule("tag-drop", {
const site = Site.current();
set(site, "top_tags", ["jeff", "neil", "arpit", "régis"]);
const response = object => {
const response = (object) => {
return [200, { "Content-Type": "application/json" }, object];
};
pretender.get("/tags/filter/search", params => {
pretender.get("/tags/filter/search", (params) => {
if (params.queryParams.q === "rég") {
return response({
results: [{ id: "régis", text: "régis", count: 2, pm_count: 0 }]
results: [{ id: "régis", text: "régis", count: 2, pm_count: 0 }],
});
} else if (params.queryParams.q === "dav") {
return response({
results: [{ id: "David", text: "David", count: 2, pm_count: 0 }]
results: [{ id: "David", text: "David", count: 2, pm_count: 0 }],
});
}
});
}
},
});
function initTags(context) {
const categories = context.site.categoriesList;
const parentCategory = categories.findBy("id", 2);
const childCategories = categories.filter(
c => c.parentCategory === parentCategory
(c) => c.parentCategory === parentCategory
);
// top_tags
context.setProperties({
firstCategory: parentCategory,
secondCategory: childCategories.firstObject,
tagId: "jeff"
tagId: "jeff",
});
}
@@ -85,5 +85,5 @@ componentTest("default", {
I18n.t("tagging.selector_all_tags"),
"it has the correct label for all-tags"
);
}
},
});
@@ -3,15 +3,15 @@ import selectKit from "helpers/select-kit-helper";
import componentTest from "helpers/component-test";
import Topic from "discourse/models/topic";
const buildTopic = function(level, archetype = "regular") {
const buildTopic = function (level, archetype = "regular") {
return Topic.create({
id: 4563
id: 4563,
}).updateFromJson({
title: "Qunit Test Topic",
details: {
notification_level: level
notification_level: level,
},
archetype
archetype,
});
};
@@ -23,7 +23,7 @@ moduleForComponent("select-kit/topic-notifications-button", {
afterEach() {
I18n.translations.en.js.topic.notifications.tracking_pm.title = originalTranslation;
}
},
});
componentTest("the header has a localized title", {
@@ -36,9 +36,7 @@ componentTest("the header has a localized title", {
async test(assert) {
assert.equal(
selectKit()
.header()
.label(),
selectKit().header().label(),
"Normal",
"it has the correct label"
);
@@ -46,13 +44,11 @@ componentTest("the header has a localized title", {
await this.set("topic", buildTopic(2));
assert.equal(
selectKit()
.header()
.label(),
selectKit().header().label(),
"Tracking",
"it correctly changes the label"
);
}
},
});
componentTest("the header has a localized title", {
@@ -66,11 +62,9 @@ componentTest("the header has a localized title", {
test(assert) {
assert.equal(
selectKit()
.header()
.label(),
selectKit().header().label(),
`${originalTranslation} PM`,
"it has the correct label for PMs"
);
}
},
});
@@ -3,34 +3,34 @@ import selectKit from "helpers/select-kit-helper";
import componentTest from "helpers/component-test";
import Topic from "discourse/models/topic";
const buildTopic = function(archetype) {
const buildTopic = function (archetype) {
return Topic.create({
id: 4563
id: 4563,
}).updateFromJson({
title: "Qunit Test Topic",
details: {
notification_level: 1
notification_level: 1,
},
archetype
archetype,
});
};
function extractDescs(rows) {
return Array.from(
rows.find(".desc").map(function() {
rows.find(".desc").map(function () {
return this.textContent.trim();
})
);
}
function getTranslations(type = "") {
return ["watching", "tracking", "regular", "muted"].map(key => {
return ["watching", "tracking", "regular", "muted"].map((key) => {
return I18n.t(`topic.notifications.${key}${type}.description`);
});
}
moduleForComponent("select-kit/topic-notifications-options", {
integration: true
integration: true,
});
componentTest("regular topic notification level descriptions", {
@@ -59,7 +59,7 @@ componentTest("regular topic notification level descriptions", {
"it has the correct copy"
);
});
}
},
});
componentTest("PM topic notification level descriptions", {
@@ -89,5 +89,5 @@ componentTest("PM topic notification level descriptions", {
"it has the correct copy"
);
});
}
},
});
@@ -16,7 +16,7 @@ componentTest("displays usernames", {
async test(assert) {
assert.equal(this.subject.header().name(), "bob,martin");
}
},
});
componentTest("can remove a username", {
@@ -29,5 +29,5 @@ componentTest("can remove a username", {
async test(assert) {
await this.subject.deselectItem("bob");
assert.equal(this.subject.header().name(), "martin");
}
},
});
@@ -12,5 +12,5 @@ componentTest("share button", {
find('button[data-share-url="https://eviltrout.com"]').length,
"it has the data attribute for sharing"
);
}
},
});
+1 -1
View File
@@ -9,5 +9,5 @@ export default Button.extend({
click() {
return true;
}
},
});
@@ -34,7 +34,7 @@ componentTest("adding a value", {
find(".values .value").length === 4,
"it adds the value when keying Enter"
);
}
},
});
componentTest("removing a value", {
@@ -56,7 +56,7 @@ componentTest("removing a value", {
find(".values .value[data-index='0'] .value-input")[0].value === "osama",
"it removes the correct value"
);
}
},
});
componentTest("delimiter support", {
@@ -80,5 +80,5 @@ componentTest("delimiter support", {
"eviltrout",
"it adds the correct value"
);
}
},
});
@@ -8,7 +8,7 @@ componentTest("renders correctly with no properties set", {
test(assert) {
assert.ok(find("input[type=text]").length);
}
},
});
componentTest("support a placeholder", {
@@ -21,7 +21,7 @@ componentTest("support a placeholder", {
test(assert) {
assert.ok(find("input[type=text]").length);
assert.equal(find("input").prop("placeholder"), "placeholder.i18n.key");
}
},
});
componentTest("sets the dir attribute to ltr for Hebrew text", {
@@ -32,7 +32,7 @@ componentTest("sets the dir attribute to ltr for Hebrew text", {
test(assert) {
assert.equal(find("input").attr("dir"), "rtl");
}
},
});
componentTest("sets the dir attribute to ltr for English text", {
@@ -43,7 +43,7 @@ componentTest("sets the dir attribute to ltr for English text", {
test(assert) {
assert.equal(find("input").attr("dir"), "ltr");
}
},
});
componentTest("supports onChange", {
@@ -52,7 +52,7 @@ componentTest("supports onChange", {
this.called = false;
this.newValue = null;
this.set("value", "hello");
this.set("changed", v => {
this.set("changed", (v) => {
this.newValue = v;
this.called = true;
});
@@ -63,7 +63,7 @@ componentTest("supports onChange", {
await fillIn(".tf-test", "new text");
assert.ok(this.called);
assert.equal(this.newValue, "new text");
}
},
});
componentTest("supports onChangeImmediate", {
@@ -72,7 +72,7 @@ componentTest("supports onChangeImmediate", {
this.called = false;
this.newValue = null;
this.set("value", "old");
this.set("changed", v => {
this.set("changed", (v) => {
this.newValue = v;
this.called = true;
});
@@ -83,5 +83,5 @@ componentTest("supports onChangeImmediate", {
await fillIn(".tf-test", "no longer old");
assert.ok(this.called);
assert.equal(this.newValue, "no longer old");
}
},
});
@@ -6,7 +6,7 @@ moduleForComponent("time-input", {
beforeEach() {
this.set("subject", selectKit());
}
},
});
function setTime(time) {
@@ -22,7 +22,7 @@ componentTest("default", {
test(assert) {
assert.equal(this.subject.header().name(), "14:58");
}
},
});
componentTest("prevents mutations", {
@@ -36,7 +36,7 @@ componentTest("prevents mutations", {
await this.subject.expand();
await this.subject.selectRowByIndex(3);
assert.equal(this.subject.header().name(), "14:58");
}
},
});
componentTest("allows mutations through actions", {
@@ -51,5 +51,5 @@ componentTest("allows mutations through actions", {
await this.subject.expand();
await this.subject.selectRowByIndex(3);
assert.equal(this.subject.header().name(), "00:45");
}
},
});
@@ -35,7 +35,7 @@ componentTest("pasting a list of usernames", {
this.set("usernames", null);
paste(element, "eviltrout\nsam\ncodinghorror");
assert.equal(this.get("usernames"), "eviltrout,sam,codinghorror");
}
},
});
componentTest("excluding usernames", {
@@ -50,5 +50,5 @@ componentTest("excluding usernames", {
let element = find(".test-selector")[0];
paste(element, "roman,penar,jeff,robin");
assert.equal(this.get("usernames"), "mark,roman,penar");
}
},
});
@@ -26,7 +26,7 @@ componentTest("adding a value", {
"vinkas\nosama\neviltrout",
"it adds the value to the list of values"
);
}
},
});
componentTest("removing a value", {
@@ -53,7 +53,7 @@ componentTest("removing a value", {
.innerText === "vinkas",
"it adds the removed value to choices"
);
}
},
});
componentTest("selecting a value", {
@@ -62,7 +62,7 @@ componentTest("selecting a value", {
beforeEach() {
this.setProperties({
values: "vinkas\nosama",
choices: ["maja", "michael"]
choices: ["maja", "michael"],
});
},
@@ -80,7 +80,7 @@ componentTest("selecting a value", {
"vinkas\nosama\nmaja",
"it adds the value to the list of values"
);
}
},
});
componentTest("array support", {
@@ -107,7 +107,7 @@ componentTest("array support", {
["vinkas", "osama", "eviltrout"],
"it adds the value to the list of values"
);
}
},
});
componentTest("delimiter support", {
@@ -134,5 +134,5 @@ componentTest("delimiter support", {
"vinkas|osama|eviltrout",
"it adds the value to the list of values"
);
}
},
});