mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 19:14:43 +08:00
DEV: uses find() helper instead of this.$() in js tests (#7062)
This commit is contained in:
@ -11,7 +11,7 @@ componentTest("default theme", {
|
||||
|
||||
test(assert) {
|
||||
assert.expect(1);
|
||||
assert.equal(this.$(".d-icon-check").length, 1, "shows default theme icon");
|
||||
assert.equal(find(".d-icon-check").length, 1, "shows default theme icon");
|
||||
}
|
||||
});
|
||||
|
||||
@ -26,7 +26,7 @@ componentTest("pending updates", {
|
||||
|
||||
test(assert) {
|
||||
assert.expect(1);
|
||||
assert.equal(this.$(".d-icon-sync").length, 1, "shows pending update icon");
|
||||
assert.equal(find(".d-icon-sync").length, 1, "shows pending update icon");
|
||||
}
|
||||
});
|
||||
|
||||
@ -45,7 +45,7 @@ componentTest("broken theme", {
|
||||
test(assert) {
|
||||
assert.expect(1);
|
||||
assert.equal(
|
||||
this.$(".d-icon-exclamation-circle").length,
|
||||
find(".d-icon-exclamation-circle").length,
|
||||
1,
|
||||
"shows broken theme icon"
|
||||
);
|
||||
|
@ -28,36 +28,36 @@ componentTest("current tab is themes", {
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.$(".themes-tab").hasClass("active"),
|
||||
find(".themes-tab").hasClass("active"),
|
||||
true,
|
||||
"themes tab is active"
|
||||
);
|
||||
assert.equal(
|
||||
this.$(".components-tab").hasClass("active"),
|
||||
find(".components-tab").hasClass("active"),
|
||||
false,
|
||||
"components tab is not active"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.$(".inactive-indicator").index(),
|
||||
find(".inactive-indicator").index(),
|
||||
-1,
|
||||
"there is no inactive themes separator when all themes are inactive"
|
||||
);
|
||||
assert.equal(this.$(".themes-list-item").length, 5, "displays all themes");
|
||||
assert.equal(find(".themes-list-item").length, 5, "displays all themes");
|
||||
|
||||
[2, 3].forEach(num => themes[num].set("user_selectable", true));
|
||||
themes[4].set("default", true);
|
||||
this.set("themes", themes);
|
||||
const names = [4, 2, 3, 0, 1].map(num => themes[num].get("name")); // default theme always on top, followed by user-selectable ones and then the rest
|
||||
assert.deepEqual(
|
||||
Array.from(this.$(".themes-list-item").find(".name")).map(node =>
|
||||
Array.from(find(".themes-list-item").find(".name")).map(node =>
|
||||
node.innerText.trim()
|
||||
),
|
||||
names,
|
||||
"sorts themes correctly"
|
||||
);
|
||||
assert.equal(
|
||||
this.$(".inactive-indicator").index(),
|
||||
find(".inactive-indicator").index(),
|
||||
3,
|
||||
"the separator is in the right location"
|
||||
);
|
||||
@ -65,19 +65,19 @@ componentTest("current tab is themes", {
|
||||
themes.forEach(theme => theme.set("user_selectable", true));
|
||||
this.set("themes", themes);
|
||||
assert.equal(
|
||||
this.$(".inactive-indicator").index(),
|
||||
find(".inactive-indicator").index(),
|
||||
-1,
|
||||
"there is no inactive themes separator when all themes are user-selectable"
|
||||
);
|
||||
|
||||
this.set("themes", []);
|
||||
assert.equal(
|
||||
this.$(".themes-list-item").length,
|
||||
find(".themes-list-item").length,
|
||||
1,
|
||||
"shows one entry with a message when there is nothing to display"
|
||||
);
|
||||
assert.equal(
|
||||
this.$(".themes-list-item span.empty")
|
||||
find(".themes-list-item span.empty")
|
||||
.text()
|
||||
.trim(),
|
||||
I18n.t("admin.customize.theme.empty"),
|
||||
@ -99,35 +99,35 @@ componentTest("current tab is components", {
|
||||
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
this.$(".components-tab").hasClass("active"),
|
||||
find(".components-tab").hasClass("active"),
|
||||
true,
|
||||
"components tab is active"
|
||||
);
|
||||
assert.equal(
|
||||
this.$(".themes-tab").hasClass("active"),
|
||||
find(".themes-tab").hasClass("active"),
|
||||
false,
|
||||
"themes tab is not active"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
this.$(".inactive-indicator").index(),
|
||||
find(".inactive-indicator").index(),
|
||||
-1,
|
||||
"there is no separator"
|
||||
);
|
||||
assert.equal(
|
||||
this.$(".themes-list-item").length,
|
||||
find(".themes-list-item").length,
|
||||
5,
|
||||
"displays all components"
|
||||
);
|
||||
|
||||
this.set("components", []);
|
||||
assert.equal(
|
||||
this.$(".themes-list-item").length,
|
||||
find(".themes-list-item").length,
|
||||
1,
|
||||
"shows one entry with a message when there is nothing to display"
|
||||
);
|
||||
assert.equal(
|
||||
this.$(".themes-list-item span.empty")
|
||||
find(".themes-list-item span.empty")
|
||||
.text()
|
||||
.trim(),
|
||||
I18n.t("admin.customize.theme.empty"),
|
||||
|
Reference in New Issue
Block a user