{items.map((item) => (
{
// Do nothing
};
+ console.log(answers);
+
render();
const rating = screen.getByTestId(ratingDataTestIds.base);
@@ -41,6 +43,7 @@ describe('Rating', () => {
displayType: DisplayType.Star,
onValueChanged: onValueChanged,
};
+ console.log(answers);
render();
diff --git a/src/screens/Question/index.test.tsx b/src/screens/Question/index.test.tsx
index 80e7a34..f5cb6bb 100644
--- a/src/screens/Question/index.test.tsx
+++ b/src/screens/Question/index.test.tsx
@@ -2,6 +2,7 @@ import React from 'react';
import { act, render, screen } from '@testing-library/react';
+import { answerDataTestIds } from 'components/Answer';
import { useAppDispatch, useAppSelector } from 'hooks';
import { SurveyState } from 'store/reducers/Survey';
import TestWrapper from 'tests/TestWrapper';
@@ -88,7 +89,7 @@ describe('QuestionScreen', () => {
const currentIndex = screen.getByTestId(questionScreenTestIds.index);
const questionTitle = screen.getByTestId(questionScreenTestIds.title);
- const answerComponent = screen.getByTestId(questionScreenTestIds.answer);
+ const answerComponent = screen.getByTestId(answerDataTestIds.base);
const closeButton = screen.getByTestId(questionScreenTestIds.closeButton);
const nextButton = screen.getByTestId(questionScreenTestIds.nextButton);
diff --git a/src/screens/Question/index.tsx b/src/screens/Question/index.tsx
index f607790..60c85d0 100644
--- a/src/screens/Question/index.tsx
+++ b/src/screens/Question/index.tsx
@@ -11,7 +11,6 @@ import { useAppSelector } from 'hooks';
export const questionScreenTestIds = {
index: 'question__index',
title: 'question__title',
- answer: 'question__answer',
closeButton: 'question__close-button',
nextButton: 'question__next-button',
};
@@ -62,7 +61,7 @@ const QuestionScreen = (): JSX.Element => {
{currentQuestion && (
{currentQuestion.displayType}
-
+
)}
diff --git a/src/tests/fabricator.ts b/src/tests/fabricator.ts
index f7bbe0d..65485b6 100644
--- a/src/tests/fabricator.ts
+++ b/src/tests/fabricator.ts
@@ -14,17 +14,17 @@ export const testTypeFabricator = Fabricator({
// Requests
const answerRequestFabricator = Fabricator({
- id: () => sequence('answerId').toString(),
+ id: () => sequence('answerRequestId').toString(),
answer: () => faker.string.sample(),
});
const questionRequestFabricator = Fabricator({
- id: () => sequence('questionId').toString(),
+ id: () => sequence('questionRequestId').toString(),
answers: () => answerRequestFabricator.times(2),
});
export const surveySubmitRequestFabricator = Fabricator({
- surveyId: () => sequence('surveyId').toString(),
+ surveyId: () => sequence('surveySubmitRequestId').toString(),
questions: () => questionRequestFabricator.times(10),
});
@@ -95,11 +95,26 @@ export const surveyFabricator = Fabricator({
});
export const answerFabricator = Fabricator({
- id: () => sequence().toString(),
+ id: () => sequence('answerId').toString(),
resourceType: 'answer',
text: () => faker.string.sample(),
});
+export const questionFabricator = Fabricator({
+ id: () => sequence('questionId').toString(),
+ resourceType: 'question',
+ text: () => faker.string.sample(),
+ displayType: 'star',
+ answers: answerFabricator.times(5),
+});
+
+/*
+ * We need to reset the answerId sequence to start from "1" since the first
+ * five sequences have already been created above. This will ensure that the
+ * next time we generate an id in a test file, it will begin with "1".
+ */
+sequence.reset('answerId');
+
// States
export const surveyStateFabricator = Fabricator({
survey: () => surveyFabricator(),
diff --git a/src/types/question.ts b/src/types/question.ts
index 0a72d23..3cb2f65 100644
--- a/src/types/question.ts
+++ b/src/types/question.ts
@@ -20,19 +20,19 @@ export interface Question extends Resource {
}
export enum DisplayType {
- Intro = 'intro',
- Star = 'star',
- Heart = 'heart',
- Smiley = 'smiley',
- Thumbs = 'thumbs',
- Choice = 'choice',
- Nps = 'nps',
- Slider = 'slider',
- Textarea = 'textarea',
- Textfield = 'textfield',
- Dropdown = 'dropdown',
- Outro = 'outro',
- Unknown = '',
+ Intro,
+ Star,
+ Heart,
+ Smiley,
+ Thumbs,
+ Choice,
+ Nps,
+ Slider,
+ Textarea,
+ Textfield,
+ Dropdown,
+ Outro,
+ Unknown,
}
export const getDisplayTypeEnum = (question: Question): DisplayType => {