Skip to content

Commit

Permalink
types: add test for context with default value (i18next#2192)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei authored and heharm committed Aug 15, 2024
1 parent 246c9eb commit 7b2ebd8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/typescript/custom-types/t.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ describe('t', () => {
assertType(t('foo', { context: 'cake' }));
});

it('should accept not mapped context if a fallback key is present', () => {
// wine is not mapped
const currentTheme = 'wine' as 'wine' | 'beer' | 'water';
expectTypeOf(t('beverage', { context: currentTheme })).toMatchTypeOf<string>();
});

it('should accept a default context key as a valid `t` function key', () => {
expectTypeOf(t('beverage')).toMatchTypeOf('cold water');
});
Expand Down

0 comments on commit 7b2ebd8

Please sign in to comment.