From a9273c03030db0349873158d85034be541f9297f Mon Sep 17 00:00:00 2001 From: stanleyyuen <102275989+stanleyyconsensys@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:41:53 +0800 Subject: [PATCH] chore: add mock for index test --- packages/starknet-snap/src/index.test.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/starknet-snap/src/index.test.tsx b/packages/starknet-snap/src/index.test.tsx index 2426ddf5..da3181cb 100644 --- a/packages/starknet-snap/src/index.test.tsx +++ b/packages/starknet-snap/src/index.test.tsx @@ -4,6 +4,7 @@ import { onHomePage, onRpcRequest } from '.'; import * as createAccountApi from './createAccount'; import { HomePageController } from './on-home-page'; import * as keyPairUtils from './utils/keyPair'; +import * as permissionUtil from './utils/permission'; jest.mock('./utils/logger'); @@ -41,7 +42,11 @@ describe('onRpcRequest', () => { expect(createAccountSpy).toHaveBeenCalledTimes(1); }); + // It is a never case, as the permission of each method is checked in the `validateOrigin` function. + // But to increase the coverage, we keep this test case. it('throws `MethodNotFoundError` if the request method not found', async () => { + jest.spyOn(permissionUtil, 'validateOrigin').mockReturnThis(); + await expect( onRpcRequest({ ...createMockRequest(),