You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
4 years ago
|
import {
|
||
4 years ago
|
TRANSACTION_TYPES,
|
||
4 years ago
|
TRANSACTION_GROUP_STATUSES,
|
||
|
TRANSACTION_STATUSES,
|
||
4 years ago
|
} from '../../../shared/constants/transaction';
|
||
4 years ago
|
import * as utils from './transactions.util';
|
||
6 years ago
|
|
||
4 years ago
|
describe('Transactions utils', () => {
|
||
|
describe('getTokenData', () => {
|
||
|
it('should return token data', () => {
|
||
4 years ago
|
const tokenData = utils.getTokenData(
|
||
|
'0xa9059cbb00000000000000000000000050a9d56c2b8ba9a5c7f2c08c3d26e0499f23a7060000000000000000000000000000000000000000000000000000000000004e20',
|
||
4 years ago
|
);
|
||
4 years ago
|
expect(tokenData).toStrictEqual(expect.anything());
|
||
4 years ago
|
const { name, args } = tokenData;
|
||
4 years ago
|
expect(name).toStrictEqual(TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER);
|
||
4 years ago
|
const to = args._to;
|
||
|
const value = args._value.toString();
|
||
4 years ago
|
expect(to).toStrictEqual('0x50A9D56C2B8BA9A5c7f2C08C3d26E0499F23a706');
|
||
|
expect(value).toStrictEqual('20000');
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should not throw errors when called without arguments', () => {
|
||
|
expect(() => utils.getTokenData()).not.toThrow();
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
describe('getStatusKey', () => {
|
||
|
it('should return the correct status', () => {
|
||
6 years ago
|
const tests = [
|
||
|
{
|
||
|
transaction: {
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
6 years ago
|
txReceipt: {
|
||
|
status: '0x0',
|
||
|
},
|
||
|
},
|
||
4 years ago
|
expected: TRANSACTION_STATUSES.FAILED,
|
||
6 years ago
|
},
|
||
|
{
|
||
|
transaction: {
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
6 years ago
|
txReceipt: {
|
||
|
status: '0x1',
|
||
|
},
|
||
|
},
|
||
4 years ago
|
expected: TRANSACTION_STATUSES.CONFIRMED,
|
||
6 years ago
|
},
|
||
|
{
|
||
|
transaction: {
|
||
4 years ago
|
status: TRANSACTION_GROUP_STATUSES.PENDING,
|
||
6 years ago
|
},
|
||
4 years ago
|
expected: TRANSACTION_GROUP_STATUSES.PENDING,
|
||
6 years ago
|
},
|
||
4 years ago
|
];
|
||
6 years ago
|
|
||
|
tests.forEach(({ transaction, expected }) => {
|
||
4 years ago
|
expect(utils.getStatusKey(transaction)).toStrictEqual(expected);
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|