2022-09-14 16:55:31 +02:00
|
|
|
import { CHAIN_IDS, NETWORK_IDS } from '../../../shared/constants/network';
|
2021-03-16 22:00:08 +01:00
|
|
|
import txHelper from './tx-helper';
|
2017-07-17 23:16:39 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('txHelper', () => {
|
|
|
|
it('always shows the oldest tx first', () => {
|
2022-09-14 16:55:31 +02:00
|
|
|
const metamaskNetworkId = NETWORK_IDS.MAINNET;
|
|
|
|
const chainId = CHAIN_IDS.MAINNET;
|
2023-06-01 16:10:26 +02:00
|
|
|
const mockUnapprovedTxs = {
|
2017-07-17 23:16:39 +02:00
|
|
|
a: { metamaskNetworkId, time: 3 },
|
2023-06-01 16:10:26 +02:00
|
|
|
b: { metamaskNetworkId, time: 6 },
|
2017-07-17 23:16:39 +02:00
|
|
|
c: { metamaskNetworkId, time: 2 },
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-07-17 23:16:39 +02:00
|
|
|
|
2023-06-01 16:10:26 +02:00
|
|
|
const mockUnapprovedMsgs = {
|
|
|
|
d: { metamaskNetworkId, time: 4 },
|
|
|
|
e: { metamaskNetworkId, time: 1 },
|
|
|
|
f: { metamaskNetworkId, time: 5 },
|
|
|
|
};
|
|
|
|
|
2023-01-31 13:01:10 +01:00
|
|
|
const sorted = txHelper(
|
2023-06-01 16:10:26 +02:00
|
|
|
mockUnapprovedTxs,
|
|
|
|
mockUnapprovedMsgs,
|
2023-01-31 13:01:10 +01:00
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
metamaskNetworkId,
|
|
|
|
chainId,
|
|
|
|
);
|
2023-06-01 16:10:26 +02:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(sorted[0].time).toStrictEqual(1);
|
|
|
|
expect(sorted[2].time).toStrictEqual(3);
|
2023-06-01 16:10:26 +02:00
|
|
|
expect(sorted[5].time).toStrictEqual(6);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|