-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(formatter): keep prettier happy
- Loading branch information
1 parent
088fb55
commit e39e406
Showing
3 changed files
with
63 additions
and
59 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,62 +1,63 @@ | ||
import { | ||
cleanUpApplicants, | ||
cleanUpWebhooks, | ||
createApplicant, | ||
repeatRequestUntilTaskOutputChanges, | ||
createWorkflowRunWithCustomInputs, | ||
onfido, | ||
sleep | ||
cleanUpApplicants, | ||
cleanUpWebhooks, | ||
createApplicant, | ||
repeatRequestUntilTaskOutputChanges, | ||
createWorkflowRunWithCustomInputs, | ||
onfido, | ||
sleep | ||
} from "../test-helpers"; | ||
|
||
import { | ||
WorkflowRunBuilder | ||
} from "onfido-node"; | ||
import { WorkflowRunBuilder } from "onfido-node"; | ||
|
||
afterAll(() => { | ||
return Promise.all([cleanUpApplicants(), cleanUpWebhooks()]); | ||
return Promise.all([cleanUpApplicants(), cleanUpWebhooks()]); | ||
}); | ||
|
||
it("downloads a signed document file", async () => { | ||
function sleep(milliseconds) { | ||
const date = Date.now(); | ||
let currentDate = null; | ||
do { | ||
currentDate = Date.now(); | ||
} while (currentDate - date < milliseconds); | ||
} | ||
const applicant = (await createApplicant()).data; | ||
|
||
const workflowRunBuilder: WorkflowRunBuilder = { | ||
applicant_id: applicant.id, | ||
workflow_id: "8b74614f-9e7f-42fd-852a-5f2bcc852587", | ||
custom_data: { | ||
country_of_operation: "GBR", | ||
document_date_of_expiry: "2022-01-01", | ||
document_issuing_country: "FRA", | ||
document_issuing_date: "2022-01-01", | ||
document_number: "Example string", | ||
document_to_sign_url: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", | ||
document_type: "driving_licence", | ||
} | ||
}; | ||
|
||
const workflowRun = await createWorkflowRunWithCustomInputs( | ||
workflowRunBuilder | ||
); | ||
const taskId = (await onfido.listTasks(workflowRun.data.id)).data[0].id; | ||
|
||
const output = (await repeatRequestUntilTaskOutputChanges( | ||
"findTask", | ||
[workflowRun.data.id, taskId], | ||
10, | ||
3000 | ||
))["output"]; | ||
|
||
const fileId = output["properties"]["signed_documents"][0]["id"] | ||
|
||
const file = await onfido.downloadQesDocument(workflowRun.data.id, fileId); | ||
|
||
expect(file.status).toEqual(200); | ||
expect(file.headers["content-type"]).toEqual("application/pdf"); | ||
expect(file.data.buffer.slice(0, 5)).toEqual("%PDF-"); | ||
}); | ||
function sleep(milliseconds) { | ||
const date = Date.now(); | ||
let currentDate = null; | ||
do { | ||
currentDate = Date.now(); | ||
} while (currentDate - date < milliseconds); | ||
} | ||
const applicant = (await createApplicant()).data; | ||
|
||
const workflowRunBuilder: WorkflowRunBuilder = { | ||
applicant_id: applicant.id, | ||
workflow_id: "8b74614f-9e7f-42fd-852a-5f2bcc852587", | ||
custom_data: { | ||
country_of_operation: "GBR", | ||
document_date_of_expiry: "2022-01-01", | ||
document_issuing_country: "FRA", | ||
document_issuing_date: "2022-01-01", | ||
document_number: "Example string", | ||
document_to_sign_url: | ||
"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", | ||
document_type: "driving_licence" | ||
} | ||
}; | ||
|
||
const workflowRun = await createWorkflowRunWithCustomInputs( | ||
workflowRunBuilder | ||
); | ||
const taskId = (await onfido.listTasks(workflowRun.data.id)).data[0].id; | ||
|
||
const output = ( | ||
await repeatRequestUntilTaskOutputChanges( | ||
"findTask", | ||
[workflowRun.data.id, taskId], | ||
10, | ||
3000 | ||
) | ||
)["output"]; | ||
|
||
const fileId = output["properties"]["signed_documents"][0]["id"]; | ||
|
||
const file = await onfido.downloadQesDocument(workflowRun.data.id, fileId); | ||
|
||
expect(file.status).toEqual(200); | ||
expect(file.headers["content-type"]).toEqual("application/pdf"); | ||
expect(file.data.buffer.slice(0, 5)).toEqual("%PDF-"); | ||
}); |
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