2020-10-29 04:36:01 +08:00
|
|
|
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");
|
2016-12-08 04:48:47 +08:00
|
|
|
|
|
|
|
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", {
|
2016-12-08 04:48:47 +08:00
|
|
|
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", []);
|
2016-12-08 04:48:47 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2020-10-29 04:36:01 +08:00
|
|
|
assert.ok(queryAll("li .d-icon-far-circle:eq(0)").length === 1);
|
2020-09-05 02:01:14 +08:00
|
|
|
},
|
2016-12-08 04:48:47 +08:00
|
|
|
});
|
|
|
|
|
2018-06-16 00:42:20 +08:00
|
|
|
widgetTest("single, selected", {
|
2016-12-08 04:48:47 +08:00
|
|
|
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"]);
|
2016-12-08 04:48:47 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2020-10-29 04:36:01 +08:00
|
|
|
assert.ok(queryAll("li .d-icon-circle:eq(0)").length === 1);
|
2020-09-05 02:01:14 +08:00
|
|
|
},
|
2016-12-08 04:48:47 +08:00
|
|
|
});
|
|
|
|
|
2018-06-16 00:42:20 +08:00
|
|
|
widgetTest("multi, not selected", {
|
2016-12-08 04:48:47 +08:00
|
|
|
template,
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2016-12-08 04:48:47 +08:00
|
|
|
this.setProperties({
|
2018-06-16 00:42:20 +08:00
|
|
|
option: { id: "opt-id" },
|
2016-12-08 04:48:47 +08:00
|
|
|
isMultiple: true,
|
2020-09-05 02:01:14 +08:00
|
|
|
vote: [],
|
2016-12-08 04:48:47 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2020-10-29 04:36:01 +08:00
|
|
|
assert.ok(queryAll("li .d-icon-far-square:eq(0)").length === 1);
|
2020-09-05 02:01:14 +08:00
|
|
|
},
|
2016-12-08 04:48:47 +08:00
|
|
|
});
|
|
|
|
|
2018-06-16 00:42:20 +08:00
|
|
|
widgetTest("multi, selected", {
|
2016-12-08 04:48:47 +08:00
|
|
|
template,
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2016-12-08 04:48:47 +08:00
|
|
|
this.setProperties({
|
2018-06-16 00:42:20 +08:00
|
|
|
option: { id: "opt-id" },
|
2016-12-08 04:48:47 +08:00
|
|
|
isMultiple: true,
|
2020-09-05 02:01:14 +08:00
|
|
|
vote: ["opt-id"],
|
2016-12-08 04:48:47 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2020-10-29 04:36:01 +08:00
|
|
|
assert.ok(queryAll("li .d-icon-far-check-square:eq(0)").length === 1);
|
2020-09-05 02:01:14 +08:00
|
|
|
},
|
2016-12-08 04:48:47 +08:00
|
|
|
});
|