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

65 lines
1.3 KiB
Plaintext
Raw Normal View History

2018-06-15 12:42:20 -04:00
import { moduleForWidget, widgetTest } from "helpers/widget-test";
moduleForWidget("discourse-poll-option");
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", {
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", []);
},
test(assert) {
assert.ok(find("li .d-icon-circle-o:eq(0)").length === 1);
}
});
2018-06-15 12:42:20 -04:00
widgetTest("single, selected", {
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"]);
},
test(assert) {
assert.ok(find("li .d-icon-dot-circle-o:eq(0)").length === 1);
}
});
2018-06-15 12:42:20 -04:00
widgetTest("multi, not selected", {
template,
2017-06-14 13:57:58 -04:00
beforeEach() {
this.setProperties({
2018-06-15 12:42:20 -04:00
option: { id: "opt-id" },
isMultiple: true,
vote: []
});
},
test(assert) {
assert.ok(find("li .d-icon-square-o:eq(0)").length === 1);
}
});
2018-06-15 12:42:20 -04:00
widgetTest("multi, selected", {
template,
2017-06-14 13:57:58 -04:00
beforeEach() {
this.setProperties({
2018-06-15 12:42:20 -04:00
option: { id: "opt-id" },
isMultiple: true,
2018-06-15 12:42:20 -04:00
vote: ["opt-id"]
});
},
test(assert) {
assert.ok(find("li .d-icon-check-square-o:eq(0)").length === 1);
}
});