Skip to content

Commit 6fd618b

Browse files
committed
Add tests
1 parent d1f6b14 commit 6fd618b

1 file changed

Lines changed: 221 additions & 0 deletions

File tree

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
import { ObjectSerializer } from "../../typings/balancePlatform/objectSerializer";
2+
import { AULocalAccountIdentification } from "../../typings/balancePlatform/aULocalAccountIdentification";
3+
import { IbanAccountIdentification } from "../../typings/balancePlatform/ibanAccountIdentification";
4+
import { NumberAndBicAccountIdentification } from "../../typings/balancePlatform/numberAndBicAccountIdentification";
5+
import { USLocalAccountIdentification } from "../../typings/balancePlatform/uSLocalAccountIdentification";
6+
import { AddressRequirement } from "../../typings/balancePlatform/addressRequirement";
7+
import { AmountMinMaxRequirement } from "../../typings/balancePlatform/amountMinMaxRequirement";
8+
import { IbanAccountIdentificationRequirement } from "../../typings/balancePlatform/ibanAccountIdentificationRequirement";
9+
import { PaymentInstrumentRequirement } from "../../typings/balancePlatform/paymentInstrumentRequirement";
10+
11+
describe("ObjectSerializer - BankAccountAccountIdentification discriminator", () => {
12+
it("should resolve 'iban' to IbanAccountIdentification", () => {
13+
const type = ObjectSerializer.findCorrectType({ type: "iban" }, "BankAccountAccountIdentification");
14+
expect(type).toBe("IbanAccountIdentification");
15+
});
16+
17+
it("should resolve 'usLocal' to USLocalAccountIdentification", () => {
18+
const type = ObjectSerializer.findCorrectType({ type: "usLocal" }, "BankAccountAccountIdentification");
19+
expect(type).toBe("USLocalAccountIdentification");
20+
});
21+
22+
it("should resolve 'auLocal' to AULocalAccountIdentification", () => {
23+
const type = ObjectSerializer.findCorrectType({ type: "auLocal" }, "BankAccountAccountIdentification");
24+
expect(type).toBe("AULocalAccountIdentification");
25+
});
26+
27+
it("should resolve 'numberAndBic' to NumberAndBicAccountIdentification", () => {
28+
const type = ObjectSerializer.findCorrectType({ type: "numberAndBic" }, "BankAccountAccountIdentification");
29+
expect(type).toBe("NumberAndBicAccountIdentification");
30+
});
31+
32+
it("should deserialize an iban payload into IbanAccountIdentification", () => {
33+
const raw = { type: "iban", iban: "NL91ABNA0417164300", bic: "ABNANL2A" };
34+
const result = ObjectSerializer.deserialize(raw, "BankAccountAccountIdentification") as IbanAccountIdentification;
35+
expect(result).toBeInstanceOf(IbanAccountIdentification);
36+
expect(result.iban).toBe("NL91ABNA0417164300");
37+
expect(result.bic).toBe("ABNANL2A");
38+
expect(result.type).toBe("iban");
39+
});
40+
41+
it("should deserialize a usLocal payload into USLocalAccountIdentification", () => {
42+
const raw = { type: "usLocal", accountNumber: "123456789", routingNumber: "021000021", accountType: "checking" };
43+
const result = ObjectSerializer.deserialize(raw, "BankAccountAccountIdentification") as USLocalAccountIdentification;
44+
expect(result).toBeInstanceOf(USLocalAccountIdentification);
45+
expect(result.accountNumber).toBe("123456789");
46+
expect(result.routingNumber).toBe("021000021");
47+
expect(result.type).toBe("usLocal");
48+
});
49+
50+
it("should deserialize an auLocal payload into AULocalAccountIdentification", () => {
51+
const raw = { type: "auLocal", accountNumber: "11111111", bsbCode: "123456" };
52+
const result = ObjectSerializer.deserialize(raw, "BankAccountAccountIdentification") as AULocalAccountIdentification;
53+
expect(result).toBeInstanceOf(AULocalAccountIdentification);
54+
expect(result.accountNumber).toBe("11111111");
55+
expect(result.bsbCode).toBe("123456");
56+
});
57+
58+
it("should deserialize a numberAndBic payload into NumberAndBicAccountIdentification", () => {
59+
const raw = { type: "numberAndBic", accountNumber: "0012345678", bic: "DEUTDEDB" };
60+
const result = ObjectSerializer.deserialize(raw, "BankAccountAccountIdentification") as NumberAndBicAccountIdentification;
61+
expect(result).toBeInstanceOf(NumberAndBicAccountIdentification);
62+
expect(result.accountNumber).toBe("0012345678");
63+
expect(result.bic).toBe("DEUTDEDB");
64+
});
65+
66+
it("should round-trip an iban payload through serialize then deserialize", () => {
67+
const raw = { type: "iban", iban: "GB29NWBK60161331926819" };
68+
const instance = ObjectSerializer.deserialize(raw, "BankAccountAccountIdentification") as IbanAccountIdentification;
69+
const serialized = ObjectSerializer.serialize(instance, "IbanAccountIdentification");
70+
const roundTripped = ObjectSerializer.deserialize(serialized, "BankAccountAccountIdentification") as IbanAccountIdentification;
71+
expect(roundTripped.iban).toBe("GB29NWBK60161331926819");
72+
expect(roundTripped.type).toBe("iban");
73+
});
74+
});
75+
76+
describe("ObjectSerializer - BankAccountIdentificationValidationRequestAccountIdentification discriminator", () => {
77+
it("should resolve 'iban' to IbanAccountIdentification", () => {
78+
const type = ObjectSerializer.findCorrectType({ type: "iban" }, "BankAccountIdentificationValidationRequestAccountIdentification");
79+
expect(type).toBe("IbanAccountIdentification");
80+
});
81+
82+
it("should resolve 'usLocal' to USLocalAccountIdentification", () => {
83+
const type = ObjectSerializer.findCorrectType({ type: "usLocal" }, "BankAccountIdentificationValidationRequestAccountIdentification");
84+
expect(type).toBe("USLocalAccountIdentification");
85+
});
86+
87+
it("should resolve 'auLocal' to AULocalAccountIdentification", () => {
88+
const type = ObjectSerializer.findCorrectType({ type: "auLocal" }, "BankAccountIdentificationValidationRequestAccountIdentification");
89+
expect(type).toBe("AULocalAccountIdentification");
90+
});
91+
92+
it("should deserialize an iban payload into IbanAccountIdentification", () => {
93+
const raw = { type: "iban", iban: "DE89370400440532013000" };
94+
const result = ObjectSerializer.deserialize(raw, "BankAccountIdentificationValidationRequestAccountIdentification") as IbanAccountIdentification;
95+
expect(result).toBeInstanceOf(IbanAccountIdentification);
96+
expect(result.iban).toBe("DE89370400440532013000");
97+
expect(result.type).toBe("iban");
98+
});
99+
100+
it("should deserialize a usLocal payload into USLocalAccountIdentification", () => {
101+
const raw = { type: "usLocal", accountNumber: "987654321", routingNumber: "011000015" };
102+
const result = ObjectSerializer.deserialize(raw, "BankAccountIdentificationValidationRequestAccountIdentification") as USLocalAccountIdentification;
103+
expect(result).toBeInstanceOf(USLocalAccountIdentification);
104+
expect(result.accountNumber).toBe("987654321");
105+
expect(result.routingNumber).toBe("011000015");
106+
});
107+
});
108+
109+
describe("ObjectSerializer - PaymentInstrumentAdditionalBankAccountIdentificationsInner discriminator", () => {
110+
it("should resolve 'iban' to IbanAccountIdentification", () => {
111+
const type = ObjectSerializer.findCorrectType({ type: "iban" }, "PaymentInstrumentAdditionalBankAccountIdentificationsInner");
112+
expect(type).toBe("IbanAccountIdentification");
113+
});
114+
115+
it("should deserialize an iban payload into IbanAccountIdentification", () => {
116+
const raw = { type: "iban", iban: "FR7630006000011234567890189" };
117+
const result = ObjectSerializer.deserialize(raw, "PaymentInstrumentAdditionalBankAccountIdentificationsInner") as IbanAccountIdentification;
118+
expect(result).toBeInstanceOf(IbanAccountIdentification);
119+
expect(result.iban).toBe("FR7630006000011234567890189");
120+
expect(result.type).toBe("iban");
121+
});
122+
123+
it("should round-trip an iban payload through serialize then deserialize", () => {
124+
const raw = { type: "iban", iban: "IT60X0542811101000000123456" };
125+
const instance = ObjectSerializer.deserialize(raw, "PaymentInstrumentAdditionalBankAccountIdentificationsInner") as IbanAccountIdentification;
126+
const serialized = ObjectSerializer.serialize(instance, "IbanAccountIdentification");
127+
const roundTripped = ObjectSerializer.deserialize(serialized, "PaymentInstrumentAdditionalBankAccountIdentificationsInner") as IbanAccountIdentification;
128+
expect(roundTripped.iban).toBe("IT60X0542811101000000123456");
129+
});
130+
});
131+
132+
describe("ObjectSerializer - TransferRouteRequirementsInner discriminator", () => {
133+
it("should resolve 'addressRequirement' to AddressRequirement", () => {
134+
const type = ObjectSerializer.findCorrectType({ type: "addressRequirement" }, "TransferRouteRequirementsInner");
135+
expect(type).toBe("AddressRequirement");
136+
});
137+
138+
it("should resolve 'amountMinMaxRequirement' to AmountMinMaxRequirement", () => {
139+
const type = ObjectSerializer.findCorrectType({ type: "amountMinMaxRequirement" }, "TransferRouteRequirementsInner");
140+
expect(type).toBe("AmountMinMaxRequirement");
141+
});
142+
143+
it("should resolve 'amountNonZeroDecimalsRequirement' to AmountNonZeroDecimalsRequirement", () => {
144+
const type = ObjectSerializer.findCorrectType({ type: "amountNonZeroDecimalsRequirement" }, "TransferRouteRequirementsInner");
145+
expect(type).toBe("AmountNonZeroDecimalsRequirement");
146+
});
147+
148+
it("should resolve 'bankAccountIdentificationTypeRequirement' to BankAccountIdentificationTypeRequirement", () => {
149+
const type = ObjectSerializer.findCorrectType({ type: "bankAccountIdentificationTypeRequirement" }, "TransferRouteRequirementsInner");
150+
expect(type).toBe("BankAccountIdentificationTypeRequirement");
151+
});
152+
153+
it("should resolve 'ibanAccountIdentificationRequirement' to IbanAccountIdentificationRequirement", () => {
154+
const type = ObjectSerializer.findCorrectType({ type: "ibanAccountIdentificationRequirement" }, "TransferRouteRequirementsInner");
155+
expect(type).toBe("IbanAccountIdentificationRequirement");
156+
});
157+
158+
it("should resolve 'paymentInstrumentRequirement' to PaymentInstrumentRequirement", () => {
159+
const type = ObjectSerializer.findCorrectType({ type: "paymentInstrumentRequirement" }, "TransferRouteRequirementsInner");
160+
expect(type).toBe("PaymentInstrumentRequirement");
161+
});
162+
163+
it("should resolve 'usInstantPayoutAddressRequirement' to USInstantPayoutAddressRequirement", () => {
164+
const type = ObjectSerializer.findCorrectType({ type: "usInstantPayoutAddressRequirement" }, "TransferRouteRequirementsInner");
165+
expect(type).toBe("USInstantPayoutAddressRequirement");
166+
});
167+
168+
it("should resolve 'usInternationalAchAddressRequirement' to USInternationalAchAddressRequirement", () => {
169+
const type = ObjectSerializer.findCorrectType({ type: "usInternationalAchAddressRequirement" }, "TransferRouteRequirementsInner");
170+
expect(type).toBe("USInternationalAchAddressRequirement");
171+
});
172+
173+
it("should resolve 'usInternationalAchPriorityRequirement' to USInternationalAchPriorityRequirement", () => {
174+
const type = ObjectSerializer.findCorrectType({ type: "usInternationalAchPriorityRequirement" }, "TransferRouteRequirementsInner");
175+
expect(type).toBe("USInternationalAchPriorityRequirement");
176+
});
177+
178+
it("should deserialize an addressRequirement payload into AddressRequirement", () => {
179+
const raw = { type: "addressRequirement", description: "Street address required", requiredAddressFields: ["line1", "postalCode"] };
180+
const result = ObjectSerializer.deserialize(raw, "TransferRouteRequirementsInner") as AddressRequirement;
181+
expect(result).toBeInstanceOf(AddressRequirement);
182+
expect(result.description).toBe("Street address required");
183+
expect(result.type).toBe("addressRequirement");
184+
});
185+
186+
it("should deserialize an amountMinMaxRequirement payload into AmountMinMaxRequirement", () => {
187+
const raw = { type: "amountMinMaxRequirement", min: 100, max: 100000 };
188+
const result = ObjectSerializer.deserialize(raw, "TransferRouteRequirementsInner") as AmountMinMaxRequirement;
189+
expect(result).toBeInstanceOf(AmountMinMaxRequirement);
190+
expect(result.min).toBe(100);
191+
expect(result.max).toBe(100000);
192+
expect(result.type).toBe("amountMinMaxRequirement");
193+
});
194+
195+
it("should deserialize an ibanAccountIdentificationRequirement payload into IbanAccountIdentificationRequirement", () => {
196+
const raw = { type: "ibanAccountIdentificationRequirement", ibanPrefixes: ["NL", "DE"], description: "IBAN prefix required" };
197+
const result = ObjectSerializer.deserialize(raw, "TransferRouteRequirementsInner") as IbanAccountIdentificationRequirement;
198+
expect(result).toBeInstanceOf(IbanAccountIdentificationRequirement);
199+
expect(result.ibanPrefixes).toEqual(["NL", "DE"]);
200+
expect(result.type).toBe("ibanAccountIdentificationRequirement");
201+
});
202+
203+
it("should deserialize a paymentInstrumentRequirement payload into PaymentInstrumentRequirement", () => {
204+
const raw = { type: "paymentInstrumentRequirement", paymentInstrumentType: "BankAccount", issuingCountryCode: "NL" };
205+
const result = ObjectSerializer.deserialize(raw, "TransferRouteRequirementsInner") as PaymentInstrumentRequirement;
206+
expect(result).toBeInstanceOf(PaymentInstrumentRequirement);
207+
expect(result.paymentInstrumentType).toBe("BankAccount");
208+
expect(result.issuingCountryCode).toBe("NL");
209+
expect(result.type).toBe("paymentInstrumentRequirement");
210+
});
211+
212+
it("should round-trip an amountMinMaxRequirement payload through serialize then deserialize", () => {
213+
const raw = { type: "amountMinMaxRequirement", min: 500, max: 50000 };
214+
const instance = ObjectSerializer.deserialize(raw, "TransferRouteRequirementsInner") as AmountMinMaxRequirement;
215+
const serialized = ObjectSerializer.serialize(instance, "AmountMinMaxRequirement");
216+
const roundTripped = ObjectSerializer.deserialize(serialized, "TransferRouteRequirementsInner") as AmountMinMaxRequirement;
217+
expect(roundTripped).toBeInstanceOf(AmountMinMaxRequirement);
218+
expect(roundTripped.min).toBe(500);
219+
expect(roundTripped.max).toBe(50000);
220+
});
221+
});

0 commit comments

Comments
 (0)