2021-02-04 19:15:23 +01:00
|
|
|
import { strict as assert } from 'assert';
|
2021-03-01 16:15:42 +01:00
|
|
|
import {
|
|
|
|
MAINNET_CHAIN_ID,
|
|
|
|
MAINNET_NETWORK_ID,
|
|
|
|
} from '../../../../../shared/constants/network';
|
2021-02-04 19:15:23 +01:00
|
|
|
import txHelper from '../../../../../ui/lib/tx-helper';
|
2017-07-17 23:16:39 +02:00
|
|
|
|
|
|
|
describe('txHelper', function () {
|
|
|
|
it('always shows the oldest tx first', function () {
|
2021-03-01 16:15:42 +01:00
|
|
|
const metamaskNetworkId = MAINNET_NETWORK_ID;
|
|
|
|
const chainId = MAINNET_CHAIN_ID;
|
2017-07-17 23:16:39 +02:00
|
|
|
const txs = {
|
|
|
|
a: { metamaskNetworkId, time: 3 },
|
|
|
|
b: { metamaskNetworkId, time: 1 },
|
|
|
|
c: { metamaskNetworkId, time: 2 },
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-07-17 23:16:39 +02:00
|
|
|
|
2021-03-01 16:15:42 +01:00
|
|
|
const sorted = txHelper(txs, null, null, metamaskNetworkId, chainId);
|
2021-02-04 19:15:23 +01:00
|
|
|
assert.equal(sorted[0].time, 1, 'oldest tx first');
|
|
|
|
assert.equal(sorted[2].time, 3, 'newest tx last');
|
|
|
|
});
|
|
|
|
});
|