mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-21 21:16:59 +02:00
test: fix inconsistent test
This commit is contained in:
parent
0f38ae3979
commit
0cef519e7f
3 changed files with 389 additions and 569 deletions
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
exports[`loadDocs simple website 1`] = `
|
exports[`loadDocs simple website 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"baseUrl": "/",
|
|
||||||
"docsData": Object {
|
|
||||||
"foo/bar": Object {
|
"foo/bar": Object {
|
||||||
"id": "foo/bar",
|
"id": "foo/bar",
|
||||||
"language": undefined,
|
"language": undefined,
|
||||||
|
@ -31,49 +29,11 @@ Object {
|
||||||
"title": "Hello, World !",
|
"title": "Hello, World !",
|
||||||
"version": undefined,
|
"version": undefined,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
"docsDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/docs",
|
|
||||||
"env": Object {
|
|
||||||
"translation": Object {
|
|
||||||
"defaultLanguage": Object {},
|
|
||||||
"enabled": false,
|
|
||||||
"enabledLanguages": Array [],
|
|
||||||
},
|
|
||||||
"versioning": Object {
|
|
||||||
"defaultVersion": null,
|
|
||||||
"enabled": false,
|
|
||||||
"latestVersion": null,
|
|
||||||
"versions": Array [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"outDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/simple-site/build",
|
|
||||||
"pagesData": Array [
|
|
||||||
Object {
|
|
||||||
"path": "/",
|
|
||||||
"source": "index.js",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"path": "/hello/world",
|
|
||||||
"source": "hello/world.js",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"pagesDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/simple-site/pages",
|
|
||||||
"siteConfig": Object {
|
|
||||||
"baseUrl": "/",
|
|
||||||
"organizationName": "endiliey",
|
|
||||||
"projectName": "hello",
|
|
||||||
"tagline": "Hello World",
|
|
||||||
"title": "Hello",
|
|
||||||
},
|
|
||||||
"siteDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/simple-site",
|
|
||||||
"themePath": "/mnt/c/Users/endij/Desktop/Linux/munseo/lib/theme",
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`loadDocs translated website 1`] = `
|
exports[`loadDocs translated website 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"baseUrl": "/",
|
|
||||||
"docsData": Object {
|
|
||||||
"en-hello": Object {
|
"en-hello": Object {
|
||||||
"id": "en-hello",
|
"id": "en-hello",
|
||||||
"language": "en",
|
"language": "en",
|
||||||
|
@ -128,65 +88,11 @@ Object {
|
||||||
"title": "Hello, World !",
|
"title": "Hello, World !",
|
||||||
"version": undefined,
|
"version": undefined,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
"docsDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/docs",
|
|
||||||
"env": Object {
|
|
||||||
"translation": Object {
|
|
||||||
"defaultLanguage": Object {
|
|
||||||
"enabled": true,
|
|
||||||
"name": "English",
|
|
||||||
"tag": "en",
|
|
||||||
},
|
|
||||||
"enabled": true,
|
|
||||||
"enabledLanguages": Array [
|
|
||||||
Object {
|
|
||||||
"enabled": true,
|
|
||||||
"name": "English",
|
|
||||||
"tag": "en",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"enabled": true,
|
|
||||||
"name": "한국어",
|
|
||||||
"tag": "ko",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"versioning": Object {
|
|
||||||
"defaultVersion": null,
|
|
||||||
"enabled": false,
|
|
||||||
"latestVersion": null,
|
|
||||||
"versions": Array [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"outDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/translated-site/build",
|
|
||||||
"pagesData": Array [
|
|
||||||
Object {
|
|
||||||
"path": "/",
|
|
||||||
"source": "index.js",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"path": "/hello/world",
|
|
||||||
"source": "hello/world.js",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"pagesDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/translated-site/pages",
|
|
||||||
"siteConfig": Object {
|
|
||||||
"baseUrl": "/",
|
|
||||||
"defaultLanguage": "en",
|
|
||||||
"organizationName": "endiliey",
|
|
||||||
"projectName": "hello",
|
|
||||||
"tagline": "Hello World",
|
|
||||||
"title": "Hello",
|
|
||||||
},
|
|
||||||
"siteDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/translated-site",
|
|
||||||
"themePath": "/mnt/c/Users/endij/Desktop/Linux/munseo/lib/theme",
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`loadDocs versioned & translated website 1`] = `
|
exports[`loadDocs versioned & translated website 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"baseUrl": "/",
|
|
||||||
"docsData": Object {
|
|
||||||
"en-hello": Object {
|
"en-hello": Object {
|
||||||
"id": "en-hello",
|
"id": "en-hello",
|
||||||
"language": "en",
|
"language": "en",
|
||||||
|
@ -371,68 +277,11 @@ Object {
|
||||||
"title": "Hello, World !",
|
"title": "Hello, World !",
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
"docsDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/docs",
|
|
||||||
"env": Object {
|
|
||||||
"translation": Object {
|
|
||||||
"defaultLanguage": Object {
|
|
||||||
"enabled": true,
|
|
||||||
"name": "English",
|
|
||||||
"tag": "en",
|
|
||||||
},
|
|
||||||
"enabled": true,
|
|
||||||
"enabledLanguages": Array [
|
|
||||||
Object {
|
|
||||||
"enabled": true,
|
|
||||||
"name": "English",
|
|
||||||
"tag": "en",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"enabled": true,
|
|
||||||
"name": "한국어",
|
|
||||||
"tag": "ko",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"versioning": Object {
|
|
||||||
"defaultVersion": "1.0.1",
|
|
||||||
"enabled": true,
|
|
||||||
"latestVersion": "1.0.1",
|
|
||||||
"versions": Array [
|
|
||||||
"1.0.1",
|
|
||||||
"1.0.0",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"outDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/transversioned-site/build",
|
|
||||||
"pagesData": Array [
|
|
||||||
Object {
|
|
||||||
"path": "/",
|
|
||||||
"source": "index.js",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"path": "/hello/world",
|
|
||||||
"source": "hello/world.js",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"pagesDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/transversioned-site/pages",
|
|
||||||
"siteConfig": Object {
|
|
||||||
"baseUrl": "/",
|
|
||||||
"defaultLanguage": "en",
|
|
||||||
"organizationName": "endiliey",
|
|
||||||
"projectName": "hello",
|
|
||||||
"tagline": "Hello World",
|
|
||||||
"title": "Hello",
|
|
||||||
},
|
|
||||||
"siteDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/transversioned-site",
|
|
||||||
"themePath": "/mnt/c/Users/endij/Desktop/Linux/munseo/lib/theme",
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`loadDocs versioned website 1`] = `
|
exports[`loadDocs versioned website 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"baseUrl": "/",
|
|
||||||
"docsData": Object {
|
|
||||||
"foo/bar": Object {
|
"foo/bar": Object {
|
||||||
"id": "foo/bar",
|
"id": "foo/bar",
|
||||||
"language": undefined,
|
"language": undefined,
|
||||||
|
@ -550,44 +399,5 @@ Object {
|
||||||
"title": "Hello, World !",
|
"title": "Hello, World !",
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
"docsDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/docs",
|
|
||||||
"env": Object {
|
|
||||||
"translation": Object {
|
|
||||||
"defaultLanguage": Object {},
|
|
||||||
"enabled": false,
|
|
||||||
"enabledLanguages": Array [],
|
|
||||||
},
|
|
||||||
"versioning": Object {
|
|
||||||
"defaultVersion": "1.0.1",
|
|
||||||
"enabled": true,
|
|
||||||
"latestVersion": "1.0.1",
|
|
||||||
"versions": Array [
|
|
||||||
"1.0.1",
|
|
||||||
"1.0.0",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"outDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/versioned-site/build",
|
|
||||||
"pagesData": Array [
|
|
||||||
Object {
|
|
||||||
"path": "/",
|
|
||||||
"source": "index.js",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"path": "/hello/world",
|
|
||||||
"source": "hello/world.js",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"pagesDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/versioned-site/pages",
|
|
||||||
"siteConfig": Object {
|
|
||||||
"baseUrl": "/",
|
|
||||||
"organizationName": "endiliey",
|
|
||||||
"projectName": "hello",
|
|
||||||
"tagline": "Hello World",
|
|
||||||
"title": "Hello",
|
|
||||||
},
|
|
||||||
"siteDir": "/mnt/c/Users/endij/Desktop/Linux/munseo/test/__fixtures__/versioned-site",
|
|
||||||
"themePath": "/mnt/c/Users/endij/Desktop/Linux/munseo/lib/theme",
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,23 +1,32 @@
|
||||||
|
import loadDocs from '@lib/load/docs';
|
||||||
import loadSetup from '../../loadSetup';
|
import loadSetup from '../../loadSetup';
|
||||||
|
|
||||||
describe('loadDocs', () => {
|
describe('loadDocs', () => {
|
||||||
test('simple website', async () => {
|
test('simple website', async () => {
|
||||||
const props = await loadSetup('simple');
|
const props = await loadSetup('simple');
|
||||||
expect(props).toMatchSnapshot();
|
const {siteDir, docsDir, env} = props;
|
||||||
|
const docsData = await loadDocs({siteDir, docsDir, env});
|
||||||
|
expect(docsData).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('versioned website', async () => {
|
test('versioned website', async () => {
|
||||||
const props = await loadSetup('versioned');
|
const props = await loadSetup('versioned');
|
||||||
expect(props).toMatchSnapshot();
|
const {siteDir, docsDir, env} = props;
|
||||||
|
const docsData = await loadDocs({siteDir, docsDir, env});
|
||||||
|
expect(docsData).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('versioned & translated website', async () => {
|
test('versioned & translated website', async () => {
|
||||||
const props = await loadSetup('transversioned');
|
const props = await loadSetup('transversioned');
|
||||||
expect(props).toMatchSnapshot();
|
const {siteDir, docsDir, env} = props;
|
||||||
|
const docsData = await loadDocs({siteDir, docsDir, env});
|
||||||
|
expect(docsData).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('translated website', async () => {
|
test('translated website', async () => {
|
||||||
const props = await loadSetup('translated');
|
const props = await loadSetup('translated');
|
||||||
expect(props).toMatchSnapshot();
|
const {siteDir, docsDir, env} = props;
|
||||||
|
const docsData = await loadDocs({siteDir, docsDir, env});
|
||||||
|
expect(docsData).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,12 +4,17 @@ import path from 'path';
|
||||||
describe('loadPages', () => {
|
describe('loadPages', () => {
|
||||||
test('valid pages', async () => {
|
test('valid pages', async () => {
|
||||||
const pagesDir = path.join(__dirname, '__fixtures__', 'simple-pages');
|
const pagesDir = path.join(__dirname, '__fixtures__', 'simple-pages');
|
||||||
const pagesData = await loadPages(pagesDir);
|
let pagesData = await loadPages(pagesDir);
|
||||||
|
pagesData.sort((a, b) => a.path > b.path); // because it was unordered
|
||||||
expect(pagesData).toEqual([
|
expect(pagesData).toEqual([
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
source: 'index.js'
|
source: 'index.js'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/bar/baz',
|
||||||
|
source: 'bar/baz.js'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/foo',
|
path: '/foo',
|
||||||
source: 'foo.js'
|
source: 'foo.js'
|
||||||
|
@ -17,10 +22,6 @@ describe('loadPages', () => {
|
||||||
{
|
{
|
||||||
path: '/foo/',
|
path: '/foo/',
|
||||||
source: 'foo/index.js'
|
source: 'foo/index.js'
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/bar/baz',
|
|
||||||
source: 'bar/baz.js'
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
expect(pagesData).not.toBeNull();
|
expect(pagesData).not.toBeNull();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue