Skip to content

Commit

Permalink
fix: test suits
Browse files Browse the repository at this point in the history
  • Loading branch information
khanti42 committed Nov 20, 2024
1 parent 9f03456 commit c66d1ac
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions packages/starknet-snap/src/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { text, MethodNotFoundError, SnapError } from '@metamask/snaps-sdk';
import { onHomePage, onRpcRequest } from '.';
import * as createAccountApi from './createAccount';
import { HomePageController } from './on-home-page';
import { InitSnapStateManager } from './state/init-snap-state-manager';
import * as keyPairUtils from './utils/keyPair';

jest.mock('./utils/logger');
Expand All @@ -16,15 +15,9 @@ jest.mock('./utils', () => ({

describe('onRpcRequest', () => {
const createMockSpy = () => {
const requireMetaMaskUpgradeSpy = jest.spyOn(
InitSnapStateManager.prototype,
'requireMetaMaskUpgrade',
);
requireMetaMaskUpgradeSpy.mockResolvedValue(false);
const createAccountSpy = jest.spyOn(createAccountApi, 'createAccount');
const keyPairSpy = jest.spyOn(keyPairUtils, 'getAddressKeyDeriver');
return {
requireMetaMaskUpgradeSpy,
createAccountSpy,
keyPairSpy,
};
Expand Down Expand Up @@ -67,20 +60,6 @@ describe('onRpcRequest', () => {
).rejects.toThrow(MethodNotFoundError);
});

it('throws `SnapError` on request if MetaMask needs update', async () => {
const { requireMetaMaskUpgradeSpy } = createMockSpy();
requireMetaMaskUpgradeSpy.mockResolvedValue(true);
await expect(
onRpcRequest({
...createMockRequest(),
request: {
...createMockRequest().request,
method: 'executeTxn',
},
}),
).rejects.toThrow(SnapError);
});

it('requests gets executed if MetaMask does not needs update', async () => {
createMockSpy();
expect(
Expand Down Expand Up @@ -111,11 +90,6 @@ describe('onRpcRequest', () => {

describe('onHomePage', () => {
it('executes homePageController normally if jsxSupport is not required', async () => {
const requireMetaMaskUpgradeSpy = jest.spyOn(
InitSnapStateManager.prototype,
'requireMetaMaskUpgrade',
);
requireMetaMaskUpgradeSpy.mockResolvedValue(false);
const executeSpy = jest.spyOn(HomePageController.prototype, 'execute');
executeSpy.mockResolvedValue({ content: text('test') });

Expand Down

0 comments on commit c66d1ac

Please sign in to comment.