mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-20 18:17:51 +02:00
fix and enhance docs tests
This commit is contained in:
parent
f6f3e6cdb4
commit
4f5d4b49cd
1 changed files with 47 additions and 1 deletions
|
@ -13,6 +13,7 @@ import {
|
||||||
posixPath,
|
posixPath,
|
||||||
DEFAULT_PLUGIN_ID,
|
DEFAULT_PLUGIN_ID,
|
||||||
LAST_UPDATE_FALLBACK,
|
LAST_UPDATE_FALLBACK,
|
||||||
|
getLocaleConfig,
|
||||||
} from '@docusaurus/utils';
|
} from '@docusaurus/utils';
|
||||||
import {getTagsFile} from '@docusaurus/utils-validation';
|
import {getTagsFile} from '@docusaurus/utils-validation';
|
||||||
import {createSidebarsUtils} from '../sidebars/utils';
|
import {createSidebarsUtils} from '../sidebars/utils';
|
||||||
|
@ -842,7 +843,11 @@ describe('simple site', () => {
|
||||||
|
|
||||||
describe('versioned site', () => {
|
describe('versioned site', () => {
|
||||||
async function loadSite(
|
async function loadSite(
|
||||||
loadSiteOptions: {options: Partial<PluginOptions>; locale?: string} = {
|
loadSiteOptions: {
|
||||||
|
options?: Partial<PluginOptions>;
|
||||||
|
locale?: string;
|
||||||
|
translate?: boolean;
|
||||||
|
} = {
|
||||||
options: {},
|
options: {},
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
@ -851,6 +856,10 @@ describe('versioned site', () => {
|
||||||
siteDir,
|
siteDir,
|
||||||
locale: loadSiteOptions.locale,
|
locale: loadSiteOptions.locale,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO this is quite hacky but gets the job done
|
||||||
|
getLocaleConfig(context.i18n).translate = loadSiteOptions.translate ?? true;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
id: DEFAULT_PLUGIN_ID,
|
id: DEFAULT_PLUGIN_ID,
|
||||||
...DEFAULT_OPTIONS,
|
...DEFAULT_OPTIONS,
|
||||||
|
@ -1055,6 +1064,43 @@ describe('versioned site', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('versioned docs - translate: false', async () => {
|
||||||
|
const {version100TestUtils} = await loadSite({
|
||||||
|
translate: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// This doc is translated, but we still read the original
|
||||||
|
await version100TestUtils.testMeta(path.join('hello.md'), {
|
||||||
|
id: 'hello',
|
||||||
|
sourceDirName: '.',
|
||||||
|
permalink: '/docs/1.0.0/',
|
||||||
|
slug: '/',
|
||||||
|
title: 'hello',
|
||||||
|
description: 'Hello 1.0.0 !',
|
||||||
|
frontMatter: {
|
||||||
|
slug: '/',
|
||||||
|
tags: ['inlineTag-v1.0.0', 'globalTag-v1.0.0'],
|
||||||
|
},
|
||||||
|
version: '1.0.0',
|
||||||
|
source: '@site/versioned_docs/version-1.0.0/hello.md',
|
||||||
|
tags: [
|
||||||
|
{
|
||||||
|
description: undefined,
|
||||||
|
inline: true,
|
||||||
|
label: 'inlineTag-v1.0.0',
|
||||||
|
permalink: '/docs/1.0.0/tags/inline-tag-v-1-0-0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: 'globalTag-v1.0.0 description',
|
||||||
|
inline: false,
|
||||||
|
label: 'globalTag-v1.0.0 label',
|
||||||
|
permalink: '/docs/1.0.0/tags/globalTag-v1.0.0 permalink',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
unlisted: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('next doc slugs', async () => {
|
it('next doc slugs', async () => {
|
||||||
const {currentVersionTestUtils} = await loadSite();
|
const {currentVersionTestUtils} = await loadSite();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue