From 7509853fd7b3c8e6eaaa79fe56d166d9913106b2 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 24 Jan 2025 12:57:03 +0000 Subject: [PATCH] fix tests --- src/oneTrust/helpers/flattenOneTrustAssessment.ts | 12 +++++------- .../tests/flattenOneTrustQuestionResponses.test.ts | 10 ++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/oneTrust/helpers/flattenOneTrustAssessment.ts b/src/oneTrust/helpers/flattenOneTrustAssessment.ts index 6debf1e4..f0e7b7d5 100644 --- a/src/oneTrust/helpers/flattenOneTrustAssessment.ts +++ b/src/oneTrust/helpers/flattenOneTrustAssessment.ts @@ -154,9 +154,11 @@ export const flattenOneTrustQuestions = ( ...convertToEmptyStrings(createDefaultCodec(OneTrustEnrichedRisk)), categories: null, } as OneTrustEnrichedRisk; - const allRisksDefault = allRisks.map((risks) => - !risks || risks.length === 0 ? [defaultRisk] : risks, - ); + const allRisksDefault = allRisks + ? allRisks.map((risks) => + !risks || risks.length === 0 ? [defaultRisk] : risks, + ) + : undefined; return { ...(questions && flattenObject({ obj: { questions }, prefix })), @@ -173,10 +175,6 @@ export const flattenOneTrustQuestions = ( }, ); - // const defaultQuestionResponses = convertToEmptyStrings( - // createDefaultCodec(OneTrustAssessmentQuestionResponses), - // ) as OneTrustAssessmentQuestionResponses; - return aggregateObjects({ objs: allSectionQuestionsFlat, wrap: true, diff --git a/src/oneTrust/helpers/tests/flattenOneTrustQuestionResponses.test.ts b/src/oneTrust/helpers/tests/flattenOneTrustQuestionResponses.test.ts index 22a2030d..e3d0b158 100644 --- a/src/oneTrust/helpers/tests/flattenOneTrustQuestionResponses.test.ts +++ b/src/oneTrust/helpers/tests/flattenOneTrustQuestionResponses.test.ts @@ -21,7 +21,7 @@ import { chai.use(deepEqualInAnyOrder); -describe('flattenOneTrustAssessment', () => { +describe.only('flattenOneTrustAssessment', () => { const defaultQuestion: OneTrustEnrichedAssessmentQuestion = createDefaultCodec(OneTrustEnrichedAssessmentQuestion); const defaultNestedQuestion: OneTrustAssessmentNestedQuestion = @@ -216,17 +216,15 @@ describe('flattenOneTrustAssessment', () => { }, ], ]; - const { questions_questionResponses_response } = flattenOneTrustQuestions( - allSectionQuestions, - '', - ); + const { sections_questions_questionResponses_response } = + flattenOneTrustQuestions(allSectionQuestions, 'sections'); // 1st section has 3 questions, the first with 2 answers const section1 = '[[s1q1r1,s1q1r2],[],[]]'; // 2nd section has 2 questions, none with answers. const section2 = '[[],[]]'; // 2nd section has 1 question without answers const section3 = '[[]]'; - expect(questions_questionResponses_response).to.equal( + expect(sections_questions_questionResponses_response).to.equal( `${section1},${section2},${section3}`, ); });