1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 12:47:14 +01:00
metamask-extension/test/unit/actions/tx.test.js
Thomas Huang 3ba91df387
Unifies unit tests filename suffix to .test.js (#10607)
* Unifies the filename suffix to .test.js

* Display @babel/no-invalid-this rule for tx-controller.test.js

* Add test file extension to test:unit:global
2021-03-09 11:08:06 -08:00

55 lines
1.5 KiB
JavaScript

import assert from 'assert';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import * as actions from '../../../ui/app/store/actions';
import * as actionConstants from '../../../ui/app/store/actionConstants';
import { ROPSTEN_CHAIN_ID } from '../../../shared/constants/network';
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
describe('tx confirmation screen', function () {
const txId = 1457634084250832;
const initialState = {
appState: {},
metamask: {
unapprovedTxs: {
[txId]: {
id: txId,
status: 'unconfirmed',
time: 1457634084250,
},
},
provider: {
chainId: ROPSTEN_CHAIN_ID,
},
},
};
const store = mockStore(initialState);
describe('cancelTx', function () {
it('creates COMPLETED_TX with the cancelled transaction ID', async function () {
actions._setBackgroundConnection({
approveTransaction(_, cb) {
cb(new Error('An error!'));
},
cancelTransaction(_, cb) {
cb();
},
getState(cb) {
cb(null, {});
},
});
await store.dispatch(actions.cancelTx({ id: txId }));
const storeActions = store.getActions();
const completedTxAction = storeActions.find(
({ type }) => type === actionConstants.COMPLETED_TX,
);
const { id } = completedTxAction.value;
assert.equal(id, txId);
});
});
});