Skip to content

Commit

Permalink
types: add test for context with default value (#2192)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei committed May 16, 2024
1 parent d057e1d commit 20011af
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 20011af

Please sign in to comment.