|
1 | 1 | import { Platform } from "react-native"; |
2 | | -import { OnfidoCountryCode, OnfidoCaptureType, OnfidoDocumentType, OnfidoConfig } from "../config_constants"; |
| 2 | +import { OnfidoCountryCode, OnfidoCaptureType, OnfidoDocumentType, OnfidoConfig, OnfidoFlowSteps } from "../config_constants"; |
3 | 3 | import Onfido from "../Onfido"; |
4 | 4 |
|
5 | 5 | // add mock |
@@ -30,7 +30,7 @@ const start = (config: OnfidoConfig) => { |
30 | 30 | }); |
31 | 31 | }; |
32 | 32 |
|
33 | | -const flowSteps = { |
| 33 | +const flowSteps : OnfidoFlowSteps = { |
34 | 34 | welcome: true, |
35 | 35 | captureDocument: { |
36 | 36 | docType: OnfidoDocumentType.DRIVING_LICENCE, |
@@ -77,10 +77,36 @@ testCases.forEach((platform) => { |
77 | 77 | }); |
78 | 78 |
|
79 | 79 | test('resolve with a valid workflow runId without flow steps', () => { |
80 | | - return start({ ...baseConfig, flowSteps: null, workflowRunId: workflowRunId }).then(result => expect(result).toBe(RESOLVED)) |
| 80 | + return start({ ...baseConfig, flowSteps: undefined, workflowRunId: workflowRunId }).then(result => expect(result).toBe(RESOLVED)) |
| 81 | + }); |
| 82 | + |
| 83 | + test('resolve with a classic workflow with allowedDocumentTypes', () => { |
| 84 | + return start( |
| 85 | + { |
| 86 | + ...baseConfig, |
| 87 | + flowSteps: { |
| 88 | + captureDocument: { |
| 89 | + allowedDocumentTypes: [OnfidoDocumentType.DRIVING_LICENCE, OnfidoDocumentType.PASSPORT] |
| 90 | + } |
| 91 | + } |
| 92 | + }).then(result => expect(result).toBe(RESOLVED)) |
81 | 93 | }); |
82 | 94 |
|
83 | 95 | // Invalid Configuration Tests |
| 96 | + test('reject when using allowedDocumentTypes together with docType/docCountry', () => { |
| 97 | + return start( |
| 98 | + { |
| 99 | + ...baseConfig, |
| 100 | + flowSteps: { |
| 101 | + captureDocument: { |
| 102 | + docType: OnfidoDocumentType.DRIVING_LICENCE, |
| 103 | + countryCode: OnfidoCountryCode.GBR, |
| 104 | + allowedDocumentTypes: [OnfidoDocumentType.DRIVING_LICENCE, OnfidoDocumentType.PASSPORT] |
| 105 | + } |
| 106 | + } |
| 107 | + }).then(result => expect(result).toBe(REJECTED)) |
| 108 | + }); |
| 109 | + |
84 | 110 | test('reject a null config object', () => { |
85 | 111 | return start(null as unknown as OnfidoConfig).then(result => expect(result).toBe(REJECTED)) |
86 | 112 | }); |
|
0 commit comments