mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
FIX: Tests were using jQuery selectors
For the most part `querySelectorAll` will work with jQuery selectors, but the big exception is `:eq(0)` and similar. Those needed to be replaced.
This commit is contained in:
@ -19,7 +19,7 @@ widgetTest("single, not selected", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(queryAll("li .d-icon-far-circle:eq(0)").length === 1);
|
||||
assert.ok(queryAll("li .d-icon-far-circle:nth-of-type(1)").length === 1);
|
||||
},
|
||||
});
|
||||
|
||||
@ -32,7 +32,7 @@ widgetTest("single, selected", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(queryAll("li .d-icon-circle:eq(0)").length === 1);
|
||||
assert.ok(queryAll("li .d-icon-circle:nth-of-type(1)").length === 1);
|
||||
},
|
||||
});
|
||||
|
||||
@ -48,7 +48,7 @@ widgetTest("multi, not selected", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(queryAll("li .d-icon-far-square:eq(0)").length === 1);
|
||||
assert.ok(queryAll("li .d-icon-far-square:nth-of-type(1)").length === 1);
|
||||
},
|
||||
});
|
||||
|
||||
@ -64,6 +64,8 @@ widgetTest("multi, selected", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(queryAll("li .d-icon-far-check-square:eq(0)").length === 1);
|
||||
assert.ok(
|
||||
queryAll("li .d-icon-far-check-square:nth-of-type(1)").length === 1
|
||||
);
|
||||
},
|
||||
});
|
||||
|
@ -25,8 +25,8 @@ widgetTest("options in descending order", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(queryAll(".option .percentage:eq(0)").text(), "56%");
|
||||
assert.equal(queryAll(".option .percentage:eq(1)").text(), "44%");
|
||||
assert.equal(queryAll(".option .percentage")[0].innerText, "56%");
|
||||
assert.equal(queryAll(".option .percentage")[1].innerText, "44%");
|
||||
},
|
||||
});
|
||||
|
||||
@ -44,8 +44,8 @@ widgetTest("options in ascending order", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(queryAll(".option .percentage:eq(0)").text(), "56%");
|
||||
assert.equal(queryAll(".option .percentage:eq(1)").text(), "44%");
|
||||
assert.equal(queryAll(".option .percentage")[0].innerText, "56%");
|
||||
assert.equal(queryAll(".option .percentage")[1].innerText, "44%");
|
||||
},
|
||||
});
|
||||
|
||||
@ -71,12 +71,20 @@ widgetTest("multiple options in descending order", {
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(queryAll(".option .percentage:eq(0)").text(), "41%");
|
||||
assert.equal(queryAll(".option .percentage:eq(1)").text(), "33%");
|
||||
assert.equal(queryAll(".option .percentage:eq(2)").text(), "16%");
|
||||
assert.equal(queryAll(".option .percentage:eq(3)").text(), "8%");
|
||||
assert.equal(queryAll(".option span:nth-child(2):eq(3)").text(), "a");
|
||||
assert.equal(queryAll(".option .percentage:eq(4)").text(), "8%");
|
||||
assert.equal(queryAll(".option span:nth-child(2):eq(4)").text(), "b");
|
||||
let percentages = queryAll(".option .percentage");
|
||||
assert.equal(percentages[0].innerText, "41%");
|
||||
assert.equal(percentages[1].innerText, "33%");
|
||||
assert.equal(percentages[2].innerText, "16%");
|
||||
assert.equal(percentages[3].innerText, "8%");
|
||||
|
||||
assert.equal(
|
||||
queryAll(".option")[3].querySelectorAll("span")[1].innerText,
|
||||
"a"
|
||||
);
|
||||
assert.equal(percentages[4].innerText, "8%");
|
||||
assert.equal(
|
||||
queryAll(".option")[4].querySelectorAll("span")[1].innerText,
|
||||
"b"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user