diff options
author | Sebastian <sebasjm@gmail.com> | 2022-12-15 17:11:24 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-12-15 17:11:24 -0300 |
commit | f93bd51499ed34844b666bf6d333227adf4368bf (patch) | |
tree | ed3cf0c38b7db54276436d1743a6085c94f71977 /packages/taler-wallet-webextension/src/test-utils.ts | |
parent | 8d8d71807df6b775e5b0335eb1b2526a56d42ac6 (diff) | |
download | wallet-core-f93bd51499ed34844b666bf6d333227adf4368bf.tar.xz |
wxApi from context and using the new testing sdk
Diffstat (limited to 'packages/taler-wallet-webextension/src/test-utils.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/test-utils.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/taler-wallet-webextension/src/test-utils.ts b/packages/taler-wallet-webextension/src/test-utils.ts index b4983b4c2..791773c42 100644 --- a/packages/taler-wallet-webextension/src/test-utils.ts +++ b/packages/taler-wallet-webextension/src/test-utils.ts @@ -31,6 +31,7 @@ import { VNode, } from "preact"; import { render as renderToString } from "preact-render-to-string"; +import { BackendProvider } from "./context/backend.js"; import { BackgroundApiClient, wxApi } from "./wxApi.js"; // When doing tests we want the requestAnimationFrame to be as fast as possible. @@ -252,7 +253,7 @@ type Subscriptions = { export function createWalletApiMock(): { handler: MockHandler; - mock: typeof wxApi; + TestingContext: FunctionalComponent<{ children: ComponentChildren }> } { const calls = new Array<CallRecord>(); const subscriptions: Subscriptions = {}; @@ -357,5 +358,14 @@ export function createWalletApiMock(): { }, }; - return { handler, mock }; + function TestingContext({ children }: { children: ComponentChildren }): VNode { + return create(BackendProvider, { + wallet: mock.wallet, + background: mock.background, + listener: mock.listener, + children, + }, children) + } + + return { handler, TestingContext }; } |