Skip to content

Commit e208c80

Browse files
committed
spec style fixes
1 parent 9dcf2b8 commit e208c80

File tree

7 files changed

+68
-35
lines changed

7 files changed

+68
-35
lines changed

test/integration/BalanceSpec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
import { startNockRec, testingApiClient } from "./helpers/integrationTestsHelpers";
22
import * as assert from "assert";
3+
import { Balance } from "../../lib";
34

45
describe("Balance", () => {
56
it("lists all balances", async () => {
67
const nockDone = await startNockRec('balance-all.json');
78

89
const balances = await testingApiClient.balances.all();
910

10-
assert.ok(balances);
11-
assert.strictEqual(1, balances.length);
12-
assert.strictEqual("paymentrails", balances[0].type);
13-
1411
nockDone();
12+
13+
assert.ok(balances);
14+
assert.strictEqual(balances.length, 1);
15+
assert.strictEqual(balances[0].constructor, Balance);
16+
assert.strictEqual(balances[0].type, "paymentrails");
1517
});
1618

1719
it("lists balances for a given kind", async () => {
1820
const nockDone = await startNockRec('balance-find.json');
1921

2022
const balances = await testingApiClient.balances.find("paymentrails");
2123

22-
assert.ok(balances);
23-
assert.strictEqual(1, balances.length);
24-
assert.strictEqual("paymentrails", balances[0].type);
25-
2624
nockDone();
25+
26+
assert.ok(balances);
27+
assert.strictEqual(balances.length, 1);
28+
assert.strictEqual(balances[0].constructor, Balance);
29+
assert.strictEqual(balances[0].type, "paymentrails");
2730
});
2831
});

test/integration/InvoiceLineSpec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { RecipientFactory } from './factories/RecipientFactory';
33
import { InvoiceFactory } from './factories/InvoiceFactory';
44
import { InvoiceLineFactory } from './factories/InvoiceLineFactory';
55
import * as assert from 'assert';
6+
import { InvoiceLine } from "../../lib/InvoiceLine";
67

78
let recipientFactory: RecipientFactory;
89
let invoiceFactory: InvoiceFactory;
@@ -26,6 +27,7 @@ describe('InvoiceLine', () => {
2627

2728
assert.ok(invoiceLines);
2829
assert.strictEqual(invoiceLines.length, 1);
30+
assert.strictEqual(invoiceLines[0].constructor, InvoiceLine);
2931
assert.strictEqual('testInvoiceLine', invoiceLines[0].externalId);
3032
});
3133

@@ -51,6 +53,9 @@ describe('InvoiceLine', () => {
5153
nockDone();
5254

5355
assert.ok(updatedInvoice);
56+
assert.strictEqual(invoiceLines.length, 1);
57+
assert.strictEqual(invoiceLines[0].constructor, InvoiceLine);
58+
assert.strictEqual(updatedInvoice.lines.length, 1);
5459
assert.strictEqual('updated line description', updatedInvoice.lines[0].description);
5560
});
5661

test/integration/InvoiceSpec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe("Invoice", () => {
2424
nockDone();
2525

2626
assert.ok(invoice);
27+
assert.strictEqual(invoice.constructor, Invoice);
2728
assert.strictEqual("testInvoice", invoice.externalId);
2829
assert.strictEqual(recipient.id, invoice.recipientId);
2930
});
@@ -53,6 +54,7 @@ describe("Invoice", () => {
5354
nockDone();
5455

5556
assert.ok(invoice);
57+
assert.strictEqual(invoice.constructor, Invoice);
5658
assert.strictEqual("testInvoice", invoice.externalId);
5759
assert.strictEqual(recipient.id, invoice.recipientId);
5860
assert.strictEqual(1, invoice.lines.length);
@@ -73,6 +75,7 @@ describe("Invoice", () => {
7375
nockDone();
7476

7577
assert.ok(findInvoice);
78+
assert.strictEqual(findInvoice.constructor, Invoice);
7679
assert.strictEqual("testInvoice", findInvoice.externalId);
7780
});
7881

@@ -96,7 +99,9 @@ describe("Invoice", () => {
9699
nockDone();
97100

98101
assert.ok(invoices);
99-
assert.strictEqual(2, invoices.length);
102+
assert.strictEqual(invoices.length, 2);
103+
assert.strictEqual(invoices[0].constructor, Invoice);
104+
assert.strictEqual(invoices[1].constructor, Invoice);
100105
assert.strictEqual([invoice.id, otherInvoice.id].sort().toString(), invoices.map(i => i.id).sort().toString());
101106
});
102107

@@ -119,6 +124,7 @@ describe("Invoice", () => {
119124
nockDone();
120125

121126
assert.ok(invoice);
127+
assert.strictEqual(invoice.constructor, Invoice);
122128
assert.strictEqual("Updated description", updatedInvoice.description);
123129
});
124130

test/integration/OfflinePaymentSpec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { startNockRec, testingApiClient } from "./helpers/integrationTestsHelper
22
import { RecipientFactory } from "./factories/RecipientFactory";
33
import * as assert from "assert";
44
import { OfflinePaymentFactory } from "./factories/OfflinePaymentFactory";
5+
import { OfflinePayment } from "../../lib";
56

67
let recipientFactory: RecipientFactory;
78
let offlinePaymentFactory: OfflinePaymentFactory;
@@ -21,7 +22,8 @@ describe('OfflinePayment', () => {
2122
nockDone();
2223

2324
assert.ok(offlinePayment);
24-
assert.strictEqual('testOfflinePayment', offlinePayment.externalId);
25+
assert.strictEqual(offlinePayment.constructor, OfflinePayment);
26+
assert.strictEqual(offlinePayment.externalId, 'testOfflinePayment');
2527
});
2628

2729
it('updates an offline payment', async () => {
@@ -44,6 +46,7 @@ describe('OfflinePayment', () => {
4446
nockDone();
4547

4648
assert.ok(offlinePayment);
49+
assert.strictEqual(offlinePayment.constructor, OfflinePayment);
4750
assert.strictEqual(true, offlinePayment.taxReportable);
4851
});
4952

@@ -86,5 +89,7 @@ describe('OfflinePayment', () => {
8689

8790
assert.ok(offlinePaymentResults);
8891
assert.strictEqual(2, offlinePaymentResults.length);
92+
assert.strictEqual(offlinePaymentResults[0].constructor, OfflinePayment);
93+
assert.strictEqual(offlinePaymentResults[1].constructor, OfflinePayment);
8994
});
9095
});

test/integration/PaymentSpec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { PaymentFactory } from "./factories/PaymentFactory";
33
import { BatchFactory } from "./factories/BatchFactory";
44
import { RecipientFactory } from "./factories/RecipientFactory";
55
import * as assert from "assert";
6+
import { Payment } from "../../lib";
67

78
let batchFactory: BatchFactory;
89
let recipientFactory: RecipientFactory;
@@ -36,7 +37,8 @@ describe('Payment', () => {
3637
nockDone();
3738

3839
assert.ok(payment);
39-
assert.strictEqual('testPayment', payment.externalId);
40+
assert.strictEqual(payment.constructor, Payment);
41+
assert.strictEqual(payment.externalId, 'testPayment');
4042
});
4143

4244
it('updates a payment', async () => {
@@ -68,6 +70,7 @@ describe('Payment', () => {
6870
nockDone();
6971

7072
assert.ok(updatedPayment);
73+
assert.strictEqual(updatedPayment.constructor, Payment);
7174
assert.strictEqual('updatedPayment', updatedPayment.externalId);
7275
});
7376

@@ -115,12 +118,13 @@ describe('Payment', () => {
115118
);
116119

117120
const query = { recipientId: recipient.id, batchId: batch.id };
118-
const searchResult = await testingApiClient.payment.search(query);
121+
const paymentsCollection = await testingApiClient.payment.search(query);
119122

120123
nockDone();
121124

122-
assert.ok(searchResult);
123-
assert.strictEqual(1, searchResult.length);
124-
assert.strictEqual(payment.externalId, searchResult[0].externalId);
125+
assert.ok(paymentsCollection);
126+
assert.strictEqual(1, paymentsCollection.length);
127+
assert.strictEqual(paymentsCollection[0].constructor, Payment);
128+
assert.strictEqual(payment.externalId, paymentsCollection[0].externalId);
125129
});
126130
});

test/integration/RecipientAccountSpec.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as assert from "assert";
22
import { startNockRec, testingApiClient } from "./helpers/integrationTestsHelpers";
33
import { RecipientFactory } from "./factories/RecipientFactory";
44
import { RecipientAccountFactory } from "./factories/RecipientAccountFactory";
5+
import {RecipientAccount} from "../../lib";
56

67
let recipientFactory: RecipientFactory;
78
let recipientAccountFactory: RecipientAccountFactory;
@@ -33,7 +34,7 @@ describe("RecipientAccount", () => {
3334

3435
const primaryAccount = await testingApiClient.recipientAccount.find(recipient.id, account.id);
3536
const accountList = await testingApiClient.recipientAccount.all(recipient.id);
36-
const result = await testingApiClient.recipientAccount.remove(recipient.id, account.id);
37+
const deleteResult = await testingApiClient.recipientAccount.remove(recipient.id, account.id);
3738
const accountList2 = await testingApiClient.recipientAccount.all(recipient.id);
3839

3940
nockDone();
@@ -43,12 +44,18 @@ describe("RecipientAccount", () => {
4344
assert.ok(account2);
4445
assert.ok(account2.primary);
4546

47+
assert.strictEqual(account.constructor, RecipientAccount);
48+
assert.strictEqual(account2.constructor, RecipientAccount);
4649
assert.strictEqual(account.iban, primaryAccount.iban);
4750

4851
assert.strictEqual(accountList.length, 2);
49-
assert.strictEqual(accountList[0].currency, "EUR");
52+
assert.strictEqual(accountList[0].constructor, RecipientAccount);
53+
assert.strictEqual(accountList[1].constructor, RecipientAccount);
5054

51-
assert.strictEqual(true, result);
55+
assert.strictEqual(accountList2.length, 1);
56+
assert.strictEqual(accountList2[0].id, account2.id);
57+
58+
assert.strictEqual(true, deleteResult);
5259

5360
assert.strictEqual(accountList2.length, 1);
5461
assert.ok(accountList2[0].primary);
@@ -58,30 +65,31 @@ describe("RecipientAccount", () => {
5865
const nockDone = await startNockRec('recipient-account-update.json');
5966

6067
const recipient = await recipientFactory.createResource();
61-
const dummyIban = "DE89 3704 0044 0532 0130 00";
68+
const iban = "DE89 3704 0044 0532 0130 00";
6269
const account = await recipientAccountFactory.createResource({
6370
recipient: { id: recipient.id },
6471
type: "bank-transfer",
6572
currency: "EUR",
66-
iban: dummyIban,
73+
iban: iban,
6774
});
68-
const otherDummyIban = "DE91 1000 0000 0123 4567 89";
69-
const account2 = await testingApiClient.recipientAccount.update(recipient.id, account.id, {
70-
iban: otherDummyIban,
75+
const otherIban = "DE91 1000 0000 0123 4567 89";
76+
const updatedAccount = await testingApiClient.recipientAccount.update(recipient.id, account.id, {
77+
iban: otherIban,
7178
});
7279

7380
const accountList = await testingApiClient.recipientAccount.all(recipient.id);
7481

7582
nockDone();
7683

7784
assert.ok(account);
78-
assert.ok(account2);
79-
assert.strictEqual(account.id, account2.id);
80-
assert.ok(account2.iban && account2.iban.includes("**89"));
85+
assert.ok(updatedAccount);
86+
assert.strictEqual(account.constructor, RecipientAccount);
87+
assert.strictEqual(updatedAccount.constructor, RecipientAccount);
88+
assert.ok(updatedAccount.iban && updatedAccount.iban.includes("**89"));
8189

8290
assert.ok((accountList as any)[0].iban.includes("**89"));
8391
assert.strictEqual(accountList.length, 1);
84-
assert.strictEqual(accountList[0].id, account2.id);
92+
assert.strictEqual(accountList[0].id, updatedAccount.id);
8593
});
8694

8795
it("deletes account", async () => {

test/integration/RecipientSpec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe("Recipient", () => {
1616
const recipient = await recipientFactory.createResource();
1717

1818
assert.ok(recipient);
19+
assert.strictEqual(recipient.constructor, Recipient);
1920
assert.strictEqual("Tom", recipientFactory.defaultAttrs.firstName);
2021
assert.strictEqual("Jones", recipientFactory.defaultAttrs.lastName);
2122
assert.ok(recipient.id);
@@ -27,16 +28,17 @@ describe("Recipient", () => {
2728
const nockDone = await startNockRec('recipient-update.json');
2829

2930
const recipient = await recipientFactory.createResource();
30-
const updated = await testingApiClient.recipient.update(recipient.id, {
31+
const updatedRecipient = await testingApiClient.recipient.update(recipient.id, {
3132
firstName: "John",
3233
lastName: "Smith",
3334
});
3435

3536
nockDone();
3637

37-
assert.ok(updated);
38-
assert.strictEqual("John", updated.firstName);
39-
assert.strictEqual("Smith", updated.lastName);
38+
assert.ok(updatedRecipient);
39+
assert.strictEqual(updatedRecipient.constructor, Recipient);
40+
assert.strictEqual("John", updatedRecipient.firstName);
41+
assert.strictEqual("Smith", updatedRecipient.lastName);
4042
});
4143

4244
it("deletes a recipient", async () => {
@@ -54,12 +56,12 @@ describe("Recipient", () => {
5456
const nockDone = await startNockRec('recipient-search.json');
5557

5658
const recipient = await recipientFactory.createResource();
57-
const recipients = await testingApiClient.recipient.search();
59+
const recipientsCollection: Recipient[] = await testingApiClient.recipient.search();
5860

5961
nockDone();
6062

61-
assert.ok(recipients);
62-
assert.strictEqual(1, recipients.length);
63-
assert.strictEqual(recipient.id, recipients[0].id);
63+
assert.ok(recipientsCollection);
64+
assert.strictEqual(1, recipientsCollection.length);
65+
assert.strictEqual(recipient.id, recipientsCollection[0].id);
6466
});
6567
});

0 commit comments

Comments
 (0)