Skip to content

Commit ad873a3

Browse files
committed
Update all tests to assert structure
1 parent 8ca966a commit ad873a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+811
-1367
lines changed

src/__tests__/accounts.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Code originally generated by Speakeasy (https://www.speakeasy.com).
3+
*/
4+
15
import { expect, test } from "vitest";
26
import { Dwolla } from "../index.js";
37
import { createTestHTTPClient } from "./testclient.js";

src/__tests__/accountsexchanges.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2+
* Code originally generated by Speakeasy (https://www.speakeasy.com).
33
*/
44

55
import { expect, test } from "vitest";
@@ -51,12 +51,12 @@ test("Accounts Exchanges Create Account Exchange", async () => {
5151
links: {
5252
exchangePartner: {
5353
href:
54-
"https://api.dwolla.com/exchange-partners/292317ec-e252-47d8-93c3-2d128e037aa4",
54+
"https://api-sandbox.dwolla.com/exchange-partners/bca8d065-49a5-475b-a6b4-509bc8504d22",
5555
},
5656
},
57-
token: "someMXProcessorToken",
57+
token: "eyJhY2NvdW50SWQiOiJBQ1QtNWY1ZWIwYTgtYTJiNC00NGQxLTk3ODYtMWVmOTM5NzZkYTU4IiwibWVtYmVySWQiOiJNQlItNTcxN2E5MDQtNDA0NC00YjQyLWIxMDctZDQyOWE0YjIzOGY5In0=",
5858
});
5959
expect(result).toBeDefined();
6060
expect(result.result).toBeDefined();
61-
expect(result.result).toEqual({});
61+
// Create exchange returns an empty object on success
6262
});

src/__tests__/accountsfundingsources.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2+
* Code originally generated by Speakeasy (https://www.speakeasy.com).
33
*/
44

55
import { expect, test } from "vitest";

src/__tests__/accountsmasspayments.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2+
* Code originally generated by Speakeasy (https://www.speakeasy.com).
33
*/
44

55
import { expect, test } from "vitest";

src/__tests__/accountstransfers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2+
* Code originally generated by Speakeasy (https://www.speakeasy.com).
33
*/
44

55
import { expect, test } from "vitest";

src/__tests__/balance.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2+
* Code originally generated by Speakeasy (https://www.speakeasy.com).
33
*/
44

55
import { expect, test } from "vitest";
Lines changed: 62 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,46 @@
11
/*
2-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2+
* Code originally generated by Speakeasy (https://www.speakeasy.com).
33
*/
44

5-
import { expect, test } from "vitest";
5+
import { beforeAll, expect, test } from "vitest";
66
import { Dwolla } from "../index.js";
77
import { createTestHTTPClient } from "./testclient.js";
88

9+
let beneficialOwnerId: string | undefined;
10+
11+
beforeAll(async () => {
12+
const dwolla = new Dwolla({
13+
serverURL: "https://api-sandbox.dwolla.com",
14+
httpClient: createTestHTTPClient("beneficialOwners"),
15+
security: {
16+
clientID: process.env["DWOLLA_CLIENT_ID"] ?? "value",
17+
clientSecret: process.env["DWOLLA_CLIENT_SECRET"] ?? "value",
18+
},
19+
});
20+
21+
const createBeneficialOwnerResult = await dwolla.customers.beneficialOwners.create({
22+
id: "274322f3-3004-41ea-8448-2193b25dd745",
23+
requestBody: {
24+
firstName: "incomplete",
25+
lastName: "Doe",
26+
dateOfBirth: "1970-01-01",
27+
address: {
28+
address1: "123 Main St",
29+
city: "Des Moines",
30+
stateProvinceRegion: "IA",
31+
country: "US",
32+
postalCode: "50309",
33+
},
34+
ssn: "123456789",
35+
},
36+
});
37+
38+
const locationHeader =
39+
createBeneficialOwnerResult?.headers["Location"]?.[0] ?? createBeneficialOwnerResult?.headers["location"]?.[0];
40+
expect(locationHeader).toBeDefined();
41+
beneficialOwnerId = new URL(locationHeader as string).pathname.split("/").pop();
42+
});
43+
944
test("Beneficialowners Retrieve Beneficial Owner", async () => {
1045
const testHttpClient = createTestHTTPClient("retrieveBeneficialOwner");
1146

@@ -19,32 +54,20 @@ test("Beneficialowners Retrieve Beneficial Owner", async () => {
1954
});
2055

2156
const result = await dwolla.beneficialOwners.get({
22-
id: "<id>",
57+
id: beneficialOwnerId!,
2358
});
2459
expect(result).toBeDefined();
25-
expect(result).toEqual({
26-
links: {
27-
"key": {
28-
href: "https://api.dwolla.com",
29-
type: "application/vnd.dwolla.v1.hal+json",
30-
resourceType: "resource-type",
31-
},
32-
},
33-
id: "d3d6b41e-5567-4bc6-9c6e-0efd0a3e647e",
34-
firstName: "John",
35-
lastName: "Doe",
36-
address: {
37-
address1: "462 Main Street",
38-
address2: "Suite 123",
39-
address3: "Unit 123",
40-
city: "Des Moines",
41-
postalCode: "50309",
42-
country: "USA",
43-
stateProvinceRegion: "IA",
44-
},
45-
verificationStatus: "verified",
46-
created: new Date("2022-07-23T00:18:21.419Z"),
47-
});
60+
// Assert structure rather than exact payload
61+
expect(result.id).toBeDefined();
62+
expect(result.firstName).toBeDefined();
63+
expect(result.lastName).toBeDefined();
64+
expect(result.verificationStatus).toBeDefined();
65+
expect(result.created).toBeInstanceOf(Date);
66+
expect(result.links).toBeDefined();
67+
expect(result.address).toBeDefined();
68+
expect(result.address?.address1).toBeDefined();
69+
expect(result.address?.city).toBeDefined();
70+
expect(result.address?.country).toBeDefined();
4871
});
4972

5073
test("Beneficialowners Update Beneficial Owner", async () => {
@@ -60,7 +83,7 @@ test("Beneficialowners Update Beneficial Owner", async () => {
6083
});
6184

6285
const result = await dwolla.beneficialOwners.update({
63-
id: "<id>",
86+
id: beneficialOwnerId!,
6487
requestBody: {
6588
firstName: "Lauryn",
6689
lastName: "D'Amore",
@@ -71,49 +94,21 @@ test("Beneficialowners Update Beneficial Owner", async () => {
7194
address3: "Unit 123",
7295
city: "Des Moines",
7396
postalCode: "50309",
74-
country: "USA",
97+
country: "US",
7598
stateProvinceRegion: "IA",
7699
},
77-
passport: {
78-
number: "<value>",
79-
country: "Suriname",
80-
},
100+
ssn: "123-45-6789",
81101
},
82102
});
83103
expect(result).toBeDefined();
84-
expect(result).toEqual({
85-
links: {
86-
"key": {
87-
href: "https://api.dwolla.com",
88-
type: "application/vnd.dwolla.v1.hal+json",
89-
resourceType: "resource-type",
90-
},
91-
"key1": {
92-
href: "https://api.dwolla.com",
93-
type: "application/vnd.dwolla.v1.hal+json",
94-
resourceType: "resource-type",
95-
},
96-
"key2": {
97-
href: "https://api.dwolla.com",
98-
type: "application/vnd.dwolla.v1.hal+json",
99-
resourceType: "resource-type",
100-
},
101-
},
102-
id: "d3d6b41e-5567-4bc6-9c6e-0efd0a3e647e",
103-
firstName: "John",
104-
lastName: "Doe",
105-
address: {
106-
address1: "462 Main Street",
107-
address2: "Suite 123",
108-
address3: "Unit 123",
109-
city: "Des Moines",
110-
postalCode: "50309",
111-
country: "USA",
112-
stateProvinceRegion: "IA",
113-
},
114-
verificationStatus: "verified",
115-
created: new Date("2022-07-23T00:18:21.419Z"),
116-
});
104+
// Assert structure rather than exact payload
105+
expect(result.id).toBeDefined();
106+
expect(result.firstName).toBeDefined();
107+
expect(result.lastName).toBeDefined();
108+
expect(result.verificationStatus).toBeDefined();
109+
expect(result.created).toBeInstanceOf(Date);
110+
expect(result.links).toBeDefined();
111+
expect(result.address).toBeDefined();
117112
});
118113

119114
test("Beneficialowners Delete Beneficial Owner", async () => {
@@ -129,8 +124,8 @@ test("Beneficialowners Delete Beneficial Owner", async () => {
129124
});
130125

131126
const result = await dwolla.beneficialOwners.delete({
132-
id: "<id>",
127+
id: beneficialOwnerId!,
133128
});
134129
expect(result).toBeDefined();
135-
expect(result).toEqual({});
130+
// Delete returns an empty object on success
136131
});

src/__tests__/beneficialownersdocuments.test.ts

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,34 @@ test("Beneficialowners Documents List Beneficial Owner Documents", async () => {
1919
});
2020

2121
const result = await dwolla.beneficialOwners.documents.list({
22-
id: "<id>",
22+
id: "ea164188-6585-4284-9dbb-932ee1b7b21a",
2323
});
2424
expect(result).toBeDefined();
25-
expect(result).toEqual({
26-
links: {
27-
"key": {
28-
href: "https://api.dwolla.com",
29-
type: "application/vnd.dwolla.v1.hal+json",
30-
resourceType: "resource-type",
31-
},
32-
},
33-
embedded: {
34-
documents: [
35-
{
36-
links: {
37-
self: {
38-
href: "https://api.dwolla.com",
39-
type: "application/vnd.dwolla.v1.hal+json",
40-
resourceType: "resource-type",
41-
},
42-
},
43-
id: "56502f7a-fa59-4a2f-8579-0f8bc9d7b9cc",
44-
status: "reviewed",
45-
type: "passport",
46-
created: new Date("2015-09-29T21:42:16.000Z"),
47-
documentVerificationStatus: "rejected",
48-
failureReason: "ScanDobMismatch",
49-
allFailureReasons: [
50-
{
51-
reason: "ScanDobMismatch",
52-
description: "Scan DOB does not match DOB on account",
53-
},
54-
{
55-
reason: "ScanDobMismatch",
56-
description: "Scan DOB does not match DOB on account",
57-
},
58-
],
59-
},
60-
],
61-
},
62-
total: 2,
63-
});
25+
// Assert structure rather than exact payload
26+
expect(result.links).toBeDefined();
27+
expect(result.links?.["self"]).toBeDefined();
28+
expect(result.embedded).toBeDefined();
29+
expect(Array.isArray(result.embedded?.documents ?? [])).toBe(true);
30+
expect(typeof result.total).toBe("number");
31+
32+
// Validate shape of the first document if present
33+
if ((result.embedded?.documents?.length ?? 0) > 0) {
34+
const first = result.embedded!.documents![0]!;
35+
expect(first.id).toBeDefined();
36+
expect(first.status).toBeDefined();
37+
expect(first.type).toBeDefined();
38+
expect(first.created).toBeInstanceOf(Date);
39+
expect(first.links).toBeDefined();
40+
expect(first.links?.self).toBeDefined();
41+
// Optional fields
42+
if (first.documentVerificationStatus) {
43+
expect(typeof first.documentVerificationStatus).toBe("string");
44+
}
45+
if (first.failureReason) {
46+
expect(typeof first.failureReason).toBe("string");
47+
}
48+
if (first.allFailureReasons) {
49+
expect(Array.isArray(first.allFailureReasons)).toBe(true);
50+
}
51+
}
6452
});

src/__tests__/beneficialownership.test.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,13 @@ test("Beneficialownership Get Beneficial Ownership Status For Customer", async (
2121
});
2222

2323
const result = await dwolla.customers.beneficialOwnership.get({
24-
id: "<id>",
24+
id: "274322f3-3004-41ea-8448-2193b25dd745",
2525
});
2626
expect(result).toBeDefined();
27-
expect(result).toEqual({
28-
links: {
29-
self: {
30-
href: "https://api.dwolla.com",
31-
type: "application/vnd.dwolla.v1.hal+json",
32-
resourceType: "resource-type",
33-
},
34-
},
35-
status: "uncertified",
36-
});
27+
// Assert structure rather than exact payload
28+
expect(result.status).toBeDefined();
29+
expect(result.links).toBeDefined();
30+
expect(result.links?.self).toBeDefined();
3731
});
3832

3933
test("Beneficialownership Certify Beneficial Ownership For Customer", async () => {
@@ -51,20 +45,14 @@ test("Beneficialownership Certify Beneficial Ownership For Customer", async () =
5145
});
5246

5347
const result = await dwolla.customers.beneficialOwnership.certify({
54-
id: "<id>",
48+
id: "274322f3-3004-41ea-8448-2193b25dd745",
5549
requestBody: {
56-
status: "<value>",
50+
status: "certified",
5751
},
5852
});
5953
expect(result).toBeDefined();
60-
expect(result).toEqual({
61-
links: {
62-
self: {
63-
href: "https://api.dwolla.com",
64-
type: "application/vnd.dwolla.v1.hal+json",
65-
resourceType: "resource-type",
66-
},
67-
},
68-
status: "uncertified",
69-
});
54+
// Assert structure rather than exact payload
55+
expect(result.status).toBeDefined();
56+
expect(result.links).toBeDefined();
57+
expect(result.links?.self).toBeDefined();
7058
});

src/__tests__/businessclassifications.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
2+
* Code originally generated by Speakeasy (https://www.speakeasy.com).
33
*/
44

55
import { expect, test } from "vitest";

0 commit comments

Comments
 (0)