mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-06 12:52:31 +02:00
refactor(v2): add flowtype + refactor test (#1443)
* chore(v2): add flow setup * nits * fix * add flow-typed * ignore compiled library * fix error * fix typing * fix module name mapper * setup for @docusaurus/core * dont try remove type without @flow * fix can't find @docusaurus/utils * fix test * remove obscure relative paths * more refactoring * add typing for server/load/theme.js * no need to ship .flow source
This commit is contained in:
parent
6f011d8e7a
commit
c2ebde997a
103 changed files with 8901 additions and 1589 deletions
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* 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 React from 'react';
|
||||
import Head from '@docusaurus/Head';
|
||||
|
||||
export default class World extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>World</title>
|
||||
</Head>
|
||||
<div>Hello World </div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* 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 React from 'react';
|
||||
import Head from '@docusaurus/Head';
|
||||
|
||||
export default class Home extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>Home</title>
|
||||
<link rel="stylesheet" type="text/css" href="/css/basic.css" />
|
||||
</Head>
|
||||
<div>Home ... </div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -7,35 +7,31 @@
|
|||
|
||||
import path from 'path';
|
||||
|
||||
import loadSetup from '../../../docusaurus/lib/server/load/__tests__/loadSetup';
|
||||
import DocusaurusPluginContentPages from '../index';
|
||||
|
||||
describe('docusaurus-plugin-content-pages', () => {
|
||||
describe('loadContent', () => {
|
||||
test.each([
|
||||
[
|
||||
'simple',
|
||||
pagesDir => [
|
||||
{
|
||||
permalink: '/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
permalink: '/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
],
|
||||
],
|
||||
])('%s website', async (type, expected) => {
|
||||
const {siteDir, siteConfig} = await loadSetup(type);
|
||||
const plugin = new DocusaurusPluginContentPages({
|
||||
siteDir,
|
||||
siteConfig,
|
||||
});
|
||||
const pagesMetadatas = await plugin.loadContent();
|
||||
const pagesDir = plugin.contentPath;
|
||||
|
||||
expect(pagesMetadatas).toEqual(expected(pagesDir));
|
||||
test('simple pages', async () => {
|
||||
const siteConfig = {
|
||||
title: 'Hello',
|
||||
baseUrl: '/',
|
||||
url: 'https://docusaurus.io',
|
||||
};
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'website');
|
||||
const plugin = new DocusaurusPluginContentPages({
|
||||
siteDir,
|
||||
siteConfig,
|
||||
});
|
||||
const pagesMetadatas = await plugin.loadContent();
|
||||
const pagesDir = plugin.contentPath;
|
||||
expect(pagesMetadatas).toEqual([
|
||||
{
|
||||
permalink: '/',
|
||||
source: path.join(pagesDir, 'index.js'),
|
||||
},
|
||||
{
|
||||
permalink: '/hello/world',
|
||||
source: path.join(pagesDir, 'hello', 'world.js'),
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue