chore(v2): make v2 docs plugin legacy (#1639)

* chore(v2): make v2 docs plugin legacy

* chore(v2): update fixtures
This commit is contained in:
Yangshun Tay 2019-07-05 17:20:46 -07:00 committed by GitHub
parent 702dba1c81
commit e5e085b33d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 24 additions and 21 deletions

View file

@ -0,0 +1,57 @@
/**
* 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 pluginContentDocs from '../index';
describe('loadDocs', () => {
test('simple website', async () => {
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const siteConfig = {
title: 'Hello',
baseUrl: '/',
url: 'https://docusaurus.io',
};
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = pluginContentDocs(
{
siteDir,
siteConfig,
},
{
path: 'docs',
sidebarPath,
},
);
const {docs: docsMetadata} = await plugin.loadContent();
const docsDir = plugin.contentPath;
expect(docsMetadata.hello).toEqual({
category: 'Guides',
id: 'hello',
permalink: '/docs/hello',
previous: 'foo/baz',
previous_title: 'baz',
sidebar: 'docs',
source: path.join(docsDir, 'hello.md'),
title: 'Hello, World !',
description: `Hi, Endilie here :)`,
});
expect(docsMetadata['foo/bar']).toEqual({
category: 'Test',
id: 'foo/bar',
next: 'foo/baz',
next_title: 'baz',
permalink: '/docs/foo/bar',
sidebar: 'docs',
source: path.join(docsDir, 'foo', 'bar.md'),
title: 'Bar',
description: 'This is custom description',
});
});
});