Skip to content

Commit

Permalink
chore: add mock for index test
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyyconsensys committed Dec 3, 2024
1 parent 5dfcd42 commit a9273c0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/starknet-snap/src/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit a9273c0

Please sign in to comment.