2018-06-15 12:42:20 -04:00
|
|
|
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
|
|
|
moduleForWidget("discourse-poll-option");
|
2016-12-07 15:48:47 -05:00
|
|
|
|
|
|
|
const template = `{{mount-widget
|
|
|
|
widget="discourse-poll-option"
|
|
|
|
args=(hash option=option isMultiple=isMultiple vote=vote)}}`;
|
|
|
|
|
2018-06-15 12:42:20 -04:00
|
|
|
widgetTest("single, not selected", {
|
2016-12-07 15:48:47 -05:00
|
|
|
template,
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 12:42:20 -04:00
|
|
|
this.set("option", { id: "opt-id" });
|
|
|
|
this.set("vote", []);
|
2016-12-07 15:48:47 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2018-11-26 16:49:57 -05:00
|
|
|
assert.ok(find("li .d-icon-far-circle:eq(0)").length === 1);
|
2016-12-07 15:48:47 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 12:42:20 -04:00
|
|
|
widgetTest("single, selected", {
|
2016-12-07 15:48:47 -05:00
|
|
|
template,
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 12:42:20 -04:00
|
|
|
this.set("option", { id: "opt-id" });
|
|
|
|
this.set("vote", ["opt-id"]);
|
2016-12-07 15:48:47 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-01-24 08:55:36 -05:00
|
|
|
assert.ok(find("li .d-icon-circle:eq(0)").length === 1);
|
2016-12-07 15:48:47 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 12:42:20 -04:00
|
|
|
widgetTest("multi, not selected", {
|
2016-12-07 15:48:47 -05:00
|
|
|
template,
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-12-07 15:48:47 -05:00
|
|
|
this.setProperties({
|
2018-06-15 12:42:20 -04:00
|
|
|
option: { id: "opt-id" },
|
2016-12-07 15:48:47 -05:00
|
|
|
isMultiple: true,
|
|
|
|
vote: []
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2018-11-26 16:49:57 -05:00
|
|
|
assert.ok(find("li .d-icon-far-square:eq(0)").length === 1);
|
2016-12-07 15:48:47 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 12:42:20 -04:00
|
|
|
widgetTest("multi, selected", {
|
2016-12-07 15:48:47 -05:00
|
|
|
template,
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-12-07 15:48:47 -05:00
|
|
|
this.setProperties({
|
2018-06-15 12:42:20 -04:00
|
|
|
option: { id: "opt-id" },
|
2016-12-07 15:48:47 -05:00
|
|
|
isMultiple: true,
|
2018-06-15 12:42:20 -04:00
|
|
|
vote: ["opt-id"]
|
2016-12-07 15:48:47 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2018-11-26 16:49:57 -05:00
|
|
|
assert.ok(find("li .d-icon-far-check-square:eq(0)").length === 1);
|
2016-12-07 15:48:47 -05:00
|
|
|
}
|
|
|
|
});
|