Skip to content

Commit 83d7475

Browse files
committed
s/toThrowError/toThrow
jest v30 breaking change removes toThrowError alias
1 parent adb4fa0 commit 83d7475

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

src/request/credit-card.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ describe('CreditCard()', () => {
2424
'throws an error if $condition',
2525
({ field, val }: { field: string; val: string }) => {
2626
const creditCard = () => new CreditCard({ [field]: val });
27-
expect(creditCard).toThrowError(ArgumentError);
27+
expect(creditCard).toThrow(ArgumentError);
2828
// Ensure that the `ArgumentError` message contains text of a given field
29-
expect(creditCard).toThrowError(field);
29+
expect(creditCard).toThrow(field);
3030
}
3131
);
3232

src/request/device.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ describe('Device()', () => {
77
new Device({
88
ipAddress: 'foo',
99
});
10-
expect(device).toThrowError(ArgumentError);
11-
expect(device).toThrowError('device.ipAddress');
10+
expect(device).toThrow(ArgumentError);
11+
expect(device).toThrow('device.ipAddress');
1212
});
1313

1414
it('constructs', () => {

src/request/email.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,35 @@ describe('Email()', () => {
88
new Email({
99
address: '123',
1010
});
11-
expect(email).toThrowError(ArgumentError);
12-
expect(email).toThrowError('email.address');
11+
expect(email).toThrow(ArgumentError);
12+
expect(email).toThrow('email.address');
1313
});
1414

1515
it('email.address with trailing period is not valid', () => {
1616
const email = () =>
1717
new Email({
1818
address: '[email protected].',
1919
});
20-
expect(email).toThrowError(ArgumentError);
21-
expect(email).toThrowError('email.address');
20+
expect(email).toThrow(ArgumentError);
21+
expect(email).toThrow('email.address');
2222
});
2323

2424
it('email.address with multiple trailing periods is not valid', () => {
2525
const email = () =>
2626
new Email({
2727
address: '[email protected]...',
2828
});
29-
expect(email).toThrowError(ArgumentError);
30-
expect(email).toThrowError('email.address');
29+
expect(email).toThrow(ArgumentError);
30+
expect(email).toThrow('email.address');
3131
});
3232

3333
it('throws an error if email.domain is not valid', () => {
3434
const email = () =>
3535
new Email({
3636
domain: '123',
3737
});
38-
expect(email).toThrowError(ArgumentError);
39-
expect(email).toThrowError('email.domain');
38+
expect(email).toThrow(ArgumentError);
39+
expect(email).toThrow('email.domain');
4040
});
4141

4242
it('constructs', () => {

src/request/location.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ describe('Location()', () => {
88
country: 'foo',
99
});
1010

11-
expect(location).toThrowError(ArgumentError);
12-
expect(location).toThrowError('country code');
11+
expect(location).toThrow(ArgumentError);
12+
expect(location).toThrow('country code');
1313
});
1414

1515
it('constructs', () => {

src/request/order.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ describe('Order()', () => {
88
new Order({
99
currency: 'foo',
1010
});
11-
expect(order).toThrowError(ArgumentError);
12-
expect(order).toThrowError('currency code');
11+
expect(order).toThrow(ArgumentError);
12+
expect(order).toThrow('currency code');
1313
});
1414

1515
it('throws an error if referrer URI is not valid', () => {
@@ -19,8 +19,8 @@ describe('Order()', () => {
1919
// @ts-ignore
2020
referrerUri: 'foo',
2121
});
22-
expect(order).toThrowError(ArgumentError);
23-
expect(order).toThrowError('referrer URI');
22+
expect(order).toThrow(ArgumentError);
23+
expect(order).toThrow('referrer URI');
2424
});
2525

2626
it('constructs', () => {

src/request/shopping-cart-item.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ describe('ShoppingCartItem()', () => {
77
new ShoppingCartItem({
88
quantity: 123.12,
99
});
10-
expect(item).toThrowError(ArgumentError);
11-
expect(item).toThrowError('positive integer');
10+
expect(item).toThrow(ArgumentError);
11+
expect(item).toThrow('positive integer');
1212
});
1313

1414
it('throws an error if quantity is not a positive integer', () => {
1515
const item = () =>
1616
new ShoppingCartItem({
1717
quantity: -1,
1818
});
19-
expect(item).toThrowError(ArgumentError);
20-
expect(item).toThrowError('positive integer');
19+
expect(item).toThrow(ArgumentError);
20+
expect(item).toThrow('positive integer');
2121
});
2222

2323
it('constructs', () => {

src/request/transaction-report.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ describe('Device()', () => {
99
ipAddress: 'foo',
1010
tag: Tag.CHARGEBACK,
1111
});
12-
expect(report).toThrowError(ArgumentError);
13-
expect(report).toThrowError('transactionReport.ipAddress');
12+
expect(report).toThrow(ArgumentError);
13+
expect(report).toThrow('transactionReport.ipAddress');
1414
});
1515

1616
it('throws an error if TransactionReport.tag is not valid', () => {
@@ -21,8 +21,8 @@ describe('Device()', () => {
2121
// @ts-ignore
2222
tag: 'foobar',
2323
});
24-
expect(report).toThrowError(ArgumentError);
25-
expect(report).toThrowError('transactionReport.tag');
24+
expect(report).toThrow(ArgumentError);
25+
expect(report).toThrow('transactionReport.tag');
2626
});
2727

2828
it('constructs with ipAddress', () => {

src/request/transaction.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ describe('Transaction()', () => {
3232
ipAddress: '123',
3333
},
3434
});
35-
expect(test).toThrowError(ArgumentError);
36-
expect(test).toThrowError('instance of Device');
35+
expect(test).toThrow(ArgumentError);
36+
expect(test).toThrow('instance of Device');
3737
});
3838

3939
test.each`
@@ -54,8 +54,8 @@ describe('Transaction()', () => {
5454
val
5555
);
5656
const test = () => new Transaction(txn);
57-
expect(test).toThrowError(ArgumentError);
58-
expect(test).toThrowError(clss);
57+
expect(test).toThrow(ArgumentError);
58+
expect(test).toThrow(clss);
5959
}
6060
);
6161

0 commit comments

Comments
 (0)