diff options
author | Sebastian <sebasjm@gmail.com> | 2023-04-21 10:47:47 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-04-21 10:47:47 -0300 |
commit | f470f167e32d8f7775ad994f09afb1d353b0b300 (patch) | |
tree | 3a1f2a040bb09d6639c81436b90b416fb8044f91 /packages/anastasis-webui/src/utils/index.tsx | |
parent | 6dcc488a2c8fd681941e5d3b62bb04af7669888e (diff) |
integrate anastasis to the web-utils testing api
Diffstat (limited to 'packages/anastasis-webui/src/utils/index.tsx')
-rw-r--r-- | packages/anastasis-webui/src/utils/index.tsx | 57 |
1 files changed, 1 insertions, 56 deletions
diff --git a/packages/anastasis-webui/src/utils/index.tsx b/packages/anastasis-webui/src/utils/index.tsx index 4cf839473..88bcac551 100644 --- a/packages/anastasis-webui/src/utils/index.tsx +++ b/packages/anastasis-webui/src/utils/index.tsx @@ -21,67 +21,12 @@ import { ReducerState, ReducerStateRecovery, } from "@gnu-taler/anastasis-core"; -import { ComponentChildren, FunctionalComponent, h, VNode } from "preact"; -import { AnastasisProvider } from "../context/anastasis.js"; +import { VNode } from "preact"; const noop = async (): Promise<void> => { return; }; -export function createExampleWithoutAnastasis<Props>( - Component: FunctionalComponent<Props>, - props: Partial<Props> | (() => Partial<Props>), -): ComponentChildren { - //FIXME: props are evaluated on build time - // in some cases we want to evaluated the props on render time so we can get some relative timestamp - // check how we can build evaluatedProps in render time - const evaluatedProps = typeof props === "function" ? props() : props; - const Render = (args: any): VNode => h(Component, args); - return { - component: Render, - props: evaluatedProps, - }; -} - -export function createExample<Props>( - Component: FunctionalComponent<Props>, - currentReducerState?: ReducerState, - props?: Partial<Props>, -): ComponentChildren { - const Render = (args: Props): VNode => { - return ( - <AnastasisProvider - value={{ - currentReducerState, - discoverMore: noop, - discoverStart: noop, - discoveryState: { - state: "finished", - }, - currentError: undefined, - back: noop, - dismissError: noop, - reset: noop, - runTransaction: noop, - startBackup: noop, - startRecover: noop, - transition: noop, - exportState: () => { - return "{}"; - }, - importState: noop, - }} - > - <Component {...(args as any)} /> - </AnastasisProvider> - ); - }; - return { - component: Render, - props: props, - }; -} - const base = { continents: [ { |