Skip to content

Commit

Permalink
Improve tests after library refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
dvacca-onfido committed Nov 18, 2024
1 parent 3c634dc commit e4ebba4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
24 changes: 11 additions & 13 deletions test/resources/report-schemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Document,
DocumentReport,
DocumentWithAddressInformationReport,
FacialSimilarityPhotoReport,
Report,
ReportName
} from "onfido-node";
Expand All @@ -16,7 +17,7 @@ import {
createApplicant,
createCheck,
getExpectedDocumentReport,
getExpectedFacialSimilarityReport,
getExpectedFacialSimilarityPhotoReport,
repeatRequestUntilStatusChanges,
uploadDocument,
uploadLivePhoto
Expand Down Expand Up @@ -62,9 +63,10 @@ it("schema of document report should be valid", async () => {

it("schema of facial similarity photo report should be valid", async () => {
await uploadLivePhoto(applicant);

const check: Check = (
await createCheck(applicant, document, {
report_names: ["facial_similarity_photo_fully_auto"]
report_names: [ReportName.FacialSimilarityPhotoFullyAuto]
})
).data;

Expand All @@ -74,18 +76,14 @@ it("schema of facial similarity photo report should be valid", async () => {
"complete"
);

const extraProperties = {
id_photos: [],
live_photos: [],
live_video: [],
motion_captures: []
};

expect(report).toEqual(
getExpectedFacialSimilarityReport(
exampleFacialSimilarityPhotoReport,
extraProperties
)
getExpectedFacialSimilarityPhotoReport(exampleFacialSimilarityPhotoReport, {
live_photos: [
{
id: (report as FacialSimilarityPhotoReport).live_photos[0].id
}
]
})
);
}, 30000);

Expand Down
2 changes: 1 addition & 1 deletion test/resources/workflow-runs-outputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe("workflow runs outputs", () => {
line2: expect.stringMatching(/^[0-9A-Za-z\s'-]+$/),
line3: expect.stringMatching(/^[0-9A-Za-z\s'-]+$/),
postcode: expect.stringMatching(/^[0-9A-Za-z\s-]+$/),
town: expect.stringMatching(/^[A-Za-z\s]+$/)
town: expect.stringMatching(/^[A-Za-z\s\.-]+$/)
},
country_residence: expect.stringMatching(/^[A-Z]{3}$/),
dob: expect.stringMatching(/^[0-9-]+$/),
Expand Down
4 changes: 4 additions & 0 deletions test/test-examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ export const exampleFacialSimilarityPhotoReport: FacialSimilarityPhotoReport = {
name: "facial_similarity_photo_fully_auto",
result: "clear",
status: "complete",
id_photos: [],
live_photos: [],
live_videos: [],
motion_captures: [],
sub_result: null,
breakdown: {
visual_authenticity: {
Expand Down
9 changes: 5 additions & 4 deletions test/test-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isAxiosError } from "axios";
import { createReadStream, readFileSync } from "fs";
import { readFileSync } from "fs";
import "dotenv/config";

import {
Expand All @@ -11,6 +11,7 @@ import {
DocumentReport,
FacialSimilarityPhotoReport,
FileTransfer,
CountryCodes,
LiveVideo,
LocationBuilder,
MotionCapture,
Expand Down Expand Up @@ -53,11 +54,11 @@ export async function createApplicant(overrideProperties = {}) {
last_name: "Applicant",
address: {
postcode: "AB12 3AB",
country: "GBR"
country: CountryCodes.Gbr
},
location: {
ip_address: "127.0.0.1",
country_of_residence: "GBR"
country_of_residence: CountryCodes.Gbr
},
email: "[email protected]",
phone_number: "351911111111",
Expand Down Expand Up @@ -255,7 +256,7 @@ export function getExpectedDocumentReport(
});
}

export function getExpectedFacialSimilarityReport(
export function getExpectedFacialSimilarityPhotoReport(
exampleReport: FacialSimilarityPhotoReport,
overrideProperties = {}
) {
Expand Down

0 comments on commit e4ebba4

Please sign in to comment.