UNPKG

@koralabs/cardano-wallets

Version:

Library for connecting cardano wallets in the browser using CIP-30

32 lines (31 loc) 917 B
import { CardanoWallets } from '.'; describe('CardanoWallets Tests', () => { let windowSpy; beforeEach(() => { windowSpy = jest.spyOn(window, 'window', 'get'); }); afterEach(() => { windowSpy.mockRestore(); }); it('Should throw error if window is not defined', async () => { // @ts-ignore windowSpy.mockImplementation(() => undefined); try { await CardanoWallets.connect('nami'); } catch (error) { expect(error.message).toEqual(null); } }); it('Should throw error if window.cardano is not defined', async () => { // @ts-ignore windowSpy.mockImplementation(() => ({})); try { await CardanoWallets.connect('nami'); } catch (error) { expect(error.message).toEqual(null); } }); it('Should connect', async () => { }); });