Skip to content

Commit b748168

Browse files
test(validation): cover missing optional field defaults
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 24c5138 commit b748168

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/tests/views/Validation.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,5 +1081,26 @@ describe('Validation.vue - Business Logic', () => {
10811081
expect(wrapper.vm.document).toBe(null)
10821082
expect(wrapper.vm.validationErrorMessage).toBe('Failed to validate document')
10831083
})
1084+
1085+
it('normalizes missing optional fields to internal defaults', () => {
1086+
const payload = createLoadedValidationDocument()
1087+
delete (payload as Record<string, unknown>).signers
1088+
delete (payload as Record<string, unknown>).metadata
1089+
delete (payload as Record<string, unknown>).settings
1090+
1091+
wrapper.vm.handleValidationSuccess(payload)
1092+
1093+
expect(wrapper.vm.document).not.toBe(null)
1094+
expect(wrapper.vm.document.signers).toEqual([])
1095+
expect(wrapper.vm.document.metadata).toEqual({ extension: 'pdf', p: 1 })
1096+
expect(wrapper.vm.document.settings).toEqual(expect.objectContaining({
1097+
canSign: false,
1098+
canRequestSign: false,
1099+
phoneNumber: '',
1100+
hasSignatureFile: false,
1101+
needIdentificationDocuments: false,
1102+
identificationDocumentsWaitingApproval: false,
1103+
}))
1104+
})
10841105
})
10851106
})

0 commit comments

Comments
 (0)