discourse/plugins/poll/test/javascripts/widgets/discourse-poll-option-test.js.es6
Robin Ward 435a9913a4 REFACTOR: Replace global find with queryAll
In newer Embers jQuery is removed. There is a `find` but it only returns
one element and not a jQuery selector. This patch migrates our code to a
new helper `queryAll` which allows us to remove the global.
2020-10-29 14:45:51 -04:00

70 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:eq(0)").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:eq(0)").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:eq(0)").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:eq(0)").length === 1);
},
});