Skip to content

Instantly share code, notes, and snippets.

@jodyheavener
Created July 20, 2021 18:10
Show Gist options
  • Save jodyheavener/63ede34122b9d51bde1b935d38b7ee13 to your computer and use it in GitHub Desktop.
Save jodyheavener/63ede34122b9d51bde1b935d38b7ee13 to your computer and use it in GitHub Desktop.
export const MockExperimentContextProvider = ({
overrides = {},
refetch = () => {},
children,
}: {
overrides?: Partial<getExperiment["experimentBySlug"]>;
refetch?: () => void;
children: ReactNode;
}) => {
const { experiment } = mockExperiment("demo-slug", overrides);
const context = {
experiment,
status: getStatus(experiment),
review: useReviewCheck(experiment),
refetch,
};
return (
<ExperimentContext.Provider value={context}>
{children}
</ExperimentContext.Provider>
);
};
export const MockAnalysisContextProvider = ({
overrides = {},
error,
loading = false,
children,
}: {
overrides?: Record<string, any> | null;
error?: Error;
loading?: boolean;
children: ReactNode;
}) => {
const analysis = overrides === null ? null : mockAnalysis(overrides);
const context = {
analysis,
error,
loading,
};
return (
<AnalysisContext.Provider value={context}>
{children}
</AnalysisContext.Provider>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment