discourse/plugins/poll/test/javascripts/widgets/discourse-poll-option-test.js.es6

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.4 KiB
Plaintext
Raw Normal View History

import {
moduleForWidget,
widgetTest,
} from "discourse/tests/helpers/widget-test";
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
2018-06-16 00:42:20 +08:00
moduleForWidget("discourse-poll-option");
const template = `{{mount-widget
widget="discourse-poll-option"
args=(hash option=option isMultiple=isMultiple vote=vote)}}`;
2018-06-16 00:42:20 +08:00
widgetTest("single, not selected", {
template,
2017-06-15 01:57:58 +08:00
beforeEach() {
2018-06-16 00:42:20 +08:00
this.set("option", { id: "opt-id" });
this.set("vote", []);
},
test(assert) {
assert.ok(queryAll("li .d-icon-far-circle:eq(0)").length === 1);
},
});
2018-06-16 00:42:20 +08:00
widgetTest("single, selected", {
template,
2017-06-15 01:57:58 +08:00
beforeEach() {
2018-06-16 00:42:20 +08:00
this.set("option", { id: "opt-id" });
this.set("vote", ["opt-id"]);
},
test(assert) {
assert.ok(queryAll("li .d-icon-circle:eq(0)").length === 1);
},
});
2018-06-16 00:42:20 +08:00
widgetTest("multi, not selected", {
template,
2017-06-15 01:57:58 +08:00
beforeEach() {
this.setProperties({
2018-06-16 00:42:20 +08:00
option: { id: "opt-id" },
isMultiple: true,
vote: [],
});
},
test(assert) {
assert.ok(queryAll("li .d-icon-far-square:eq(0)").length === 1);
},
});
2018-06-16 00:42:20 +08:00
widgetTest("multi, selected", {
template,
2017-06-15 01:57:58 +08:00
beforeEach() {
this.setProperties({
2018-06-16 00:42:20 +08:00
option: { id: "opt-id" },
isMultiple: true,
vote: ["opt-id"],
});
},
test(assert) {
assert.ok(queryAll("li .d-icon-far-check-square:eq(0)").length === 1);
},
});