mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 08:26:05 +08:00
3394d994e9
For the most part `querySelectorAll` will work with jQuery selectors, but the big exception is `:eq(0)` and similar. Those needed to be replaced.
72 lines
1.4 KiB
JavaScript
72 lines
1.4 KiB
JavaScript
import {
|
|
moduleForWidget,
|
|
widgetTest,
|
|
} from "discourse/tests/helpers/widget-test";
|
|
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
moduleForWidget("discourse-poll-option");
|
|
|
|
const template = `{{mount-widget
|
|
widget="discourse-poll-option"
|
|
args=(hash option=option isMultiple=isMultiple vote=vote)}}`;
|
|
|
|
widgetTest("single, not selected", {
|
|
template,
|
|
|
|
beforeEach() {
|
|
this.set("option", { id: "opt-id" });
|
|
this.set("vote", []);
|
|
},
|
|
|
|
test(assert) {
|
|
assert.ok(queryAll("li .d-icon-far-circle:nth-of-type(1)").length === 1);
|
|
},
|
|
});
|
|
|
|
widgetTest("single, selected", {
|
|
template,
|
|
|
|
beforeEach() {
|
|
this.set("option", { id: "opt-id" });
|
|
this.set("vote", ["opt-id"]);
|
|
},
|
|
|
|
test(assert) {
|
|
assert.ok(queryAll("li .d-icon-circle:nth-of-type(1)").length === 1);
|
|
},
|
|
});
|
|
|
|
widgetTest("multi, not selected", {
|
|
template,
|
|
|
|
beforeEach() {
|
|
this.setProperties({
|
|
option: { id: "opt-id" },
|
|
isMultiple: true,
|
|
vote: [],
|
|
});
|
|
},
|
|
|
|
test(assert) {
|
|
assert.ok(queryAll("li .d-icon-far-square:nth-of-type(1)").length === 1);
|
|
},
|
|
});
|
|
|
|
widgetTest("multi, selected", {
|
|
template,
|
|
|
|
beforeEach() {
|
|
this.setProperties({
|
|
option: { id: "opt-id" },
|
|
isMultiple: true,
|
|
vote: ["opt-id"],
|
|
});
|
|
},
|
|
|
|
test(assert) {
|
|
assert.ok(
|
|
queryAll("li .d-icon-far-check-square:nth-of-type(1)").length === 1
|
|
);
|
|
},
|
|
});
|