Skip to content

Commit

Permalink
Add namespace consumer test with multi value
Browse files Browse the repository at this point in the history
  • Loading branch information
rosskevin committed Jan 23, 2019
1 parent 2964867 commit 8e90695
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/typescript/NamespacesConsumer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,25 @@ function workWithOptionalProps() {
<NamespacesConsumer i18n={i18next}>{t => <Control hint={t('title')} />}</NamespacesConsumer>
);
}

function workWithVariousResults() {
return (
<NamespacesConsumer i18n={i18next}>
{(t, { i18n }) => {
// sanity first - tests from i18next t.test
const is: string = i18n.t('friend'); // same as <string>
const io: object = i18n.t<object>('friend');
const isa: string[] = i18n.t<string[]>('friend');
const ioa: object[] = i18n.t<object[]>('friend');

// now try t provided by NamespacesConsumer
const s: string = t('friend'); // same as <string>
const o: object = t<object>('friend');
const sa: string[] = t<string[]>('friend');
const oa: object[] = t<object[]>('friend');

return <div>foo</div>;
}}
</NamespacesConsumer>
);
}

0 comments on commit 8e90695

Please sign in to comment.