From 56d0638c76d8e1c012f64a11d3359c8fcdc3805f Mon Sep 17 00:00:00 2001 From: Espen Hovlandsdal Date: Fri, 13 Oct 2023 16:58:01 -0700 Subject: [PATCH] test: add LocaleProvider to TestProvider --- .../FileInput/__tests__/fileInput.test.tsx | 2 +- .../sanity/test/testUtils/TestProvider.tsx | 34 ++++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/packages/sanity/src/core/form/inputs/files/FileInput/__tests__/fileInput.test.tsx b/packages/sanity/src/core/form/inputs/files/FileInput/__tests__/fileInput.test.tsx index d7aaf58479c9..967935505420 100644 --- a/packages/sanity/src/core/form/inputs/files/FileInput/__tests__/fileInput.test.tsx +++ b/packages/sanity/src/core/form/inputs/files/FileInput/__tests__/fileInput.test.tsx @@ -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() }) }) diff --git a/packages/sanity/test/testUtils/TestProvider.tsx b/packages/sanity/test/testUtils/TestProvider.tsx index fa1ee4021b6d..efc92b75a838 100644 --- a/packages/sanity/test/testUtils/TestProvider.tsx +++ b/packages/sanity/test/testUtils/TestProvider.tsx @@ -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 { @@ -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 ( - - - - - {children} - - - - + + + + + + {children} + + + + + ) }