mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
edf2cc41cb
* adds code fencing * MMI adds mmi-controller * MMI prettier * chore: create keyring builder for CustodyKeyrings * updates code fence to build-mmi * adds dependencies * fix import and prettier * lint * clean up * clean up * removes old methods and adds new * comment for now * adds two missing methods * runs yarn dedupe * adds missing import * bump target values * lavamoat policy update * bump values in coverage targets * prettier import order * coverage report update * clean up * yarn update * yarn dedupe * ran lavamoat:auto * adds zlib entry to storybook/main.js * adds browserify-zlib * clean up * clean up * prettier * prettier * eslint fix * fix paths * fix prettier * fix file name for mocha * adds to config * rename * adds file to configs * test lavamoat clean up * run dedupe * sets value in storybook main.js as false * runs lavamoat auto * updates mmi packages to lighter versions * updates mmi packages * lavamoat auto * adds finalized tx status * lavamoat auto * yarn dedupe * clean up * moving stuff into mmi controller * clean up * updates tresholds * yarn lock review * updates the mmi controller --------- Co-authored-by: Shane Terence Odlum <shane.odlum@consensys.net>
130 lines
4.1 KiB
JavaScript
130 lines
4.1 KiB
JavaScript
/* eslint-disable */
|
|
import { KeyringController } from '@metamask/eth-keyring-controller';
|
|
import { MmiConfigurationController } from '@metamask-institutional/custody-keyring';
|
|
import { TransactionUpdateController } from '@metamask-institutional/transaction-update';
|
|
|
|
import MMIController from './mmi-controller';
|
|
import TransactionController from './transactions';
|
|
import PreferencesController from './preferences';
|
|
import AppStateController from './app-state';
|
|
|
|
describe('MMIController', function () {
|
|
let mmiController;
|
|
|
|
beforeEach(function () {
|
|
mmiController = new MMIController({
|
|
mmiConfigurationController: new MmiConfigurationController(),
|
|
keyringController: new KeyringController({
|
|
initState: {},
|
|
}),
|
|
transactionUpdateController: new TransactionUpdateController({
|
|
getCustodyKeyring: jest.fn(),
|
|
}),
|
|
txController: new TransactionController({
|
|
initState: {},
|
|
provider: {
|
|
chainId: 'fail',
|
|
nickname: '',
|
|
rpcTarget: 'https://api.myetherwallet.com/eth',
|
|
ticker: 'ETH',
|
|
type: 'rinkeby',
|
|
},
|
|
getCurrentChainId: jest.fn(),
|
|
getNetworkId: jest.fn(),
|
|
onNetworkStateChange: jest.fn(),
|
|
}),
|
|
preferencesController: new PreferencesController({
|
|
initState: {},
|
|
onInfuraIsBlocked: jest.fn(),
|
|
onInfuraIsUnblocked: jest.fn(),
|
|
provider: {},
|
|
}),
|
|
appStateController: new AppStateController({
|
|
addUnlockListener: jest.fn(),
|
|
isUnlocked: jest.fn(() => true),
|
|
initState: {},
|
|
onInactiveTimeout: jest.fn(),
|
|
showUnlockRequest: jest.fn(),
|
|
preferencesStore: {
|
|
subscribe: jest.fn(),
|
|
getState: jest.fn(() => ({
|
|
preferences: {
|
|
autoLockTimeLimit: 0,
|
|
},
|
|
})),
|
|
},
|
|
qrHardwareStore: {
|
|
subscribe: jest.fn(),
|
|
},
|
|
messenger: {
|
|
call: jest.fn(() => ({
|
|
catch: jest.fn(),
|
|
})),
|
|
},
|
|
}),
|
|
custodianEventHandlerFactory: jest.fn(),
|
|
});
|
|
});
|
|
|
|
describe('mmiController constructor', function () {
|
|
it('should instantiate correctly', function () {
|
|
expect(mmiController).toBeInstanceOf(MMIController);
|
|
});
|
|
|
|
it('should have all required properties', function () {
|
|
expect(mmiController.opts).toBeDefined();
|
|
expect(mmiController.mmiConfigurationController).toBeDefined();
|
|
expect(mmiController.preferencesController).toBeDefined();
|
|
expect(mmiController.transactionUpdateController).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('persistKeyringsAfterRefreshTokenChange', function () {
|
|
it('should call keyringController.persistAllKeyrings', async function () {
|
|
mmiController.keyringController.persistAllKeyrings = jest.fn();
|
|
|
|
await mmiController.persistKeyringsAfterRefreshTokenChange();
|
|
|
|
expect(
|
|
mmiController.keyringController.persistAllKeyrings,
|
|
).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('trackTransactionEventFromCustodianEvent', function () {
|
|
it('should call txController._trackTransactionMetricsEvent', function () {
|
|
const txMeta = {};
|
|
const event = 'event';
|
|
mmiController.txController._trackTransactionMetricsEvent = jest.fn();
|
|
|
|
mmiController.trackTransactionEventFromCustodianEvent(txMeta, event);
|
|
|
|
expect(
|
|
mmiController.txController._trackTransactionMetricsEvent,
|
|
).toHaveBeenCalledWith(txMeta, event);
|
|
});
|
|
});
|
|
|
|
describe('custodianEventHandlerFactory', function () {
|
|
it('should call custodianEventHandlerFactory', async function () {
|
|
mmiController.custodianEventHandlerFactory = jest.fn();
|
|
|
|
mmiController.custodianEventHandlerFactory();
|
|
|
|
expect(mmiController.custodianEventHandlerFactory).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('storeCustodianSupportedChains', function () {
|
|
it('should call storeCustodianSupportedChains', async function () {
|
|
mmiController.storeCustodianSupportedChains = jest.fn();
|
|
|
|
mmiController.storeCustodianSupportedChains('0x1');
|
|
|
|
expect(mmiController.storeCustodianSupportedChains).toHaveBeenCalledWith(
|
|
'0x1',
|
|
);
|
|
});
|
|
});
|
|
});
|