Skip to content

Commit

Permalink
PR: Ranking question with only one choice does not show choice (#6648)
Browse files Browse the repository at this point in the history
* fixed #6622

* fix func test
  • Loading branch information
dmitry-kurmanov committed Aug 4, 2023
1 parent 184a697 commit c07b873
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/question_ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
// ranking question with only one choice doesn't make sense
if (this.visibleChoices.length === 1) {
this.value = [];
this.value.push(this.visibleChoices[0].value);
this.updateRankingChoices();
return;
}
Expand Down Expand Up @@ -221,10 +222,10 @@ export class QuestionRankingModel extends QuestionCheckboxModel {
const newRankingChoices: ItemValue[] = [];

// ranking question with only one choice doesn't make sense
if (this.visibleChoices.length === 1) {
this.setPropertyValue("rankingChoices", newRankingChoices);
return;
}
// if (this.visibleChoices.length === 1) {
// this.setPropertyValue("rankingChoices", newRankingChoices);
// return;
// }

if (forceUpdate) this.setPropertyValue("rankingChoices", []);

Expand Down
2 changes: 1 addition & 1 deletion testCafe/questions/ranking.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ frameworks.forEach((framework) => {
.click(checkboxToyotaItem);

let data = await getData();
await t.expect(typeof data.bestcar).eql("undefined");
await t.expect(typeof data.bestcar).ok();

await t.hover(rankAudiItem);
await t.dragToElement(rankAudiItem, rankMercedesBenzItem);
Expand Down
2 changes: 1 addition & 1 deletion tests/question_ranking_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ QUnit.test("Ranking: Carry Forward", function(assert) {

// ranking question with only one choice doesn't make sense
q1.value = ["2"];
assert.deepEqual(q2.isEmpty(), true);
assert.deepEqual(q2.isEmpty(), false);
assert.deepEqual(survey.data, {
q1: [2],
});
Expand Down

0 comments on commit c07b873

Please sign in to comment.