Skip to content

Commit

Permalink
unnecessary describe
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Nov 1, 2024
1 parent 877b246 commit 930c94a
Showing 1 changed file with 57 additions and 59 deletions.
116 changes: 57 additions & 59 deletions packages/use-intl/src/core/createTranslator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,77 +75,75 @@ it('throws an error for non-alphanumeric value names', () => {
});

describe('type safety', () => {
describe('keys', () => {
it('allows valid namespaces', () => {
createTranslator({
locale: 'en',
messages,
namespace: 'Home'
});
});

it('allows valid keys', () => {
const t = createTranslator({
locale: 'en',
messages,
namespace: 'Home'
});

t('title');
t.has('title');
t.markup('title');
t.rich('title');
it('allows valid namespaces', () => {
createTranslator({
locale: 'en',
messages,
namespace: 'Home'
});
});

it('allows an undefined namespace with a valid key', () => {
const t = createTranslator({
locale: 'en',
messages
});
t('Home.title');
it('allows valid keys', () => {
const t = createTranslator({
locale: 'en',
messages,
namespace: 'Home'
});

it('disallows an undefined namespace with an invalid key', () => {
const t = createTranslator({
locale: 'en',
messages
});
t('title');
t.has('title');
t.markup('title');
t.rich('title');
});

// @ts-expect-error
t('unknown');
// @ts-expect-error
t.has('unknown');
// @ts-expect-error
t.markup('unknown');
// @ts-expect-error
t.rich('unknown');
it('allows an undefined namespace with a valid key', () => {
const t = createTranslator({
locale: 'en',
messages
});
t('Home.title');
});

it('disallows invalid namespaces', () => {
createTranslator<typeof messages>({
locale: 'en',
messages,
// @ts-expect-error
namespace: 'unknown'
});
it('disallows an undefined namespace with an invalid key', () => {
const t = createTranslator({
locale: 'en',
messages
});

it('disallows invalid keys', () => {
const t = createTranslator({
locale: 'en',
messages,
namespace: 'Home'
});
// @ts-expect-error
t('unknown');
// @ts-expect-error
t.has('unknown');
// @ts-expect-error
t.markup('unknown');
// @ts-expect-error
t.rich('unknown');
});

it('disallows invalid namespaces', () => {
createTranslator<typeof messages>({
locale: 'en',
messages,
// @ts-expect-error
t('unknown');
// @ts-expect-error
t.has('unknown');
// @ts-expect-error
t.markup('unknown');
// @ts-expect-error
t.rich('unknown');
namespace: 'unknown'
});
});

it('disallows invalid keys', () => {
const t = createTranslator({
locale: 'en',
messages,
namespace: 'Home'
});

// @ts-expect-error
t('unknown');
// @ts-expect-error
t.has('unknown');
// @ts-expect-error
t.markup('unknown');
// @ts-expect-error
t.rich('unknown');
});
});

Expand Down

0 comments on commit 930c94a

Please sign in to comment.