Skip to content

Commit

Permalink
test: add LocaleProvider to TestProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 13, 2023
1 parent 2ce93ba commit 56d0638
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('FileInput with empty state', () => {
})

await waitFor(() => {
expect(result.queryByText(`inputs.files.common.placeholder.read-only`)).toBeInTheDocument()
expect(result.queryByText('Read only')).toBeInTheDocument()
})
})

Expand Down
34 changes: 25 additions & 9 deletions packages/sanity/test/testUtils/TestProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import React from 'react'
import {SanityClient} from '@sanity/client'
import {LayerProvider, studioTheme, ThemeProvider, ToastProvider} from '@sanity/ui'
import {
LocaleProviderBase,
ResourceCacheProvider,
SingleWorkspace,
SourceProvider,
usEnglishLocale,
WorkspaceProvider,
} from '../../src/core'
import {prepareI18n} from '../../src/core/i18n/i18nConfig'
import {studioDefaultLocaleResources} from '../../src/core/i18n/bundles/studio'
import {getMockWorkspace} from './getMockWorkspaceFromConfig'

interface TestProviderOptions {
Expand All @@ -17,18 +21,30 @@ interface TestProviderOptions {
export async function createTestProvider({client, config}: TestProviderOptions = {}) {
const workspace = await getMockWorkspace({client, config})

const locales = [usEnglishLocale]
const {i18next} = prepareI18n({
projectId: 'test',
dataset: 'test',
name: 'test',
i18n: {bundles: [studioDefaultLocaleResources]},
})

await i18next.init()

function TestProvider({children}: {children: React.ReactNode}) {
return (
<ThemeProvider theme={studioTheme}>
<ToastProvider>
<LayerProvider>
<WorkspaceProvider workspace={workspace}>
<SourceProvider source={workspace.unstable_sources[0]}>
<ResourceCacheProvider>{children}</ResourceCacheProvider>
</SourceProvider>
</WorkspaceProvider>
</LayerProvider>
</ToastProvider>
<LocaleProviderBase locales={locales} i18next={i18next} projectId="test" sourceId="test">
<ToastProvider>
<LayerProvider>
<WorkspaceProvider workspace={workspace}>
<SourceProvider source={workspace.unstable_sources[0]}>
<ResourceCacheProvider>{children}</ResourceCacheProvider>
</SourceProvider>
</WorkspaceProvider>
</LayerProvider>
</ToastProvider>
</LocaleProviderBase>
</ThemeProvider>
)
}
Expand Down

0 comments on commit 56d0638

Please sign in to comment.