diff --git a/packages/use-i18n/src/__tests__/locales/en.json b/packages/use-i18n/src/__tests__/locales/en.json index 31bf99601..675e26090 100644 --- a/packages/use-i18n/src/__tests__/locales/en.json +++ b/packages/use-i18n/src/__tests__/locales/en.json @@ -1,4 +1,5 @@ { + "with.identifier": "Are you sure you want to delete {identifier}?", "plurals": "You have {numPhotos, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}", "subtitle": "Here is a subtitle", "tests.test.namespaces": "test", diff --git a/packages/use-i18n/src/__tests__/usei18n.tsx b/packages/use-i18n/src/__tests__/usei18n.tsx index a464b363a..c819eb948 100644 --- a/packages/use-i18n/src/__tests__/usei18n.tsx +++ b/packages/use-i18n/src/__tests__/usei18n.tsx @@ -600,4 +600,28 @@ describe('i18n hook', () => { expect(result.current.dateFnsLocale?.code).toEqual('en-GB') }) }) + + it('should work with a component', async () => { + const { result } = renderHook(() => useTranslation([]), { + wrapper: wrapper({ defaultLocale: 'en' }), + }) + const CustomComponent = ({ children }: { children: ReactNode }) => ( +
{children}
+ ) + + await waitFor(() => { + expect( + result.current.t('with.identifier', { identifier: My resource }), + ).toEqual(['Are you sure you want to delete ', My resource, '?']) + expect( + result.current.t('with.identifier', { + identifier: