-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebc7b97
commit 61df46e
Showing
31 changed files
with
1,410 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
env: { | ||
test: { | ||
presets: ['@babel/preset-env', '@babel/preset-react'] | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = { | ||
rootDir: './', | ||
coverageReporters: ['lcov'], | ||
collectCoverageFrom: ['**/*.{js,ts,tsx}', '!**/*/node_modules/**', '!**/docs/**', '!**/test/**'], | ||
moduleNameMapper: { | ||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': | ||
'<rootDir>/__mocks__/fileMock.js', | ||
'.*\\.(css|less|scss)$': 'identity-obj-proxy' | ||
}, | ||
testRegex: '(/__test__/.*|(\\.|/)(test|spec))\\.(ts|js)?$', | ||
transform: { | ||
'^.+\\.jsx?$': 'babel7-jest', | ||
'^.+\\.tsx?$': 'ts-jest' | ||
}, | ||
snapshotSerializers: ['enzyme-to-json/serializer'], | ||
setupFiles: ['<rootDir>/node_modules/regenerator-runtime/runtime'], | ||
setupFilesAfterEnv: ['<rootDir>/setupTest.js'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
globals: { | ||
'ts-jest': { | ||
isolatedModules: true, | ||
tsConfig: { | ||
target: 'es6' | ||
}, | ||
babelConfig: true | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/@rcpress/core/lib/node/__tests__/commands/cli.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const { getSourceDirs } = require('@rcpress/test-util'); | ||
const spa = require('../../commands/spa'); | ||
const ssr = require('../../commands/ssr'); | ||
|
||
describe('Commands', () => { | ||
test('dev', async () => { | ||
await Promise.all( | ||
getSourceDirs(__dirname).map(async ({ name, docsPath, docsTempPath }) => { | ||
await fs.ensureDir(docsTempPath); | ||
expect(() => { | ||
spa(docsPath); | ||
}).not.toThrow(); | ||
}) | ||
); | ||
}); | ||
|
||
test('dev-prod', async () => { | ||
await Promise.all( | ||
getSourceDirs(__dirname).map(async ({ name, docsPath, docsTempPath }) => { | ||
await fs.ensureDir(docsTempPath); | ||
expect(() => { | ||
spa(docsPath, {}, true); | ||
}).not.toThrow(); | ||
}) | ||
); | ||
}); | ||
|
||
test('ssr', async () => { | ||
await Promise.all( | ||
getSourceDirs(__dirname).map(async ({ name, docsPath, docsTempPath }) => { | ||
await fs.ensureDir(docsTempPath); | ||
expect(() => { | ||
ssr(docsPath); | ||
}).not.toThrow(); | ||
}) | ||
); | ||
}); | ||
|
||
test('ssr-prod', async () => { | ||
await Promise.all( | ||
getSourceDirs(__dirname).map(async ({ name, docsPath, docsTempPath }) => { | ||
await fs.ensureDir(docsTempPath); | ||
expect(() => { | ||
ssr(docsPath, {}, true); | ||
}).not.toThrow(); | ||
}) | ||
); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/@rcpress/core/lib/node/__tests__/commands/fixtures/demo/README.MD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# hello world! | ||
|
||
hello world |
3 changes: 3 additions & 0 deletions
3
packages/@rcpress/core/lib/node/__tests__/prepare/fixtures/demo/README.MD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# hello world! | ||
|
||
hello world |
16 changes: 16 additions & 0 deletions
16
packages/@rcpress/core/lib/node/__tests__/prepare/prepare.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const prepare = require('../../prepare/index'); | ||
const { getSourceDirs } = require('@rcpress/test-util'); | ||
|
||
describe('App', () => { | ||
test('should not throw error', async () => { | ||
await Promise.all( | ||
getSourceDirs(__dirname).map(async ({ name, docsPath, docsTempPath }) => { | ||
await fs.ensureDir(docsTempPath); | ||
const option = await prepare(docsPath); | ||
expect(option.sourceDir).toBe(docsPath); | ||
}) | ||
); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/@rcpress/core/lib/node/__tests__/ssr/__snapshots__/page-render.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ssr pagerender 1`] = ` | ||
"<!-- prettier-ignore --> | ||
<!DOCTYPE html> | ||
<html {{{ htmlAttr }}}> | ||
<head> | ||
<meta charset=\\"utf-8\\" /> | ||
<meta name=\\"viewport\\" content=\\"width=device-width,initial-scale=1\\" /> | ||
<!--react-helmet render area --> | ||
{{{ title }}} | ||
{{{ meta }}} | ||
{{{ helmet-links }}} | ||
<script> | ||
window.RC_CONTEXT = \\"{{ RC_CONTEXT }}\\"; | ||
</script> | ||
<!--loadable-components prefetch --> | ||
{{{ links }}} | ||
{{{ style }}} | ||
</head> | ||
<body> | ||
<div id=\\"app\\"><div class=\\"page-wrapper index-page-wrapper\\"><div style=\\"width:100%\\"><div class=\\"\\"><div id=\\"header\\" class=\\"header\\"><div class=\\"ant-row\\"><div class=\\"ant-col ant-col-xs-24 ant-col-sm-24 ant-col-md-8 ant-col-lg-8 ant-col-xl-5 ant-col-xxl-4\\"><a id=\\"site-logo\\" href=\\"/\\"><span class=\\"left-top-title\\">rcpress</span></a></div><div class=\\"ant-col ant-col-xs-0 ant-col-sm-0 ant-col-md-16 ant-col-lg-16 ant-col-xl-19 ant-col-xxl-20\\"><div class=\\"header-meta\\"><div class=\\"right-header\\"></div><div id=\\"menu\\"><ul id=\\"nav\\" class=\\"ant-menu ant-menu-light ant-menu-root ant-menu-horizontal\\" role=\\"menu\\"></ul></div></div></div></div></div></div></div><div class=\\"ant-row main-wrapper\\"><div class=\\"ant-col ant-col-xs-24 ant-col-sm-24 ant-col-md-24 ant-col-lg-24 ant-col-xl-24 ant-col-xxl-24\\"><div><div><div class=\\"main-container\\"><article class=\\"markdown\\"><div class=\\"modifiedTime modifiedTimeLeft\\">Last Updated<!-- --> <!-- -->2020-03-14 21:55:00</div><div class=\\" toc-affix\\"><div><div class=\\"\\"><div class=\\"toc toc-affix ant-anchor-wrapper\\" style=\\"max-height:calc(100vh - 70px)\\"><div class=\\"ant-anchor\\"><div class=\\"ant-anchor-ink\\"><span class=\\"ant-anchor-ink-ball\\"></span></div><div class=\\"ant-anchor-link\\"><a class=\\"ant-anchor-link-title\\" href=\\"#hello-world\\" title=\\"hello world!\\">hello world!</a></div></div></div></div></div></div><section class=\\"markdown api-container\\"><h1 class=\\"__internal\\" id=\\"hello-world\\">hello world!<a href=\\"#hello-world\\" aria-hidden=\\"true\\" class=\\"anchor\\">#</a></h1><p>hello world</p></section><section class=\\"prev-next-nav\\"></section></article></div></div></div></div></div></div></div> | ||
<!--loadable-components render area --> | ||
{{{ scripts }}} | ||
</body> | ||
</html> | ||
" | ||
`; |
3 changes: 3 additions & 0 deletions
3
packages/@rcpress/core/lib/node/__tests__/ssr/fixtures/demo/README.MD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# hello world! | ||
|
||
hello world |
31 changes: 31 additions & 0 deletions
31
packages/@rcpress/core/lib/node/__tests__/ssr/page-render.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const prepare = require('../../prepare/index'); | ||
const fs = require('fs-extra'); | ||
const { getSourceDirs } = require('@rcpress/test-util'); | ||
const getConfig = require('../../commands/ssr/getConfig'); | ||
const { Helmet } = require('react-helmet'); | ||
jest.setTimeout(200000); | ||
// Helmet.canUseDOM = false; | ||
describe('ssr', () => { | ||
beforeEach(() => { | ||
Helmet.canUseDOM = false; | ||
}); | ||
|
||
afterEach(() => { | ||
Helmet.canUseDOM = true; | ||
}); | ||
test('pagerender', async () => { | ||
const { getPageRender } = require('../../commands/ssr'); | ||
await Promise.all( | ||
getSourceDirs(__dirname).map(async ({ name, docsPath, docsTempPath }) => { | ||
await fs.ensureDir(docsTempPath); | ||
const [ssrConfig, spaConfig, options] = await getConfig(docsPath, {}, true); | ||
const pagerender = await getPageRender(ssrConfig, spaConfig, options); | ||
const html = await pagerender.renderPage( | ||
options.siteData.pages[0], | ||
true /* only render html*/ | ||
); | ||
expect(html).toMatchSnapshot(); | ||
}) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.