From 026c34e4f769cc260971f7598a196b4e7fe5d4f7 Mon Sep 17 00:00:00 2001 From: Stanislav Lvovsky Date: Wed, 5 Feb 2020 08:56:03 +0200 Subject: [PATCH] list (#130) --- frontend/src/App.vue | 5 ++--- .../components/QuestionTypes/QuestionList.vue | 20 ++++++++++++++----- .../QuestionTypes/QuestionList.spec.js | 4 ++-- generator-foodq/generators/app/index.js | 3 +-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 67ce17f6..47f7ec24 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -171,6 +171,7 @@ export default { return p.then(() => that.updateQuestion(question)).catch(error => { // eslint-disable-next-line no-console console.error(error); + // TODO: add information to log in case a question failed and there is a list/rawlist question without selected value }) }, Promise.resolve()); @@ -238,9 +239,7 @@ export default { "validate" ]); question.isValid = _.isString(response) ? false : response; - question.validationMessage = _.isString(response) - ? response - : undefined; + question.validationMessage = _.isString(response) ? response : undefined; } } }, diff --git a/frontend/src/components/QuestionTypes/QuestionList.vue b/frontend/src/components/QuestionTypes/QuestionList.vue index 27a6af63..734fba22 100644 --- a/frontend/src/components/QuestionTypes/QuestionList.vue +++ b/frontend/src/components/QuestionTypes/QuestionList.vue @@ -2,7 +2,8 @@

{{currentQuestion.message}}

{ updateQuestionsFromIndex: () => {} }) - expect(wrapper.vm.default).toBe('testName1') + expect(wrapper.vm.default).toBeUndefined() }) test('default is undefined and choices are strings', () => { @@ -77,7 +77,7 @@ describe('QuestionList.vue', () => { updateQuestionsFromIndex: () => {} }) - expect(wrapper.vm.default).toBe('testName1') + expect(wrapper.vm.default).toBeUndefined() }) test('change selected', async () => { diff --git a/generator-foodq/generators/app/index.js b/generator-foodq/generators/app/index.js index f82b29ef..eed67776 100644 --- a/generator-foodq/generators/app/index.js +++ b/generator-foodq/generators/app/index.js @@ -128,7 +128,6 @@ module.exports = class extends Generator { type: "list", name: "hungerLevel", message: "How hungry are you?", - default: 1, choices: () => [ { name: "Very hungry" }, { name: "A bit hungry" }, @@ -164,7 +163,7 @@ module.exports = class extends Generator { name: 'enjoy', message: 'Did you enjoy your meal?', default: (answers) => { - return (answers.hungerLevel === "A bit hungry" ? "ok" : "michelin"); + return (answers.hungerLevel.toString() === "A bit hungry" ? "ok" : "michelin"); }, choices: [ { name: 'Not at all', value: 'no' },