Skip to content

Commit 035e985

Browse files
committed
Add unit test for preinstalled snap
1 parent 1325997 commit 035e985

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

packages/snaps-controllers/src/snaps/SnapController.test.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9568,6 +9568,45 @@ describe('SnapController', () => {
95689568
);
95699569
snapController.destroy();
95709570
});
9571+
9572+
it('should not track event for preinstalled snap', async () => {
9573+
const mockTrackEvent = jest.fn();
9574+
const rootMessenger = getControllerMessenger();
9575+
const executionEnvironmentStub = new ExecutionEnvironmentStub(
9576+
getNodeEESMessenger(rootMessenger),
9577+
) as unknown as NodeThreadExecutionService;
9578+
9579+
const [snapController] = getSnapControllerWithEES(
9580+
getSnapControllerWithEESOptions({
9581+
rootMessenger,
9582+
trackEvent: mockTrackEvent,
9583+
state: {
9584+
snaps: getPersistedSnapsState(
9585+
getPersistedSnapObject({ preinstalled: true }),
9586+
),
9587+
},
9588+
}),
9589+
executionEnvironmentStub,
9590+
);
9591+
9592+
const snap = snapController.getExpect(MOCK_SNAP_ID);
9593+
await snapController.startSnap(snap.id);
9594+
9595+
await snapController.handleRequest({
9596+
snapId: snap.id,
9597+
origin: MOCK_ORIGIN,
9598+
handler: HandlerType.OnRpcRequest,
9599+
request: {
9600+
jsonrpc: '2.0',
9601+
method: 'test',
9602+
params: {},
9603+
id: 1,
9604+
},
9605+
});
9606+
9607+
expect(mockTrackEvent).not.toHaveBeenCalled();
9608+
snapController.destroy();
9609+
});
95719610
});
95729611

95739612
it('handles a transaction insight request', async () => {

0 commit comments

Comments
 (0)