mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-10 19:06:34 +03:00
tests: add SSR test
This commit is contained in:
parent
5bb0bdfd29
commit
ef4e6d8ae2
|
@ -70,7 +70,8 @@
|
|||
"typescript": "^2.6.2",
|
||||
"webpack": "^3.10.0",
|
||||
"webpack-dev-server": "^2.9.5",
|
||||
"webpack-node-externals": "^1.6.0"
|
||||
"webpack-node-externals": "^1.6.0",
|
||||
"yaml-js": "^0.2.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.0.0",
|
||||
|
|
20
src/__tests__/ssr.test.tsx
Normal file
20
src/__tests__/ssr.test.tsx
Normal file
|
@ -0,0 +1,20 @@
|
|||
import * as React from 'react';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
import { Redoc, createStore } from '../';
|
||||
var yaml = require('yaml-js');
|
||||
|
||||
import { readFileSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
|
||||
describe('SSR', () => {
|
||||
it('should render in SSR mode', async () => {
|
||||
(global as any).__DEV__ = true;
|
||||
const spec = yaml.load(readFileSync(resolve(__dirname, '../../demo/openapi.yaml')));
|
||||
const store = await createStore(spec, '');
|
||||
expect(() => {
|
||||
renderToString(<Redoc store={store} />);
|
||||
}).not.toThrow();
|
||||
|
||||
delete (global as any).__DEV__;
|
||||
});
|
||||
});
|
|
@ -4,7 +4,7 @@ import { default as PerfectScrollbarConstructor } from 'perfect-scrollbar';
|
|||
import psStyles from 'perfect-scrollbar/css/perfect-scrollbar.css';
|
||||
import styled, { injectGlobal } from '../styled-components';
|
||||
|
||||
injectGlobal`${psStyles.toString()}`;
|
||||
injectGlobal`${psStyles && psStyles.toString()}`;
|
||||
|
||||
const StyledScrollWrapper = styled.div`
|
||||
position: relative;
|
||||
|
|
|
@ -18,7 +18,7 @@ export class RedocStandalone extends React.Component<RedocStandaloneProps> {
|
|||
spec: (props, _, componentName) => {
|
||||
if (!props.spec && !props.specUrl) {
|
||||
return new Error(
|
||||
`One of props 'spec' or 'specUrlurl' was not specified in '${componentName}'.`,
|
||||
`One of props 'spec' or 'specUrl' was not specified in '${componentName}'.`,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -7574,6 +7574,10 @@ yallist@^2.1.2:
|
|||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
|
||||
|
||||
yaml-js@^0.2.3:
|
||||
version "0.2.3"
|
||||
resolved "https://registry.yarnpkg.com/yaml-js/-/yaml-js-0.2.3.tgz#f4cf6c1b3c784f59f55547d7dfcdd06418303291"
|
||||
|
||||
yargs-parser@^4.2.0:
|
||||
version "4.2.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-4.2.1.tgz#29cceac0dc4f03c6c87b4a9f217dd18c9f74871c"
|
||||
|
|
Loading…
Reference in New Issue
Block a user