diff --git a/packages/use-i18n/src/__typetests__/namespaceTranslation.test.ts b/packages/use-i18n/src/__typetests__/namespaceTranslation.test.ts index e365fedea..bfe760fd6 100644 --- a/packages/use-i18n/src/__typetests__/namespaceTranslation.test.ts +++ b/packages/use-i18n/src/__typetests__/namespaceTranslation.test.ts @@ -16,43 +16,34 @@ test('i18n - namespaceTranslation', () => { const { namespaceTranslation } = useI18n() // Single key - expect(namespaceTranslation('hello')).type.toRaiseError( - `Argument of type '"hello"' is not assignable to parameter of type '"doe" | "describe"'`, - ) + expect(namespaceTranslation).type.not.toBeCallableWith('hello') // Multiple keys - expect(namespaceTranslation('doe.john')).type.toRaiseError( - `Argument of type '"doe.john"' is not assignable to parameter of type '"doe" | "describe"'`, - ) + expect(namespaceTranslation).type.not.toBeCallableWith('doe.john') expect(namespaceTranslation('doe')('john')).type.toBe() - expect(namespaceTranslation('doe')('doesnotexists')).type.toRaiseError( - `Expected 2 arguments, but got 1.`, - ) + expect(namespaceTranslation('doe')).type.not.toBeCallableWith('doesnotexists') // With a param - expect(namespaceTranslation('doe')('child')).type.toRaiseError( - `Expected 2 arguments, but got 1.`, - ) + expect(namespaceTranslation('doe')).type.not.toBeCallableWith('child') expect( namespaceTranslation('doe')('child', { name: 'Name', }), ).type.toBe() - expect( - namespaceTranslation('doe')('doesnotexists', { + expect(namespaceTranslation('doe')).type.not.toBeCallableWith( + 'doesnotexists', + { name: 'Name', - }), - ).type.toRaiseError() - expect( - namespaceTranslation('doe')('child', { - doesnotexists: 'Name', - }), - ).type.toRaiseError() + }, + ) + expect(namespaceTranslation('doe')).type.not.toBeCallableWith('child', { + doesnotexists: 'Name', + }) - expect(namespaceTranslation('doe')('child', {})).type.toRaiseError() - expect(namespaceTranslation('doe')('child')).type.toRaiseError() + expect(namespaceTranslation('doe')).type.not.toBeCallableWith('child', {}) + expect(namespaceTranslation('doe')).type.not.toBeCallableWith('child') // With multiple params expect( @@ -62,12 +53,10 @@ test('i18n - namespaceTranslation', () => { }), ).type.toBe() - expect(namespaceTranslation('describe')('john', {})).type.toRaiseError() - expect(namespaceTranslation('describe')('john')).type.toRaiseError() + expect(namespaceTranslation('describe')).type.not.toBeCallableWith('john', {}) + expect(namespaceTranslation('describe')).type.not.toBeCallableWith('john') // Required generic const { namespaceTranslation: namespaceTranslation2 } = useI18n() - expect(namespaceTranslation2('test')).type.toRaiseError( - `Argument of type '"test"' is not assignable to parameter of type`, - ) + expect(namespaceTranslation2).type.not.toBeCallableWith('test') }) diff --git a/packages/use-i18n/src/__typetests__/t.test.tsx b/packages/use-i18n/src/__typetests__/t.test.tsx index 313ab59c8..2a3c697fc 100644 --- a/packages/use-i18n/src/__typetests__/t.test.tsx +++ b/packages/use-i18n/src/__typetests__/t.test.tsx @@ -12,11 +12,11 @@ const { t } = useI18n<{ test('i18n - t', () => { expect(t('hello')).type.toBe() // Single key - expect(t('keydoesnotexists')).type.toRaiseError() + expect(t).type.not.toBeCallableWith('keydoesnotexists') // Multiple keys expect(t('doe.john')).type.toBe() - expect(t('doe.doesnotexists')).type.toRaiseError() + expect(t).type.not.toBeCallableWith('doe.doesnotexists') // With a param expect( @@ -24,17 +24,13 @@ test('i18n - t', () => { name: 'Name', }), ).type.toBe() - expect( - t('doe.doesnotexists', { - name: 'Name', - }), - ).type.toRaiseError() + expect(t).type.not.toBeCallableWith('doe.doesnotexists', { + name: 'Name', + }) - expect(t('doe.child', {})).type.toRaiseError( - "Argument of type '{}' is not assignable to parameter of type", - ) + expect(t).type.not.toBeCallableWith('doe.child', {}) - expect(t('doe.child')).type.toRaiseError('Expected 2 arguments, but got 1') + expect(t).type.not.toBeCallableWith('doe.child') // With multiple params expect( @@ -44,8 +40,8 @@ test('i18n - t', () => { }), ).type.toBe() - expect(t('describe.john', {})).type.toRaiseError() - expect(t('describe.john')).type.toRaiseError() + expect(t).type.not.toBeCallableWith('describe.john', {}) + expect(t).type.not.toBeCallableWith('describe.john') // With react components as param value expect( @@ -60,5 +56,5 @@ test('i18n - t', () => { // Required generic const { t: t2 } = useI18n() - expect(t2('test')).type.toRaiseError() + expect(t2).type.not.toBeCallableWith('test') })