Skip to content

Commit f3c8075

Browse files
authored
Merge pull request #43 from moovfinancial/fe-2041
FE-2041 Fix failing tests
2 parents ec32e0b + c288448 commit f3c8075

File tree

10 files changed

+59
-89
lines changed

10 files changed

+59
-89
lines changed

bun.lock

Lines changed: 30 additions & 57 deletions
Large diffs are not rendered by default.

test/tests/accounts.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("Accounts", () => {
2828
test("should fail if the account type is not supported", async () => {
2929
await expect(() =>
3030
createAccount({
31-
accountType: "not-a-valid-account-type" as AccountType,
31+
accountType: "not-a-valid-account-type" as "business" | "individual",
3232
}),
3333
).toThrowError();
3434
});
@@ -102,7 +102,7 @@ describe("Accounts", () => {
102102
const legalBusinessName = chance.company();
103103
const { result } = await moov.accounts.update({
104104
accountID: account.accountID,
105-
createAccountUpdate: { profile: { business: { legalBusinessName } } },
105+
patchAccount: { profile: { business: { legalBusinessName } } },
106106
});
107107
expect(result).toBeDefined();
108108
expect(result.accountID).toEqual(account.accountID);

test/tests/bankAccounts.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ describe("Bank Accounts", () => {
102102
accountID,
103103
bankAccountID: bankAccount.bankAccountID!,
104104
}),
105-
).toThrowError(
106-
expect.objectContaining({ error: "unacceptable bank account status verified for verification" }),
107-
);
105+
).toThrowError(/found existing active verification/i);
108106
});
109107
test("should be able to get the bank account verification status", async () => {
110108
const { result } = await moov.bankAccounts.initiateVerification({
@@ -151,11 +149,7 @@ describe("Bank Accounts", () => {
151149
accountID,
152150
bankAccountID: bankAccount.bankAccountID!,
153151
}),
154-
).toThrowError(
155-
expect.objectContaining({
156-
error: "unexpected account status: expected 'new' or 'verificationFailed', found 'verified'",
157-
}),
158-
);
152+
).toThrowError(/unexpected account status: expected 'new' or 'verificationFailed'/i);
159153
});
160154
});
161155
});

test/tests/capabilities.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("Capabilities", () => {
2727
moov.capabilities.list({
2828
accountID: "not-a-valid-account-id",
2929
}),
30-
).toThrowError("API error occurred: Status 403 Content-Type Body ");
30+
).toThrowError(/API error occurred: Status 403/);
3131
});
3232
});
3333

@@ -79,7 +79,7 @@ describe("Capabilities", () => {
7979
accountID: "not-a-valid-account-id",
8080
capabilityID: "transfers",
8181
}),
82-
).toThrowError("API error occurred: Status 403 Content-Type Body ");
82+
).toThrowError(/API error occurred: Status 403/i);
8383
});
8484

8585
test("getting a capability should fail if the capability does not exist", async () => {
@@ -113,7 +113,7 @@ describe("Capabilities", () => {
113113
capabilities: ["transfers"],
114114
},
115115
}),
116-
).toThrowError("API error occurred: Status 403 Content-Type Body ");
116+
).toThrowError(/API error occurred: Status 403/i);
117117
});
118118

119119
test("requesting capabilities should fail if the capability is invalid", async () => {

test/tests/cards.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe("Cards", () => {
9090

9191
test("Getting a card should fail when I pass incorrect params", async () => {
9292
expect(async () => await moov.cards.get({ accountID, cardID: "invalid-card-id" })).toThrowError(
93-
"API error occurred: Status 404 Content-Type Body",
93+
/API error occurred: Status 404/,
9494
);
9595
});
9696

@@ -109,7 +109,7 @@ describe("Cards", () => {
109109

110110
test("listing should fail when I pass incorrect params", async () => {
111111
expect(async () => await moov.cards.list({ accountID: "invalid-account-id" })).toThrowError(
112-
"API error occurred: Status 403 Content-Type Body ",
112+
/API error occurred: Status 403/,
113113
);
114114
});
115115
});
@@ -145,7 +145,7 @@ describe("Cards", () => {
145145
},
146146
},
147147
}),
148-
).toThrowError('API error occurred: {"expiration":"year: the length must be exactly 2."}');
148+
).toThrowError(/API error occurred:.*\"expiration\":\"year: the length must be exactly 2.\"/i);
149149
});
150150
});
151151

@@ -160,7 +160,7 @@ describe("Cards", () => {
160160

161161
test("disabling should fail when I pass incorrect params", async () => {
162162
expect(async () => await moov.cards.disable({ accountID, cardID: "invalid-card-id" })).toThrowError(
163-
"API error occurred: Status 404 Content-Type Body",
163+
/API error occurred: Status 404/i,
164164
);
165165
});
166166
});

test/tests/paymentMethods.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("PaymentMethods", () => {
2626
});
2727
test("listing should fail if accountID is not provided", async () => {
2828
expect(() => moov.paymentMethods.list({ accountID: "" })).toThrowError(
29-
"API error occurred: Status 403 Content-Type Body",
29+
/API error occurred: Status 403/i,
3030
);
3131
});
3232
});
@@ -43,12 +43,12 @@ describe("PaymentMethods", () => {
4343
});
4444
test("getting should fail if accountID and paymentMethodID are not correct", async () => {
4545
expect(() => moov.paymentMethods.get({ accountID: "@#$@#$@$", paymentMethodID: "@#$@#$@#$@" })).toThrowError(
46-
"API error occurred: Status 403 Content-Type Body",
46+
/API error occurred: Status 403/i,
4747
);
4848
});
4949
test("getting should fail if paymentMethodID is not provided", async () => {
5050
expect(() => moov.paymentMethods.get({ accountID: accountID, paymentMethodID: "" })).toThrowError(
51-
"API error occurred: Status 403 Content-Type Body",
51+
/API error occurred: Status 403/i,
5252
);
5353
});
5454
});

test/tests/representatives.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("Representative", () => {
4040
});
4141
test("listing representatives should fail if the account is not found", async () => {
4242
expect(() => moov.representatives.list({ accountID: "not-a-valid-account-id" })).toThrowError(
43-
"API error occurred: Status 403 Content-Type Body ",
43+
/API error occurred: Status 403/i,
4444
);
4545
});
4646
test("getting a representative should fail if the account is not found", async () => {
@@ -49,7 +49,7 @@ describe("Representative", () => {
4949
accountID: "not-a-valid-account-id",
5050
representativeID: representative.representativeID,
5151
}),
52-
).toThrowError("API error occurred: Status 403 Content-Type Body ");
52+
).toThrowError(/API error occurred: Status 403/i);
5353
});
5454
});
5555
describe("Updating a representative", () => {
@@ -76,7 +76,7 @@ describe("Representative", () => {
7676
7777
},
7878
}),
79-
).toThrowError("API error occurred: Status 403 Content-Type Body ");
79+
).toThrowError(/API error occurred: Status 403/i);
8080
});
8181
});
8282
});

test/tests/transfers.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeAll, beforeEach, describe, expect, test } from "bun:test";
22
import { ids, moov } from "../setup";
33
import {
4-
crateAccountAndGetTransferOptions,
4+
createAccountAndGetTransferOptions,
55
createAccount,
66
createAccountWithWallet,
77
createBankAccount,
@@ -10,20 +10,20 @@ import {
1010
UUID_REGEX,
1111
waitFor,
1212
} from "../utils/utils";
13-
import type { CreateTransferOptions, PaymentMethod, TransferResponse } from "../../models/components";
13+
import type { CreateTransferOptions, PaymentMethod, Transfer, CreatedTransfer, AsyncTransfer } from "../../models/components";
1414
import { sleep } from "bun";
1515
import type { CreateTransferRequest } from "../../models/operations";
1616

1717
let destinationAccountID: string;
1818
let sourcePaymentMethodID: string;
1919
let destinationPaymentMethodID: string;
20-
let transfer: TransferResponse;
20+
let transfer: Transfer | CreatedTransfer | AsyncTransfer;
2121
describe("Transfers", () => {
22-
// Setup accounts and payment methods
2322

2423
describe("Transfer Creation", () => {
2524
beforeAll(async () => {
26-
const availablePaymentMethods = await crateAccountAndGetTransferOptions();
25+
// Setup accounts and payment methods
26+
const availablePaymentMethods = await createAccountAndGetTransferOptions();
2727
sourcePaymentMethodID = availablePaymentMethods.sourceOptions![0].paymentMethodID!;
2828
destinationPaymentMethodID = availablePaymentMethods.destinationOptions![0].paymentMethodID!;
2929
});
@@ -99,7 +99,7 @@ describe("Transfers", () => {
9999
};
100100

101101
await expect(() => moov.transfers.create(transferRequest)).toThrowError(
102-
'API error occurred: {"amount":"amount value must be greater than or equal to 0.01"}',
102+
/API error occurred: {"amount":"amount value must be greater than or equal to 0.01"}/i,
103103
);
104104
});
105105
});

test/tests/wallets.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("Wallets", () => {
2222
});
2323
test("listing should fail if accountID is not provided", async () => {
2424
expect(() => moov.wallets.list({ accountID: "" })).toThrowError(
25-
"API error occurred: Status 403 Content-Type Body",
25+
/API error occurred: Status 403/i
2626
);
2727
});
2828
});

test/utils/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export const createCard = async (accountID: string, card: DeepPartial<LinkCard>
217217
return { card: result, cardNumber: mergedCard.cardNumber };
218218
};
219219

220-
export const crateAccountAndGetTransferOptions = async () => {
220+
export const createAccountAndGetTransferOptions = async () => {
221221
const doneCheck = (data: { result: PaymentMethod[] }) => data.result.length > 0;
222222

223223
// Create destination account with card and bank account
@@ -239,7 +239,10 @@ export const crateAccountAndGetTransferOptions = async () => {
239239
destination: { accountID: destinationAccountID },
240240
amount: { currency: "USD", value: 1 },
241241
};
242-
const { result: availablePaymentMethods } = await moov.transfers.generateOptions(generateOptionsRequest);
242+
const { result: availablePaymentMethods } = await moov.transfers.generateOptions({
243+
accountID: SOURCE_ACCOUNT_ID,
244+
createTransferOptions: generateOptionsRequest,
245+
});
243246
expect(availablePaymentMethods).toBeDefined();
244247
expect(availablePaymentMethods.sourceOptions).toBeArray();
245248
expect(availablePaymentMethods.sourceOptions!.length).toBeGreaterThan(0);

0 commit comments

Comments
 (0)