simplify unit test

This commit is contained in:
sebastien 2025-07-07 15:10:48 +02:00
parent 1808945c1f
commit 97285cf392
2 changed files with 13 additions and 17 deletions

View file

@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`load loads props for site with custom i18n path 1`] = `
exports[`load loads props for site 1`] = `
{
"baseUrl": "/",
"codeTranslations": {},

View file

@ -6,26 +6,22 @@
*/
import path from 'path';
import {mergeWithCustomize} from 'webpack-merge';
import {loadSetup} from './testUtils';
import type {Props} from '@docusaurus/types';
import type {DeepPartial} from 'utility-types';
describe('load', () => {
it('loads props for site with custom i18n path', async () => {
it('loads props for site', async () => {
const site = await loadSetup('custom-i18n-site');
expect(site.props).toMatchSnapshot();
const site2 = await loadSetup('custom-i18n-site', {locale: 'zh-Hans'});
expect(site2.props).toEqual(
mergeWithCustomize<DeepPartial<Props>>({
customizeArray(a, b, key) {
return ['routesPaths', 'plugins'].includes(key) ? b : undefined;
},
})(site.props, {
});
it('loads props for site - custom i18n path', async () => {
const site = await loadSetup('custom-i18n-site', {locale: 'zh-Hans'});
expect(site.props).toEqual(
expect.objectContaining({
baseUrl: '/zh-Hans/',
i18n: {
i18n: expect.objectContaining({
currentLocale: 'zh-Hans',
},
}),
localizationDir: path.join(
__dirname,
'__fixtures__/custom-i18n-site/i18n/zh-Hans-custom',
@ -35,14 +31,14 @@ describe('load', () => {
'__fixtures__/custom-i18n-site/build/zh-Hans',
),
routesPaths: ['/zh-Hans/404.html'],
siteConfig: {
siteConfig: expect.objectContaining({
baseUrl: '/zh-Hans/',
},
}),
siteStorage: {
namespace: '',
type: 'localStorage',
},
plugins: site2.props.plugins,
plugins: site.props.plugins,
}),
);
});