DEV: uses find() helper instead of this.$() in js tests (#7062)
This commit is contained in:
@@ -6,7 +6,7 @@ componentTest("css editor", {
|
||||
template: '{{ace-editor mode="css"}}',
|
||||
test(assert) {
|
||||
assert.expect(1);
|
||||
assert.ok(this.$(".ace_editor").length, "it renders the ace editor");
|
||||
assert.ok(find(".ace_editor").length, "it renders the ace editor");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ componentTest("html editor", {
|
||||
template: '{{ace-editor mode="html" content="<b>wat</b>"}}',
|
||||
test(assert) {
|
||||
assert.expect(1);
|
||||
assert.ok(this.$(".ace_editor").length, "it renders the ace editor");
|
||||
assert.ok(find(".ace_editor").length, "it renders the ace editor");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ componentTest("sql editor", {
|
||||
template: '{{ace-editor mode="sql" content="SELECT * FROM users"}}',
|
||||
test(assert) {
|
||||
assert.expect(1);
|
||||
assert.ok(this.$(".ace_editor").length, "it renders the ace editor");
|
||||
assert.ok(find(".ace_editor").length, "it renders the ace editor");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ componentTest("disabled editor", {
|
||||
template:
|
||||
'{{ace-editor mode="sql" content="SELECT * FROM users" disabled=true}}',
|
||||
test(assert) {
|
||||
const $ace = this.$(".ace_editor");
|
||||
const $ace = find(".ace_editor");
|
||||
assert.expect(3);
|
||||
assert.ok($ace.length, "it renders the ace editor");
|
||||
assert.equal(
|
||||
|
||||
@@ -6,11 +6,11 @@ componentTest("icon only button", {
|
||||
|
||||
test(assert) {
|
||||
assert.ok(
|
||||
this.$("button.btn.btn-icon.no-text").length,
|
||||
find("button.btn.btn-icon.no-text").length,
|
||||
"it has all the classes"
|
||||
);
|
||||
assert.ok(this.$("button .d-icon.d-icon-plus").length, "it has the icon");
|
||||
assert.equal(this.$("button").attr("tabindex"), "3", "it has the tabindex");
|
||||
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");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,11 +19,11 @@ componentTest("icon and text button", {
|
||||
|
||||
test(assert) {
|
||||
assert.ok(
|
||||
this.$("button.btn.btn-icon-text").length,
|
||||
find("button.btn.btn-icon-text").length,
|
||||
"it has all the classes"
|
||||
);
|
||||
assert.ok(this.$("button .d-icon.d-icon-plus").length, "it has the icon");
|
||||
assert.ok(this.$("button span.d-button-label").length, "it has the label");
|
||||
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");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -31,8 +31,8 @@ componentTest("text only button", {
|
||||
template: '{{d-button label="topic.create"}}',
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$("button.btn.btn-text").length, "it has all the classes");
|
||||
assert.ok(this.$("button span.d-button-label").length, "it has the label");
|
||||
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");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ componentTest("preview updates with markdown", {
|
||||
template: "{{d-editor value=value}}",
|
||||
|
||||
async test(assert) {
|
||||
assert.ok(this.$(".d-editor-button-bar").length);
|
||||
assert.ok(find(".d-editor-button-bar").length);
|
||||
await fillIn(".d-editor-input", "hello **world**");
|
||||
|
||||
assert.equal(this.get("value"), "hello **world**");
|
||||
assert.equal(
|
||||
this.$(".d-editor-preview")
|
||||
find(".d-editor-preview")
|
||||
.html()
|
||||
.trim(),
|
||||
"<p>hello <strong>world</strong></p>"
|
||||
@@ -26,7 +26,7 @@ componentTest("preview sanitizes HTML", {
|
||||
async test(assert) {
|
||||
await fillIn(".d-editor-input", `"><svg onload="prompt(/xss/)"></svg>`);
|
||||
assert.equal(
|
||||
this.$(".d-editor-preview")
|
||||
find(".d-editor-preview")
|
||||
.html()
|
||||
.trim(),
|
||||
'<p>"></p>'
|
||||
@@ -43,7 +43,7 @@ componentTest("updating the value refreshes the preview", {
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(
|
||||
this.$(".d-editor-preview")
|
||||
find(".d-editor-preview")
|
||||
.html()
|
||||
.trim(),
|
||||
"<p>evil trout</p>"
|
||||
@@ -51,7 +51,7 @@ componentTest("updating the value refreshes the preview", {
|
||||
|
||||
await this.set("value", "zogstrip");
|
||||
assert.equal(
|
||||
this.$(".d-editor-preview")
|
||||
find(".d-editor-preview")
|
||||
.html()
|
||||
.trim(),
|
||||
"<p>zogstrip</p>"
|
||||
@@ -72,7 +72,7 @@ function testCase(title, testFunc) {
|
||||
this.set("value", "hello world.");
|
||||
},
|
||||
test(assert) {
|
||||
const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]);
|
||||
const textarea = jumpEnd(find("textarea.d-editor-input")[0]);
|
||||
testFunc.call(this, assert, textarea);
|
||||
}
|
||||
});
|
||||
@@ -85,7 +85,7 @@ function composerTestCase(title, testFunc) {
|
||||
this.set("value", "hello world.");
|
||||
},
|
||||
test(assert) {
|
||||
const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]);
|
||||
const textarea = jumpEnd(find("textarea.d-editor-input")[0]);
|
||||
testFunc.call(this, assert, textarea);
|
||||
}
|
||||
});
|
||||
@@ -196,13 +196,13 @@ testCase(`italic with a multiline selection`, async function(assert, textarea) {
|
||||
});
|
||||
|
||||
testCase("link modal (cancel)", async function(assert) {
|
||||
assert.equal(this.$(".insert-link.hidden").length, 1);
|
||||
assert.equal(find(".insert-link.hidden").length, 1);
|
||||
|
||||
await click("button.link");
|
||||
assert.equal(this.$(".insert-link.hidden").length, 0);
|
||||
assert.equal(find(".insert-link.hidden").length, 0);
|
||||
|
||||
await click(".insert-link button.btn-danger");
|
||||
assert.equal(this.$(".insert-link.hidden").length, 1);
|
||||
assert.equal(find(".insert-link.hidden").length, 1);
|
||||
assert.equal(this.get("value"), "hello world.");
|
||||
});
|
||||
|
||||
@@ -213,7 +213,7 @@ testCase("link modal (simple link)", async function(assert, textarea) {
|
||||
|
||||
await fillIn(".insert-link input.link-url", url);
|
||||
await click(".insert-link button.btn-primary");
|
||||
assert.equal(this.$(".insert-link.hidden").length, 1);
|
||||
assert.equal(find(".insert-link.hidden").length, 1);
|
||||
assert.equal(this.get("value"), `hello world.[${url}](${url})`);
|
||||
assert.equal(textarea.selectionStart, 13);
|
||||
assert.equal(textarea.selectionEnd, 13 + url.length);
|
||||
@@ -234,11 +234,11 @@ testCase("link modal (simple link) with selected text", async function(
|
||||
textarea.selectionEnd = 12;
|
||||
|
||||
await click("button.link");
|
||||
assert.equal(this.$("input.link-text")[0].value, "hello world.");
|
||||
assert.equal(find("input.link-text")[0].value, "hello world.");
|
||||
|
||||
await fillIn(".insert-link input.link-url", "http://eviltrout.com");
|
||||
await click(".insert-link button.btn-primary");
|
||||
assert.equal(this.$(".insert-link.hidden").length, 1);
|
||||
assert.equal(find(".insert-link.hidden").length, 1);
|
||||
assert.equal(this.get("value"), "[hello world.](http://eviltrout.com)");
|
||||
});
|
||||
|
||||
@@ -247,7 +247,7 @@ testCase("link modal (link with description)", async function(assert) {
|
||||
await fillIn(".insert-link input.link-url", "http://eviltrout.com");
|
||||
await fillIn(".insert-link input.link-text", "evil trout");
|
||||
await click(".insert-link button.btn-primary");
|
||||
assert.equal(this.$(".insert-link.hidden").length, 1);
|
||||
assert.equal(find(".insert-link.hidden").length, 1);
|
||||
assert.equal(
|
||||
this.get("value"),
|
||||
"hello world.[evil trout](http://eviltrout.com)"
|
||||
@@ -271,7 +271,7 @@ function xyz(x, y, z) {
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
const textarea = this.$("textarea.d-editor-input")[0];
|
||||
const textarea = find("textarea.d-editor-input")[0];
|
||||
textarea.selectionStart = 0;
|
||||
textarea.selectionEnd = textarea.value.length;
|
||||
|
||||
@@ -296,7 +296,7 @@ componentTest("code button", {
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]);
|
||||
const textarea = jumpEnd(find("textarea.d-editor-input")[0]);
|
||||
|
||||
await click("button.code");
|
||||
assert.equal(this.get("value"), ` ${I18n.t("composer.code_text")}`);
|
||||
@@ -384,7 +384,7 @@ componentTest("code fences", {
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]);
|
||||
const textarea = jumpEnd(find("textarea.d-editor-input")[0]);
|
||||
|
||||
await click("button.code");
|
||||
assert.equal(
|
||||
@@ -496,7 +496,7 @@ componentTest("quote button - empty lines", {
|
||||
this.set("value", "one\n\ntwo\n\nthree");
|
||||
},
|
||||
async test(assert) {
|
||||
const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]);
|
||||
const textarea = jumpEnd(find("textarea.d-editor-input")[0]);
|
||||
|
||||
textarea.selectionStart = 0;
|
||||
|
||||
@@ -517,7 +517,7 @@ componentTest("quote button - selecting empty lines", {
|
||||
this.set("value", "one\n\n\n\ntwo");
|
||||
},
|
||||
async test(assert) {
|
||||
const textarea = jumpEnd(this.$("textarea.d-editor-input")[0]);
|
||||
const textarea = jumpEnd(find("textarea.d-editor-input")[0]);
|
||||
|
||||
textarea.selectionStart = 6;
|
||||
textarea.selectionEnd = 10;
|
||||
@@ -650,7 +650,7 @@ componentTest("clicking the toggle-direction button toggles the direction", {
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
const textarea = this.$("textarea.d-editor-input");
|
||||
const textarea = find("textarea.d-editor-input");
|
||||
await click("button.toggle-direction");
|
||||
assert.equal(textarea.attr("dir"), "rtl");
|
||||
await click("button.toggle-direction");
|
||||
@@ -693,7 +693,7 @@ componentTest("emoji", {
|
||||
this.set("value", "hello world.");
|
||||
},
|
||||
async test(assert) {
|
||||
jumpEnd(this.$("textarea.d-editor-input")[0]);
|
||||
jumpEnd(find("textarea.d-editor-input")[0]);
|
||||
await click("button.emoji");
|
||||
|
||||
await click(
|
||||
|
||||
@@ -6,13 +6,13 @@ componentTest("with image", {
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(
|
||||
this.$(".d-icon-far-image").length,
|
||||
find(".d-icon-far-image").length,
|
||||
1,
|
||||
"it displays the upload icon"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.$(".d-icon-far-trash-alt").length,
|
||||
find(".d-icon-far-trash-alt").length,
|
||||
1,
|
||||
"it displays the trash icon"
|
||||
);
|
||||
@@ -32,19 +32,19 @@ componentTest("without image", {
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.$(".d-icon-far-image").length,
|
||||
find(".d-icon-far-image").length,
|
||||
1,
|
||||
"it displays the upload icon"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.$(".d-icon-far-trash-alt").length,
|
||||
find(".d-icon-far-trash-alt").length,
|
||||
0,
|
||||
"it does not display trash icon"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.$(".image-uploader-lightbox-btn").length,
|
||||
find(".image-uploader-lightbox-btn").length,
|
||||
0,
|
||||
"it does not display the button to open image lightbox"
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ componentTest("renders correctly with no properties set", {
|
||||
template: `{{text-field}}`,
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$("input[type=text]").length);
|
||||
assert.ok(find("input[type=text]").length);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,8 +18,8 @@ componentTest("support a placeholder", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$("input[type=text]").length);
|
||||
assert.equal(this.$("input").prop("placeholder"), "placeholder.i18n.key");
|
||||
assert.ok(find("input[type=text]").length);
|
||||
assert.equal(find("input").prop("placeholder"), "placeholder.i18n.key");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ componentTest("sets the dir attribute to ltr for Hebrew text", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$("input").attr("dir"), "rtl");
|
||||
assert.equal(find("input").attr("dir"), "rtl");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,6 +41,6 @@ componentTest("sets the dir attribute to ltr for English text", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$("input").attr("dir"), "ltr");
|
||||
assert.equal(find("input").attr("dir"), "ltr");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user