-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add removeConfirmationPageQCodes tests
- Loading branch information
Showing
1 changed file
with
133 additions
and
0 deletions.
There are no files selected for viewing
133 changes: 133 additions & 0 deletions
133
eq-author-api/migrations/removeConfirmationPageQCodes.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
const removeConfirmationPageQCodes = require("./removeConfirmationPageQCodes"); | ||
|
||
describe("removeConfirmationPageQCodes", () => { | ||
it("should remove qCode from confirmation pages", () => { | ||
const questionnaire = { | ||
sections: [ | ||
{ | ||
id: "section-1", | ||
folders: [ | ||
{ | ||
id: "folder-1", | ||
pages: [ | ||
{ | ||
id: "page-1", | ||
confirmation: { | ||
id: "confirmation-page-1", | ||
qCode: "123", | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
const result = removeConfirmationPageQCodes(questionnaire); | ||
|
||
expect( | ||
result.sections[0].folders[0].pages[0].confirmation.qCode | ||
).toBeUndefined(); | ||
}); | ||
|
||
it("should not remove qCode from answers", () => { | ||
const questionnaire = { | ||
sections: [ | ||
{ | ||
id: "section-1", | ||
folders: [ | ||
{ | ||
id: "folder-1", | ||
pages: [ | ||
{ | ||
id: "page-1", | ||
answers: [ | ||
{ | ||
id: "answer-1", | ||
qCode: "123", | ||
}, | ||
], | ||
confirmation: { | ||
id: "confirmation-page-1", | ||
qCode: "123", | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
const result = removeConfirmationPageQCodes(questionnaire); | ||
|
||
expect( | ||
result.sections[0].folders[0].pages[0].confirmation.qCode | ||
).toBeUndefined(); | ||
expect(result.sections[0].folders[0].pages[0].answers[0].qCode).toBe("123"); | ||
}); | ||
|
||
it("should not amend questionnaire data if the questionnaire does not contain any confirmation pages", () => { | ||
const questionnaire = { | ||
sections: [ | ||
{ | ||
id: "section-1", | ||
folders: [ | ||
{ | ||
id: "folder-1", | ||
pages: [ | ||
{ | ||
id: "page-1", | ||
answers: [ | ||
{ | ||
id: "answer-1", | ||
qCode: "123", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
const result = removeConfirmationPageQCodes(questionnaire); | ||
|
||
expect(result.sections[0].folders[0].pages[0].answers[0].qCode).toBe("123"); | ||
expect(result).toEqual(questionnaire); | ||
}); | ||
|
||
it("should not amend questionnaire data if the questionnaire does not contain any qCodes", () => { | ||
const questionnaire = { | ||
sections: [ | ||
{ | ||
id: "section-1", | ||
folders: [ | ||
{ | ||
id: "folder-1", | ||
pages: [ | ||
{ | ||
id: "page-1", | ||
answers: [ | ||
{ | ||
id: "answer-1", | ||
}, | ||
], | ||
confirmation: { | ||
id: "confirmation-page-1", | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
const result = removeConfirmationPageQCodes(questionnaire); | ||
|
||
expect(result).toEqual(questionnaire); | ||
}); | ||
}); |