-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
91 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export type {LocalePrefix} from './types'; | ||
export type {Pathnames} from './types'; | ||
export type {Pathnames, LocalePrefix, DomainsConfig} from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,69 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import {it} from 'vitest'; | ||
import {LocalePrefix} from '../../src/routing/types'; | ||
import {describe, it} from 'vitest'; | ||
import {LocalePrefix, DomainConfig} from '../../src/routing/types'; | ||
|
||
it('does not require a type param for simple values', () => { | ||
const config: LocalePrefix = 'always'; | ||
}); | ||
describe('LocalePrefix', () => { | ||
it('does not require a type param for simple values', () => { | ||
const config: LocalePrefix = 'always'; | ||
}); | ||
|
||
it('provides strict typing for locales', () => { | ||
const locales = ['en', 'de'] as const; | ||
const config: LocalePrefix<typeof locales> = { | ||
mode: 'always', | ||
prefixes: { | ||
en: '/en', | ||
// @ts-expect-error | ||
unknown: '/unknown' | ||
} | ||
}; | ||
}); | ||
it('provides strict typing for locales', () => { | ||
const locales = ['en', 'de'] as const; | ||
const config: LocalePrefix<typeof locales> = { | ||
mode: 'always', | ||
prefixes: { | ||
en: '/en', | ||
// @ts-expect-error | ||
unknown: '/unknown' | ||
} | ||
}; | ||
}); | ||
|
||
it('allows partial config', () => { | ||
const locales = ['en', 'de'] as const; | ||
const config: LocalePrefix<typeof locales> = { | ||
mode: 'always', | ||
prefixes: { | ||
en: '/en' | ||
} | ||
}; | ||
}); | ||
|
||
it('allows partial config', () => { | ||
const locales = ['en', 'de'] as const; | ||
const config: LocalePrefix<typeof locales> = { | ||
mode: 'always', | ||
prefixes: { | ||
en: '/en' | ||
} | ||
}; | ||
it('provides optional typing for locales in prefixes', () => { | ||
const config: LocalePrefix = { | ||
mode: 'always', | ||
prefixes: { | ||
de: '/de', | ||
en: '/en', | ||
unknown: '/unknown' | ||
} | ||
}; | ||
}); | ||
}); | ||
|
||
it('provides optional typing for locales in prefixes', () => { | ||
const config: LocalePrefix = { | ||
mode: 'always', | ||
prefixes: { | ||
de: '/de', | ||
en: '/en', | ||
unknown: '/unknown' | ||
} | ||
}; | ||
describe('DomainConfig', () => { | ||
it('allows to handle all locales', () => { | ||
const config: DomainConfig<['en', 'de']> = { | ||
defaultLocale: 'en', | ||
domain: 'example.com' | ||
}; | ||
}); | ||
|
||
it('allows to restrict locales', () => { | ||
const config: DomainConfig<['en', 'de']> = { | ||
defaultLocale: 'en', | ||
domain: 'example.com', | ||
locales: ['en'] | ||
}; | ||
}); | ||
|
||
it('errors for unknown locales', () => { | ||
const config: DomainConfig<['en', 'de']> = { | ||
// @ts-expect-error | ||
defaultLocale: 'unknown', | ||
domain: 'example.com', | ||
// @ts-expect-error | ||
locales: ['unknown'] | ||
}; | ||
}); | ||
}); |