Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abrantesarthur committed Jan 24, 2025
1 parent 050fd21 commit 7509853
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
12 changes: 5 additions & 7 deletions src/oneTrust/helpers/flattenOneTrustAssessment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })),
Expand All @@ -173,10 +175,6 @@ export const flattenOneTrustQuestions = (
},
);

// const defaultQuestionResponses = convertToEmptyStrings(
// createDefaultCodec(OneTrustAssessmentQuestionResponses),
// ) as OneTrustAssessmentQuestionResponses;

return aggregateObjects({
objs: allSectionQuestionsFlat,
wrap: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {

chai.use(deepEqualInAnyOrder);

describe('flattenOneTrustAssessment', () => {
describe.only('flattenOneTrustAssessment', () => {
const defaultQuestion: OneTrustEnrichedAssessmentQuestion =
createDefaultCodec(OneTrustEnrichedAssessmentQuestion);
const defaultNestedQuestion: OneTrustAssessmentNestedQuestion =
Expand Down Expand Up @@ -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}`,
);
});
Expand Down

0 comments on commit 7509853

Please sign in to comment.