UNPKG

@arbius/aa-wallet

Version:

A secure and flexible Account Abstraction wallet implementation for Arbitrum One chain applications.

51 lines (50 loc) 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const init_1 = require("../core/init"); const ethereumProxy_1 = require("../core/ethereumProxy"); const transactionQueue_1 = require("../core/transactionQueue"); // Mock the dependencies jest.mock('../core/ethereumProxy', () => ({ setupEthereumProxy: jest.fn(), })); jest.mock('../core/transactionQueue', () => ({ setupTransactionQueue: jest.fn(), })); describe('init', () => { beforeEach(() => { // Clear module state between tests jest.resetModules(); // Reset mocks jest.clearAllMocks(); // Reset global state // @ts-ignore global.__AA_WALLET_CONFIG = undefined; }); it('should initialize with valid config', () => { const config = { defaultChainId: 1, supportedChainIds: [1, 5, 11155111], }; (0, init_1.init)(config); expect(ethereumProxy_1.setupEthereumProxy).toHaveBeenCalled(); expect(transactionQueue_1.setupTransactionQueue).toHaveBeenCalled(); expect((0, init_1.getConfig)()).toEqual(config); expect((0, init_1.isInitialized)()).toBe(true); }); it('should throw error for invalid config', () => { const invalidConfig = { defaultChainId: 1, supportedChainIds: [], }; expect(() => (0, init_1.init)(invalidConfig)).toThrow('Configuration error'); expect((0, init_1.isInitialized)()).toBe(false); }); it('should throw error if defaultChainId is not in supportedChainIds', () => { const invalidConfig = { defaultChainId: 2, supportedChainIds: [1, 5, 11155111], }; expect(() => (0, init_1.init)(invalidConfig)).toThrow('Configuration error'); expect((0, init_1.isInitialized)()).toBe(false); }); });