mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #11602 from overleaf/jel-react-personal-subscription-dash-pt-6
[web] Continue migration of change plan UI to React GitOrigin-RevId: 4f6176ac101ba3c57134cf5c86329e205f17ab23
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
import { render } from '@testing-library/react'
|
||||
import { SubscriptionDashboardProvider } from '../../../../../frontend/js/features/subscription/context/subscription-dashboard-context'
|
||||
|
||||
export function renderWithSubscriptionDashContext(
|
||||
component: React.ReactElement,
|
||||
options?: {
|
||||
metaTags?: { name: string; value: string | object | Array<object> }[]
|
||||
recurlyNotLoaded?: boolean
|
||||
}
|
||||
) {
|
||||
const SubscriptionDashboardProviderWrapper = ({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) => (
|
||||
<SubscriptionDashboardProvider>{children}</SubscriptionDashboardProvider>
|
||||
)
|
||||
|
||||
window.metaAttributesCache = new Map()
|
||||
options?.metaTags?.forEach(tag =>
|
||||
window.metaAttributesCache.set(tag.name, tag.value)
|
||||
)
|
||||
|
||||
if (!options?.recurlyNotLoaded) {
|
||||
// @ts-ignore
|
||||
window.recurly = {}
|
||||
}
|
||||
|
||||
return render(component, {
|
||||
wrapper: SubscriptionDashboardProviderWrapper,
|
||||
})
|
||||
}
|
||||
|
||||
export function cleanUpContext() {
|
||||
// @ts-ignore
|
||||
delete window.recurly
|
||||
window.metaAttributesCache = new Map()
|
||||
}
|
||||
Reference in New Issue
Block a user