mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-18 11:36:53 +02:00
refactor(v2): plugin, utils as separate package (#1298)
* refactor(v2): plugin, utils as separate package * rename docusaurus-plugin to @docusaurus/plugin * update snapshot
This commit is contained in:
parent
9597a8ce9c
commit
3a7a253db7
24 changed files with 102 additions and 43 deletions
125
packages/docusaurus-plugin-content-pages/__tests__/index.test.js
Normal file
125
packages/docusaurus-plugin-content-pages/__tests__/index.test.js
Normal file
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import loadSetup from '../../docusaurus/test/loadSetup';
|
||||
import DocusaurusPluginContentPages from '../index';
|
||||
|
||||
describe('docusaurus-plugin-content-pages', () => {
|
||||
describe('loadContents', () => {
|
||||
test.each([
|
||||
[
|
||||
'simple',
|
||||
pagesDir => [
|
||||
{
|
||||
permalink: '/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
permalink: '/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
],
|
||||
],
|
||||
[
|
||||
'versioned',
|
||||
pagesDir => [
|
||||
{
|
||||
permalink: '/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
permalink: '/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
],
|
||||
],
|
||||
[
|
||||
'translated',
|
||||
pagesDir => [
|
||||
{
|
||||
language: 'en',
|
||||
permalink: '/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
language: 'en',
|
||||
permalink: '/en/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
language: 'ko',
|
||||
permalink: '/ko/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
language: 'en',
|
||||
permalink: '/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
{
|
||||
language: 'en',
|
||||
permalink: '/en/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
{
|
||||
language: 'ko',
|
||||
permalink: '/ko/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
],
|
||||
[
|
||||
'transversioned',
|
||||
pagesDir => [
|
||||
{
|
||||
language: 'en',
|
||||
permalink: '/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
language: 'en',
|
||||
permalink: '/en/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
language: 'ko',
|
||||
permalink: '/ko/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
language: 'en',
|
||||
permalink: '/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
{
|
||||
language: 'en',
|
||||
permalink: '/en/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
{
|
||||
language: 'ko',
|
||||
permalink: '/ko/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
])('%s website', async (type, expected) => {
|
||||
const {env, siteDir, siteConfig} = await loadSetup(type);
|
||||
const plugin = new DocusaurusPluginContentPages(null, {
|
||||
env,
|
||||
siteDir,
|
||||
siteConfig,
|
||||
});
|
||||
const pagesMetadatas = await plugin.loadContents();
|
||||
const pagesDir = plugin.contentPath;
|
||||
|
||||
expect(pagesMetadatas).toEqual(expected(pagesDir));
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue