2021-06-09 10:58:55 -04:00
|
|
|
import componentTest, {
|
|
|
|
setupRenderingTest,
|
|
|
|
} from "discourse/tests/helpers/component-test";
|
2020-10-28 16:36:01 -04:00
|
|
|
import {
|
2021-06-09 10:58:55 -04:00
|
|
|
discourseModule,
|
|
|
|
queryAll,
|
|
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
2021-06-21 15:52:15 -04:00
|
|
|
import hbs from "htmlbars-inline-precompile";
|
2020-10-28 16:36:01 -04:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
discourseModule(
|
|
|
|
"Integration | Component | Widget | discourse-poll-option",
|
|
|
|
function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
2021-06-21 15:52:15 -04:00
|
|
|
const template = hbs`{{mount-widget
|
2016-12-07 15:48:47 -05:00
|
|
|
widget="discourse-poll-option"
|
|
|
|
args=(hash option=option isMultiple=isMultiple vote=vote)}}`;
|
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
componentTest("single, not selected", {
|
|
|
|
template,
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
beforeEach() {
|
|
|
|
this.set("option", { id: "opt-id" });
|
|
|
|
this.set("vote", []);
|
|
|
|
},
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
test(assert) {
|
|
|
|
assert.ok(
|
|
|
|
queryAll("li .d-icon-far-circle:nth-of-type(1)").length === 1
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
componentTest("single, selected", {
|
|
|
|
template,
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
beforeEach() {
|
|
|
|
this.set("option", { id: "opt-id" });
|
|
|
|
this.set("vote", ["opt-id"]);
|
|
|
|
},
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
test(assert) {
|
|
|
|
assert.ok(queryAll("li .d-icon-circle:nth-of-type(1)").length === 1);
|
|
|
|
},
|
|
|
|
});
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
componentTest("multi, not selected", {
|
|
|
|
template,
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
beforeEach() {
|
|
|
|
this.setProperties({
|
|
|
|
option: { id: "opt-id" },
|
|
|
|
isMultiple: true,
|
|
|
|
vote: [],
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
|
|
|
assert.ok(
|
|
|
|
queryAll("li .d-icon-far-square:nth-of-type(1)").length === 1
|
|
|
|
);
|
|
|
|
},
|
2016-12-07 15:48:47 -05:00
|
|
|
});
|
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
componentTest("multi, selected", {
|
|
|
|
template,
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
beforeEach() {
|
|
|
|
this.setProperties({
|
|
|
|
option: { id: "opt-id" },
|
|
|
|
isMultiple: true,
|
|
|
|
vote: ["opt-id"],
|
|
|
|
});
|
|
|
|
},
|
2016-12-07 15:48:47 -05:00
|
|
|
|
2021-06-09 10:58:55 -04:00
|
|
|
test(assert) {
|
|
|
|
assert.ok(
|
|
|
|
queryAll("li .d-icon-far-check-square:nth-of-type(1)").length === 1
|
|
|
|
);
|
|
|
|
},
|
2016-12-07 15:48:47 -05:00
|
|
|
});
|
2021-06-09 10:58:55 -04:00
|
|
|
}
|
|
|
|
);
|