From 0f28b6f311c9d4a74fa1480561c7311128b0d10c Mon Sep 17 00:00:00 2001 From: endiliey Date: Sat, 11 Aug 2018 14:22:50 +0800 Subject: [PATCH] test: fix load test --- lib/load/routes.js | 4 +- test/load/__fixtures__/simple-docs/foo/bar.md | 66 ++++++++++++++ test/load/__fixtures__/simple-docs/foo/baz.md | 77 ++++++++++++++++ test/load/__fixtures__/simple-docs/hello.md | 40 +++++++++ .../load/__fixtures__/simple-pages/bar/baz.js | 3 + test/load/__fixtures__/simple-pages/foo.js | 3 + .../__fixtures__/simple-pages/foo/index.js | 3 + test/load/__fixtures__/simple-pages/index.js | 3 + test/load/__snapshots__/routes.test.js.snap | 90 ++++--------------- 9 files changed, 213 insertions(+), 76 deletions(-) create mode 100644 test/load/__fixtures__/simple-docs/foo/bar.md create mode 100644 test/load/__fixtures__/simple-docs/foo/baz.md create mode 100644 test/load/__fixtures__/simple-docs/hello.md create mode 100644 test/load/__fixtures__/simple-pages/bar/baz.js create mode 100644 test/load/__fixtures__/simple-pages/foo.js create mode 100644 test/load/__fixtures__/simple-pages/foo/index.js create mode 100644 test/load/__fixtures__/simple-pages/index.js diff --git a/lib/load/routes.js b/lib/load/routes.js index c84193cc99..2b6f48fd60 100644 --- a/lib/load/routes.js +++ b/lib/load/routes.js @@ -7,8 +7,8 @@ async function genRoutesConfig({docsData = [], pagesData = []}) { { path: ${JSON.stringify(docsPath)}, exact: true, - component: () => ( - + component: (props) => ( + <${componentName} /> ) diff --git a/test/load/__fixtures__/simple-docs/foo/bar.md b/test/load/__fixtures__/simple-docs/foo/bar.md new file mode 100644 index 0000000000..9f978009c5 --- /dev/null +++ b/test/load/__fixtures__/simple-docs/foo/bar.md @@ -0,0 +1,66 @@ +--- +id: bar +title: Bar +--- + +# Remarkable + +> Experience real-time editing with Remarkable! + +Click the `clear` link to start with a clean slate, or get the `permalink` to share or save your results. + +*** + +# h1 Heading +## h2 Heading +### h3 Heading +#### h4 Heading +##### h5 Heading +###### h6 Heading + + +## Horizontal Rules + +___ + +*** + +*** + + +## Typographic replacements + +Enable typographer option to see result. + +(c) (C) (r) (R) (tm) (TM) (p) (P) +- + +test.. test... test..... test?..... test!.... + +!!!!!! ???? ,, + +Remarkable -- awesome + +"Smartypants, double quotes" + +'Smartypants, single quotes' + + +## Emphasis + +**This is bold text** + +__This is bold text__ + +*This is italic text* + +_This is italic text_ + +~~Deleted text~~ + +Superscript: 19^th^ + +Subscript: H~2~O + +++Inserted text++ + +==Marked text== diff --git a/test/load/__fixtures__/simple-docs/foo/baz.md b/test/load/__fixtures__/simple-docs/foo/baz.md new file mode 100644 index 0000000000..add729c51d --- /dev/null +++ b/test/load/__fixtures__/simple-docs/foo/baz.md @@ -0,0 +1,77 @@ +--- +id: baz +title: baz +--- + +## Images + +![Minion](/img/minion.png) +![Stormtroopocat](/img/stormtroopocat.jpg) + +Like links, Images also have a footnote style syntax + +![Alt text][id] + +With a reference later in the document defining the URL location: + +[id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat" + +## Links + +[link text](http://dev.nodeca.com) + +[link with title](http://nodeca.github.io/pica/demo/ "title text!") + +Autoconverted link https://github.com/nodeca/pica (enable linkify to see) + + + +## Footnotes + +Footnote 1 link[^first]. + +Footnote 2 link[^second]. + +Inline footnote^[Text of inline footnote] definition. + +Duplicated footnote reference[^second]. + +[^first]: Footnote **can have markup** + + and multiple paragraphs. + +[^second]: Footnote text. + + +## Definition lists + +Term 1 + +: Definition 1 +with lazy continuation. + +Term 2 with *inline markup* + +: Definition 2 + + { some code, part of Definition 2 } + + Third paragraph of definition 2. + +_Compact style:_ + +Term 1 + ~ Definition 1 + +Term 2 + ~ Definition 2a + ~ Definition 2b + + +## Abbreviations + +This is HTML abbreviation example. + +It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on. + +*[HTML]: Hyper Text Markup Language diff --git a/test/load/__fixtures__/simple-docs/hello.md b/test/load/__fixtures__/simple-docs/hello.md new file mode 100644 index 0000000000..a392b2ca54 --- /dev/null +++ b/test/load/__fixtures__/simple-docs/hello.md @@ -0,0 +1,40 @@ +--- +id: hello +title: Hello, World ! +--- + +Hi, Endilie here :) + +## Blockquotes + +> Blockquotes can also be nested... +>> ...by using additional greater-than signs right next to each other... +> > > ...or with spaces between arrows. + + +## Lists + +Unordered + ++ Create a list by starting a line with `+`, `-`, or `*` ++ Sub-lists are made by indenting 2 spaces: + - Marker character change forces new list start: + * Ac tristique libero volutpat at + + Facilisis in pretium nisl aliquet + - Nulla volutpat aliquam velit ++ Very easy! + +Ordered + +1. Lorem ipsum dolor sit amet +2. Consectetur adipiscing elit +3. Integer molestie lorem at massa + + +1. You can use sequential numbers... +1. ...or keep all the numbers as `1.` + +Start numbering with offset: + +57. foo +1. bar diff --git a/test/load/__fixtures__/simple-pages/bar/baz.js b/test/load/__fixtures__/simple-pages/bar/baz.js new file mode 100644 index 0000000000..75a8c70015 --- /dev/null +++ b/test/load/__fixtures__/simple-pages/bar/baz.js @@ -0,0 +1,3 @@ +import React from 'react'; + +export default () =>
Baz
; diff --git a/test/load/__fixtures__/simple-pages/foo.js b/test/load/__fixtures__/simple-pages/foo.js new file mode 100644 index 0000000000..3b52ec615c --- /dev/null +++ b/test/load/__fixtures__/simple-pages/foo.js @@ -0,0 +1,3 @@ +import React from 'react'; + +export default () =>
Foo
; diff --git a/test/load/__fixtures__/simple-pages/foo/index.js b/test/load/__fixtures__/simple-pages/foo/index.js new file mode 100644 index 0000000000..5faf67ae13 --- /dev/null +++ b/test/load/__fixtures__/simple-pages/foo/index.js @@ -0,0 +1,3 @@ +import React from 'react'; + +export default () =>
Foo in subfolder
; diff --git a/test/load/__fixtures__/simple-pages/index.js b/test/load/__fixtures__/simple-pages/index.js new file mode 100644 index 0000000000..13063810a7 --- /dev/null +++ b/test/load/__fixtures__/simple-pages/index.js @@ -0,0 +1,3 @@ +import React from 'react'; + +export default () =>
Index
; diff --git a/test/load/__snapshots__/routes.test.js.snap b/test/load/__snapshots__/routes.test.js.snap index e0f4c9eff0..075ce45f36 100644 --- a/test/load/__snapshots__/routes.test.js.snap +++ b/test/load/__snapshots__/routes.test.js.snap @@ -21,37 +21,8 @@ exports[`genRoutesConfig website with only docs 1`] = ` import Docs from '@theme/Docs'; import NotFound from '@theme/NotFound'; -import MDHello from '@docs/hello.md'; -import MDFooBaz from '@docs/foo/baz.md'; -import MDFooBar from '@docs/foo/bar.md'; -const routes = [ - { - path: \\"/hello\\", - exact: true, - component: () => ( - - - - ) - }, - { - path: \\"/foo/baz\\", - exact: true, - component: () => ( - - - - ) - }, - { - path: \\"/foo/bar\\", - exact: true, - component: () => ( - - - - ) - },, + +const routes = [,, { path: '*', component: NotFound @@ -65,22 +36,22 @@ exports[`genRoutesConfig website with only pages 1`] = ` "import React from 'react'; import Docs from '@theme/Docs'; import NotFound from '@theme/NotFound'; -import JSIndex from '@pages/index.js'; import JSFoo from '@pages/foo.js'; +import JSIndex from '@pages/index.js'; import JSBarBaz from '@pages/bar/baz.js'; import JSFooIndex from '@pages/foo/index.js'; const routes = [, - { - path: \\"/\\", - exact: true, - component: JSIndex - }, { path: \\"/foo\\", exact: true, component: JSFoo }, + { + path: \\"/\\", + exact: true, + component: JSIndex + }, { path: \\"/bar/baz\\", exact: true, @@ -106,39 +77,10 @@ import Docs from '@theme/Docs'; import NotFound from '@theme/NotFound'; import JSFoo from '@pages/foo.js'; import JSIndex from '@pages/index.js'; -import JSBarBaz from '@pages/bar/baz.js'; import JSFooIndex from '@pages/foo/index.js'; -import MDHello from '@docs/hello.md'; -import MDFooBar from '@docs/foo/bar.md'; -import MDFooBaz from '@docs/foo/baz.md'; -const routes = [ - { - path: \\"/hello\\", - exact: true, - component: () => ( - - - - ) - }, - { - path: \\"/foo/bar\\", - exact: true, - component: () => ( - - - - ) - }, - { - path: \\"/foo/baz\\", - exact: true, - component: () => ( - - - - ) - }, +import JSBarBaz from '@pages/bar/baz.js'; + +const routes = [, { path: \\"/foo\\", exact: true, @@ -149,16 +91,16 @@ const routes = [ exact: true, component: JSIndex }, - { - path: \\"/bar/baz\\", - exact: true, - component: JSBarBaz - }, { path: \\"/foo/\\", exact: true, component: JSFooIndex }, + { + path: \\"/bar/baz\\", + exact: true, + component: JSBarBaz + }, { path: '*', component: NotFound