Created
July 20, 2021 18:10
-
-
Save jodyheavener/63ede34122b9d51bde1b935d38b7ee13 to your computer and use it in GitHub Desktop.
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
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