mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 23:42:43 +08:00
DEV: uses find() helper instead of this.$() in js tests (#7062)
This commit is contained in:
@ -18,7 +18,7 @@ widgetTest("widget attributes are passed in via args", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$(".test").text(), "Hello Robin");
|
||||
assert.equal(find(".test").text(), "Hello Robin");
|
||||
}
|
||||
});
|
||||
|
||||
@ -34,7 +34,7 @@ widgetTest("hbs template - no tagName", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$("div.test").text(), "Hello Robin");
|
||||
assert.equal(find("div.test").text(), "Hello Robin");
|
||||
}
|
||||
});
|
||||
|
||||
@ -51,7 +51,7 @@ widgetTest("hbs template - with tagName", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$("div.test").text(), "Hello Robin");
|
||||
assert.equal(find("div.test").text(), "Hello Robin");
|
||||
}
|
||||
});
|
||||
|
||||
@ -71,10 +71,7 @@ widgetTest("buildClasses", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(
|
||||
this.$(".test.static.cool-class").length,
|
||||
"it has all the classes"
|
||||
);
|
||||
assert.ok(find(".test.static.cool-class").length, "it has all the classes");
|
||||
}
|
||||
});
|
||||
|
||||
@ -94,8 +91,8 @@ widgetTest("buildAttributes", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$(".test[data-evil=trout]").length);
|
||||
assert.ok(this.$(".test[aria-label=accessibility]").length);
|
||||
assert.ok(find(".test[data-evil=trout]").length);
|
||||
assert.ok(find(".test[aria-label=accessibility]").length);
|
||||
}
|
||||
});
|
||||
|
||||
@ -113,7 +110,7 @@ widgetTest("buildId", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$("#test-1234").length);
|
||||
assert.ok(find("#test-1234").length);
|
||||
}
|
||||
});
|
||||
|
||||
@ -137,11 +134,11 @@ widgetTest("widget state", {
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.ok(this.$("button.test").length, "it renders the button");
|
||||
assert.equal(this.$("button.test").text(), "0 clicks");
|
||||
assert.ok(find("button.test").length, "it renders the button");
|
||||
assert.equal(find("button.test").text(), "0 clicks");
|
||||
|
||||
await click(this.$("button"));
|
||||
assert.equal(this.$("button.test").text(), "1 clicks");
|
||||
await click(find("button"));
|
||||
assert.equal(find("button.test").text(), "1 clicks");
|
||||
}
|
||||
});
|
||||
|
||||
@ -173,15 +170,15 @@ widgetTest("widget update with promise", {
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(
|
||||
this.$("button.test")
|
||||
find("button.test")
|
||||
.text()
|
||||
.trim(),
|
||||
"No name"
|
||||
);
|
||||
|
||||
await click(this.$("button"));
|
||||
await click(find("button"));
|
||||
assert.equal(
|
||||
this.$("button.test")
|
||||
find("button.test")
|
||||
.text()
|
||||
.trim(),
|
||||
"Robin"
|
||||
@ -202,8 +199,8 @@ widgetTest("widget attaching", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$(".container").length, "renders container");
|
||||
assert.ok(this.$(".container .embedded").length, "renders attached");
|
||||
assert.ok(find(".container").length, "renders container");
|
||||
assert.ok(find(".container .embedded").length, "renders attached");
|
||||
}
|
||||
});
|
||||
|
||||
@ -217,7 +214,7 @@ widgetTest("handlebars d-icon", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$(".d-icon-arrow-down").length, 1);
|
||||
assert.equal(find(".d-icon-arrow-down").length, 1);
|
||||
}
|
||||
});
|
||||
|
||||
@ -243,9 +240,9 @@ widgetTest("handlebars i18n", {
|
||||
|
||||
test(assert) {
|
||||
// comin up
|
||||
assert.equal(this.$("span.string").text(), "evil");
|
||||
assert.equal(this.$("span.var").text(), "trout");
|
||||
assert.equal(this.$("a").prop("title"), "evil");
|
||||
assert.equal(find("span.string").text(), "evil");
|
||||
assert.equal(find("span.var").text(), "trout");
|
||||
assert.equal(find("a").prop("title"), "evil");
|
||||
}
|
||||
});
|
||||
|
||||
@ -268,8 +265,8 @@ widgetTest("handlebars #each", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$("ul li").length, 3);
|
||||
assert.equal(this.$("ul li:eq(0)").text(), "one");
|
||||
assert.equal(find("ul li").length, 3);
|
||||
assert.equal(find("ul li:eq(0)").text(), "one");
|
||||
}
|
||||
});
|
||||
|
||||
@ -294,9 +291,9 @@ widgetTest("widget decorating", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$(".decorate").length);
|
||||
assert.equal(this.$(".decorate b").text(), "before");
|
||||
assert.equal(this.$(".decorate i").text(), "after");
|
||||
assert.ok(find(".decorate").length);
|
||||
assert.equal(find(".decorate b").text(), "before");
|
||||
assert.equal(find(".decorate i").text(), "after");
|
||||
}
|
||||
});
|
||||
|
||||
@ -312,7 +309,7 @@ widgetTest("widget settings", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$(".settings").text(), "age is 36");
|
||||
assert.equal(find(".settings").text(), "age is 36");
|
||||
}
|
||||
});
|
||||
|
||||
@ -332,6 +329,6 @@ widgetTest("override settings", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(this.$(".settings").text(), "age is 37");
|
||||
assert.equal(find(".settings").text(), "age is 37");
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user