-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(core): Add
defineWalletSetup
function
- Loading branch information
1 parent
fd8edb1
commit d368c5d
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { BrowserContext, Page } from 'playwright-core' | ||
import { getWalletSetupFuncHash } from './utils/getWalletSetupFuncHash' | ||
|
||
export type WalletSetupFunction = (context: BrowserContext, walletPage: Page) => Promise<void> | ||
|
||
// TODO: This runs at least twice. Should we cache it somehow? | ||
export function defineWalletSetup(fn: WalletSetupFunction) { | ||
const hash = getWalletSetupFuncHash(fn) | ||
|
||
return { | ||
hash, | ||
fn | ||
} | ||
} |
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,21 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { defineWalletSetup } from '../src/defineWalletSetup' | ||
|
||
const EXPECTED_HASH = '69620d59802a61c6900f' | ||
|
||
const testWalletSetupFunction = async (): Promise<void> => { | ||
const result = 1 + 2 | ||
if (result !== 3) { | ||
throw new Error('That damn Quacker messed with my math again! 😡') | ||
} | ||
|
||
return | ||
} | ||
|
||
describe('defineWalletSetup', () => { | ||
it('returns both hash and function', async () => { | ||
const { hash, fn } = defineWalletSetup(testWalletSetupFunction) | ||
expect(hash).toEqual(EXPECTED_HASH) | ||
expect(fn.toString()).toEqual(testWalletSetupFunction.toString()) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.