mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
d4057a7bcc
[web] Continue migration of change plan UI to React GitOrigin-RevId: 4f6176ac101ba3c57134cf5c86329e205f17ab23
38 lines
1,017 B
TypeScript
38 lines
1,017 B
TypeScript
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()
|
|
}
|