Skip to content

Commit

Permalink
fix test types
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed May 27, 2022
1 parent 3fd1b1b commit 4b0dd5c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const DefaultI18N: I18n = {
currentLocale: 'en',
locales: ['en'],
defaultLocale: 'en',
path: '1i8n',
localeConfigs: {
en: {
label: 'English',
Expand Down
5 changes: 5 additions & 0 deletions packages/docusaurus-utils/src/__tests__/i18nUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('localizePath', () => {
path: '/baseUrl',
i18n: {
defaultLocale: 'en',
path: 'i18n',
locales: ['en', 'fr'],
currentLocale: 'fr',
localeConfigs: {},
Expand All @@ -119,6 +120,7 @@ describe('localizePath', () => {
path: '/baseFsPath',
i18n: {
defaultLocale: 'en',
path: 'i18n',
locales: ['en', 'fr'],
currentLocale: 'fr',
localeConfigs: {},
Expand All @@ -135,6 +137,7 @@ describe('localizePath', () => {
path: '/baseUrl/',
i18n: {
defaultLocale: 'en',
path: 'i18n',
locales: ['en', 'fr'],
currentLocale: 'en',
localeConfigs: {},
Expand All @@ -151,6 +154,7 @@ describe('localizePath', () => {
path: '/baseUrl/',
i18n: {
defaultLocale: 'en',
path: 'i18n',
locales: ['en', 'fr'],
currentLocale: 'en',
localeConfigs: {},
Expand All @@ -166,6 +170,7 @@ describe('localizePath', () => {
path: '/baseUrl/',
i18n: {
defaultLocale: 'en',
path: 'i18n',
locales: ['en', 'fr'],
currentLocale: 'en',
localeConfigs: {},
Expand Down
9 changes: 6 additions & 3 deletions packages/docusaurus/src/server/__tests__/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {jest} from '@jest/globals';
import {loadI18n, getDefaultLocaleConfig} from '../i18n';
import {DEFAULT_I18N_CONFIG} from '../configValidation';
import type {I18nConfig} from '@docusaurus/types';
import type {DocusaurusConfig, I18nConfig} from '@docusaurus/types';

function testLocaleConfigsFor(locales: string[]) {
return Object.fromEntries(
Expand All @@ -18,10 +18,9 @@ function testLocaleConfigsFor(locales: string[]) {

function loadI18nTest(i18nConfig: I18nConfig, locale?: string) {
return loadI18n(
// @ts-expect-error: enough for this test
{
i18n: i18nConfig,
},
} as DocusaurusConfig,
{locale},
);
}
Expand Down Expand Up @@ -112,6 +111,7 @@ describe('loadI18n', () => {
it('loads I18n for multi-lang config', async () => {
await expect(
loadI18nTest({
path: 'i18n',
defaultLocale: 'fr',
locales: ['en', 'fr', 'de'],
localeConfigs: {},
Expand All @@ -128,6 +128,7 @@ describe('loadI18n', () => {
await expect(
loadI18nTest(
{
path: 'i18n',
defaultLocale: 'fr',
locales: ['en', 'fr', 'de'],
localeConfigs: {},
Expand All @@ -146,6 +147,7 @@ describe('loadI18n', () => {
await expect(
loadI18nTest(
{
path: 'i18n',
defaultLocale: 'fr',
locales: ['en', 'fr', 'de'],
localeConfigs: {
Expand Down Expand Up @@ -175,6 +177,7 @@ describe('loadI18n', () => {
it('warns when trying to load undeclared locale', async () => {
await loadI18nTest(
{
path: 'i18n',
defaultLocale: 'fr',
locales: ['en', 'fr', 'de'],
localeConfigs: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ describe('writePluginTranslations', () => {

await writePluginTranslations({
localizationDir,
locale: 'fr',
translationFile: {
path: 'my/translation/file',
content: {
Expand Down Expand Up @@ -384,7 +383,6 @@ describe('writePluginTranslations', () => {
await expect(() =>
writePluginTranslations({
localizationDir,
locale: 'fr',
translationFile: {
path: 'my/translation/file.json',
content: {},
Expand Down Expand Up @@ -420,7 +418,6 @@ describe('localizePluginTranslationFile', () => {

const localizedTranslationFile = await localizePluginTranslationFile({
localizationDir,
locale: 'fr',
translationFile,
plugin: {
name: 'my-plugin-name',
Expand Down Expand Up @@ -453,7 +450,6 @@ describe('localizePluginTranslationFile', () => {

const localizedTranslationFile = await localizePluginTranslationFile({
localizationDir,
locale: 'fr',
translationFile,
plugin: {
name: 'my-plugin-name',
Expand Down

0 comments on commit 4b0dd5c

Please sign in to comment.