Skip to content

Commit 93a1e1a

Browse files
committed
more refactoring
1 parent 8d7f44f commit 93a1e1a

File tree

6 files changed

+67
-37
lines changed

6 files changed

+67
-37
lines changed

packages/docusaurus-plugin-content-docs/src/__tests__/index.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@ describe('loadDocs', () => {
1414
const siteDir = path.join(__dirname, '__fixtures__', 'website');
1515
const siteConfig = {
1616
title: 'Hello',
17-
tagline: 'Hello World',
18-
organizationName: 'endiliey',
19-
projectName: 'hello',
2017
baseUrl: '/',
2118
url: 'https://docusaurus.io',
22-
headerIcon: '',
23-
favicon: '',
2419
};
2520
const sidebarPath = path.join(siteDir, 'sidebars.json');
2621
const plugin = new DocusaurusPluginContentDocs(

packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@ describe('processMetadata', () => {
1313
const siteDir = path.join(__dirname, '__fixtures__', 'website');
1414
const siteConfig = {
1515
title: 'Hello',
16-
tagline: 'Hello World',
17-
organizationName: 'endiliey',
18-
projectName: 'hello',
1916
baseUrl: '/',
2017
url: 'https://docusaurus.io',
21-
headerIcon: '',
22-
favicon: '',
2318
};
2419
const docsDir = path.resolve(siteDir, 'docs');
2520

packages/docusaurus-plugin-content-docs/src/__tests__/sidebars.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import '@babel/polyfill';
98
import path from 'path';
109
import loadSidebars from '../sidebars';
1110

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) 2017-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import Head from '@docusaurus/Head';
10+
11+
export default class World extends React.Component {
12+
render() {
13+
return (
14+
<div>
15+
<Head>
16+
<title>World</title>
17+
</Head>
18+
<div>Hello World </div>
19+
</div>
20+
);
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) 2017-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import Head from '@docusaurus/Head';
10+
11+
export default class Home extends React.Component {
12+
render() {
13+
return (
14+
<div>
15+
<Head>
16+
<title>Home</title>
17+
<link rel="stylesheet" type="text/css" href="/css/basic.css" />
18+
</Head>
19+
<div>Home ... </div>
20+
</div>
21+
);
22+
}
23+
}

packages/docusaurus-plugin-content-pages/src/__tests__/index.test.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,31 @@
77

88
import path from 'path';
99

10-
import loadSetup from '../../../docusaurus/src/server/load/loadSetup';
1110
import DocusaurusPluginContentPages from '../index';
1211

1312
describe('docusaurus-plugin-content-pages', () => {
14-
describe('loadContent', () => {
15-
test.each([
16-
[
17-
'simple',
18-
pagesDir => [
19-
{
20-
permalink: '/',
21-
source: path.join(pagesDir, 'index.js'),
22-
},
23-
{
24-
permalink: '/hello/world',
25-
source: path.join(pagesDir, 'hello', 'world.js'),
26-
},
27-
],
28-
],
29-
])('%s website', async (type, expected) => {
30-
const {siteDir, siteConfig} = await loadSetup(type);
31-
const plugin = new DocusaurusPluginContentPages({
32-
siteDir,
33-
siteConfig,
34-
});
35-
const pagesMetadatas = await plugin.loadContent();
36-
const pagesDir = plugin.contentPath;
37-
38-
expect(pagesMetadatas).toEqual(expected(pagesDir));
13+
test('simple pages', async () => {
14+
const siteConfig = {
15+
title: 'Hello',
16+
baseUrl: '/',
17+
url: 'https://docusaurus.io',
18+
};
19+
const siteDir = path.join(__dirname, '__fixtures__', 'website');
20+
const plugin = new DocusaurusPluginContentPages({
21+
siteDir,
22+
siteConfig,
3923
});
24+
const pagesMetadatas = await plugin.loadContent();
25+
const pagesDir = plugin.contentPath;
26+
expect(pagesMetadatas).toEqual([
27+
{
28+
permalink: '/',
29+
source: path.join(pagesDir, 'index.js'),
30+
},
31+
{
32+
permalink: '/hello/world',
33+
source: path.join(pagesDir, 'hello', 'world.js'),
34+
},
35+
]);
4036
});
4137
});

0 commit comments

Comments
 (0)