Skip to content

Commit

Permalink
test: add actions, events, callbacks to test messenger
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorLift committed Jan 26, 2024
1 parent 6ba98de commit a590dcc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/assets-controllers/src/TokenDetectionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ function buildTokenDetectionControllerMessenger(
return controllerMessenger.getRestricted({
name: controllerName,
allowedActions: [
'KeyringController:getState',
'NetworkController:getNetworkConfigurationByNetworkClientId',
'TokenListController:getState',
],
allowedEvents: [
'AccountsController:selectedAccountChange',
'KeyringController:lock',
'KeyringController:unlock',
'NetworkController:stateChange',
'NetworkController:networkDidChange',
'TokenListController:stateChange',
Expand Down Expand Up @@ -1297,6 +1301,12 @@ async function withController<ReturnValue>(
.mockImplementation((networkClientId: string) => {
return mockNetworkConfigurations[networkClientId];
});
controllerMessenger.registerActionHandler(
'KeyringController:getState',
jest.fn().mockReturnValue({
isActive: true,
}),
);
controllerMessenger.registerActionHandler(
'NetworkController:getNetworkConfigurationByNetworkClientId',
mockGetNetworkConfigurationByNetworkClientId,
Expand All @@ -1323,6 +1333,7 @@ async function withController<ReturnValue>(
...getDefaultPreferencesState(),
useTokenDetection: true,
}),
trackMetaMetricsEvent: jest.fn(),
messenger: buildTokenDetectionControllerMessenger(controllerMessenger),
...options,
});
Expand Down

0 comments on commit a590dcc

Please sign in to comment.