-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathaddress-based.test.ts
More file actions
52 lines (51 loc) · 2.15 KB
/
address-based.test.ts
File metadata and controls
52 lines (51 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { UnsupportedCurrencyError } from '@requestnetwork/currency';
import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import AddressBasedPaymentNetwork from '../../../src/extensions/payment-network/address-based';
describe('extensions/payment-network/address-based', () => {
it('address validation should throw when using unsupported currency type', () => {
class TestAddressBasedPaymentNetwork extends AddressBasedPaymentNetwork {
public constructor(
extensionId: ExtensionTypes.PAYMENT_NETWORK_ID,
currentVersion: string,
supportedCurrencyType: RequestLogicTypes.CURRENCY,
) {
super(extensionId, currentVersion, supportedCurrencyType);
}
public testIsValidAddress() {
this.isValidAddress('test');
}
}
expect(() => {
const testAddressBasedPaymentNetwork = new TestAddressBasedPaymentNetwork(
ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_ADDRESS_BASED,
'test',
RequestLogicTypes.CURRENCY.ISO4217,
);
testAddressBasedPaymentNetwork.testIsValidAddress();
}).toThrowError(
'Default implementation of isValidAddressForNetwork() does not support currency type ISO4217. Please override this method if needed.',
);
});
it('address validation should throw when using unsupported currency', () => {
class TestAddressBasedPaymentNetwork extends AddressBasedPaymentNetwork {
public constructor(
extensionId: ExtensionTypes.PAYMENT_NETWORK_ID,
currentVersion: string,
supportedCurrencyType: RequestLogicTypes.CURRENCY,
) {
super(extensionId, currentVersion, supportedCurrencyType);
}
public testIsValidAddress() {
this.isValidAddressForSymbolAndNetwork('test', 'test', 'mainnet');
}
}
expect(() => {
const testAddressBasedPaymentNetwork = new TestAddressBasedPaymentNetwork(
ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_ADDRESS_BASED,
'test',
RequestLogicTypes.CURRENCY.ERC20,
);
testAddressBasedPaymentNetwork.testIsValidAddress();
}).toThrowError(new UnsupportedCurrencyError({ value: 'test', network: 'mainnet' }));
});
});