-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: basic tests for the reactive controller
- Loading branch information
Showing
3 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/wallet-manager/src/test/WalletManagerController.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { LitElement } from 'lit'; | ||
import { ExternalProvider } from '@ethersproject/providers'; | ||
import { ethers } from 'ethers' | ||
import { describe, it, beforeEach, vi, expect } from 'vitest'; | ||
import { WalletManagerController } from '..'; | ||
|
||
class WidgetTestFixture extends LitElement { | ||
constructor() { | ||
super(); | ||
} | ||
} | ||
|
||
customElements.define('widget-test-fixture', WidgetTestFixture); | ||
|
||
describe('WalletManagerController', () => { | ||
let walletController: WalletManagerController; | ||
const walletTextFixture = new WidgetTestFixture(); | ||
|
||
beforeEach(() => { | ||
window.ethereum = { | ||
request: () => Promise.resolve(true), | ||
on: vi.fn() | ||
} as ExternalProvider & { on: () => void }; | ||
|
||
walletController = new WalletManagerController(walletTextFixture); | ||
}); | ||
|
||
it('should instantiate', () => { | ||
expect(walletController).toBeInstanceOf(WalletManagerController); | ||
}); | ||
it('should initialize evm wallet from window', () => { | ||
walletController.initFromWindow(); | ||
expect(walletController.evmWallet).toBeDefined(); | ||
}); | ||
it('should initialize evm wallet from web3 provider', () => { | ||
const provider = new ethers.providers.Web3Provider(window.ethereum); | ||
walletController.initFromWeb3Provider(provider); | ||
expect(walletController.evmWallet).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters