Skip to content

Commit 57c8a45

Browse files
committed
rename messagingSystem in constructor to messenger and spyon messenger instance instead of prototype in tests
1 parent f2dc20d commit 57c8a45

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

app/scripts/controllers/mmi-controller.test.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ describe('MMIController', function () {
9191
accountsController,
9292
keyringController,
9393
metaMetricsController,
94-
custodyController;
94+
custodyController,
95+
mmiControllerMessenger;
9596

9697
beforeEach(async function () {
9798
const mockMessenger = {
@@ -239,7 +240,7 @@ describe('MMIController', function () {
239240
jest.fn().mockReturnValue(createMockNetworkConfiguration()),
240241
);
241242

242-
const mmiControllerMessenger = controllerMessenger.getRestricted({
243+
mmiControllerMessenger = controllerMessenger.getRestricted({
243244
name: 'MMIController',
244245
allowedActions: [
245246
'AccountsController:getAccountByAddress',
@@ -255,7 +256,7 @@ describe('MMIController', function () {
255256
});
256257

257258
mmiController = new MMIController({
258-
messagingSystem: mmiControllerMessenger,
259+
messenger: mmiControllerMessenger,
259260
mmiConfigurationController,
260261
keyringController,
261262
transactionUpdateController: new TransactionUpdateController({
@@ -539,7 +540,7 @@ describe('MMIController', function () {
539540
CUSTODIAN_TYPES['CUSTODIAN-TYPE'] = {
540541
keyringClass: { type: 'mock-keyring-class' },
541542
};
542-
jest.spyOn(ControllerMessenger.prototype, 'call').mockReturnValue({ address: '0x1' });
543+
jest.spyOn(mmiControllerMessenger, 'call').mockReturnValue({ address: '0x1' });
543544
mmiController.custodyController.getCustodyTypeByAddress = jest
544545
.fn()
545546
.mockReturnValue('custodian-type');
@@ -763,7 +764,7 @@ describe('MMIController', function () {
763764

764765
describe('handleMmiDashboardData', () => {
765766
it('should return internalAccounts as identities', async () => {
766-
const controllerMessengerSpy = jest.spyOn(ControllerMessenger.prototype, 'call');
767+
const controllerMessengerSpy = jest.spyOn(mmiControllerMessenger, 'call');
767768
await mmiController.handleMmiDashboardData();
768769

769770
expect(controllerMessengerSpy).toHaveBeenCalledWith(
@@ -841,7 +842,7 @@ describe('MMIController', function () {
841842

842843
describe('setAccountAndNetwork', () => {
843844
it('should set a new selected account if the selectedAddress and the address from the arguments is different', async () => {
844-
const selectedAccountSpy = jest.spyOn(ControllerMessenger.prototype, 'call');
845+
const selectedAccountSpy = jest.spyOn(mmiControllerMessenger, 'call');
845846
await mmiController.setAccountAndNetwork(
846847
'mock-origin',
847848
mockAccount2.address,
@@ -859,7 +860,7 @@ describe('MMIController', function () {
859860
});
860861

861862
it('should not set a new selected account the accounts are the same', async () => {
862-
const selectedAccountSpy = jest.spyOn(ControllerMessenger.prototype, 'call');
863+
const selectedAccountSpy = jest.spyOn(mmiControllerMessenger, 'call');
863864
await mmiController.setAccountAndNetwork(
864865
'mock-origin',
865866
mockAccount.address,

app/scripts/controllers/mmi-controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class MMIController {
132132

133133
constructor(opts: MMIControllerOptions) {
134134
this.opts = opts;
135-
this.messagingSystem = opts.messagingSystem;
135+
this.messagingSystem = opts.messenger;
136136
this.mmiConfigurationController = opts.mmiConfigurationController;
137137
this.keyringController = opts.keyringController;
138138
this.appStateController = opts.appStateController;

app/scripts/metamask-controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ export default class MetamaskController extends EventEmitter {
20252025
});
20262026

20272027
this.mmiController = new MMIController({
2028-
messagingSystem: mmiControllerMessenger,
2028+
messenger: mmiControllerMessenger,
20292029
mmiConfigurationController: this.mmiConfigurationController,
20302030
keyringController: this.keyringController,
20312031
appStateController: this.appStateController,

shared/constants/mmi-controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export type MMIControllerOptions = {
7070
appStateController: AppStateController;
7171
transactionUpdateController: TransactionUpdateController;
7272
custodyController: CustodyController;
73-
messagingSystem: MMIControllerMessenger;
73+
messenger: MMIControllerMessenger;
7474
// TODO: Replace `any` with type
7575
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7676
getState: () => any;

0 commit comments

Comments
 (0)