);
fireEvent.click(getByRole('button'));
- expect(copy).toBeCalledWith(pathline);
+ expect(copy).toHaveBeenCalledWith(pathline);
});
diff --git a/src/client/rsg-components/Pathline/__snapshots__/Pathline.spec.tsx.snap b/src/client/rsg-components/Pathline/__snapshots__/Pathline.spec.tsx.snap
index 5a9a8b896..bb6136acb 100644
--- a/src/client/rsg-components/Pathline/__snapshots__/Pathline.spec.tsx.snap
+++ b/src/client/rsg-components/Pathline/__snapshots__/Pathline.spec.tsx.snap
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`renderer should a path line 1`] = `
diff --git a/src/client/rsg-components/Props/Props.spec.tsx b/src/client/rsg-components/Props/Props.spec.tsx
index 71517f7b8..e84aee3d8 100644
--- a/src/client/rsg-components/Props/Props.spec.tsx
+++ b/src/client/rsg-components/Props/Props.spec.tsx
@@ -5,7 +5,7 @@ import { parse } from 'react-docgen';
import PropsRenderer, { columns, getRowKey } from './PropsRenderer';
import { unquote, getType, showSpaces, PropDescriptor } from './util';
-const propsToArray = (props: any) => Object.keys(props).map(name => ({ ...props[name], name }));
+const propsToArray = (props: any) => Object.keys(props).map((name) => ({ ...props[name], name }));
const getText = (node: { innerHTML: string }): string =>
node.innerHTML
@@ -130,13 +130,13 @@ describe('PropsRenderer', () => {
]}
/>
);
- expect((await findAllByRole('columnheader')).map(node => node.textContent)).toEqual([
+ expect((await findAllByRole('columnheader')).map((node) => node.textContent)).toEqual([
'Prop name',
'Type',
'Default',
'Description',
]);
- expect((await findAllByRole('cell')).map(node => node.textContent)).toEqual([
+ expect((await findAllByRole('cell')).map((node) => node.textContent)).toEqual([
'color',
'string',
'tomato',
@@ -289,9 +289,9 @@ describe('props columns', () => {
expect(getByText('Shape').title).toMatchInlineSnapshot(`
"{
- \\"bar\\": 123,
- \\"qwarc\\": {
- \\"si\\": \\"señor\\"
+ "bar": 123,
+ "qwarc": {
+ "si": "señor"
}
}"
`);
@@ -685,19 +685,19 @@ describe('props columns', () => {
const { container } = renderFn(['foo: MyEnum'], [], [options.enum.declaration]);
if (options.enum.expect.type === 'enum') {
expect(getText(container)).toMatchInlineSnapshot(`
- "Prop name: foo
- Type: ${options.enum.expect.type}
- Default: Required
- Description:
- One of: One , Two"
- `);
+ "Prop name: foo
+ Type: enum
+ Default: Required
+ Description:
+ One of: One , Two"
+ `);
} else {
expect(getText(container)).toMatchInlineSnapshot(`
- "Prop name: foo
- Type: ${options.enum.expect.type}
- Default: Required
- Description:"
- `);
+ "Prop name: foo
+ Type: MyEnum
+ Default: Required
+ Description:"
+ `);
}
});
diff --git a/src/client/rsg-components/ReactExample/__snapshots__/ReactExample.spec.tsx.snap b/src/client/rsg-components/ReactExample/__snapshots__/ReactExample.spec.tsx.snap
index 2552cfeb7..ca285c799 100644
--- a/src/client/rsg-components/ReactExample/__snapshots__/ReactExample.spec.tsx.snap
+++ b/src/client/rsg-components/ReactExample/__snapshots__/ReactExample.spec.tsx.snap
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should render code 1`] = `
OK",
"evalInContext": [Function],
"type": "code",
@@ -21,10 +21,10 @@ exports[`render should render component 1`] = `
OK",
"evalInContext": [Function],
"type": "code",
@@ -80,10 +80,10 @@ exports[`render should render styled component 1`] = `
OK",
"evalInContext": [Function],
"type": "code",
@@ -133,10 +133,10 @@ exports[`should render component renderer 1`] = `
{
);
fireEvent.click(getByText(/pizza/i));
- expect(onClick).toBeCalledTimes(1);
+ expect(onClick).toHaveBeenCalledTimes(1);
});
diff --git a/src/client/rsg-components/Table/__snapshots__/Table.spec.tsx.snap b/src/client/rsg-components/Table/__snapshots__/Table.spec.tsx.snap
index 6b2bdeb78..611b6b8de 100644
--- a/src/client/rsg-components/Table/__snapshots__/Table.spec.tsx.snap
+++ b/src/client/rsg-components/Table/__snapshots__/Table.spec.tsx.snap
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should render a table 1`] = `
{
fireEvent.change(getByRole('textbox'), { target: { value: newSearchTerm } });
- expect(onSearchTermChange).toBeCalledWith(newSearchTerm);
+ expect(onSearchTermChange).toHaveBeenCalledWith(newSearchTerm);
});
it('should render content of subsections of a section that has no components', () => {
@@ -135,24 +135,24 @@ it('should render content of subsections of a section that has no components', (
>
{
renderer.render();
expect(renderer.getRenderOutput()).toMatchInlineSnapshot(`
-
-
-
-`);
+
+
+
+ `);
});
it('should render as the link will open in a new window only if external presents as true', () => {
@@ -240,41 +240,41 @@ it('should render as the link will open in a new window only if external present
);
expect(renderer.getRenderOutput()).toMatchInlineSnapshot(`
-
-
-
-`);
+
+
+
+ `);
});
/**
diff --git a/src/client/rsg-components/Text/__snapshots__/Text.spec.tsx.snap b/src/client/rsg-components/Text/__snapshots__/Text.spec.tsx.snap
index bc79a4202..725b281bb 100644
--- a/src/client/rsg-components/Text/__snapshots__/Text.spec.tsx.snap
+++ b/src/client/rsg-components/Text/__snapshots__/Text.spec.tsx.snap
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`Text should render colored text 1`] = `
diff --git a/src/client/rsg-components/Wrapper/__snapshots__/Wrapper.spec.tsx.snap b/src/client/rsg-components/Wrapper/__snapshots__/Wrapper.spec.tsx.snap
index 95bca6c02..c552ae1f8 100644
--- a/src/client/rsg-components/Wrapper/__snapshots__/Wrapper.spec.tsx.snap
+++ b/src/client/rsg-components/Wrapper/__snapshots__/Wrapper.spec.tsx.snap
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should render children 1`] = `
diff --git a/src/client/rsg-components/slots/__snapshots__/IsolateButton.spec.tsx.snap b/src/client/rsg-components/slots/__snapshots__/IsolateButton.spec.tsx.snap
index 717e452d7..49e70531d 100644
--- a/src/client/rsg-components/slots/__snapshots__/IsolateButton.spec.tsx.snap
+++ b/src/client/rsg-components/slots/__snapshots__/IsolateButton.spec.tsx.snap
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should renderer a link home in isolated mode 1`] = `
{
test('compile ES6 to ES5', () => {
const result = compileCode(`const {foo, bar} = baz`, compilerConfig);
expect(result).toMatchInlineSnapshot(`
-"var foo = baz.foo;
-var bar = baz.bar;"
-`);
+ "var foo = baz.foo;
+ var bar = baz.bar;"
+ `);
});
test('transform imports to require()', () => {
const result = compileCode(`import foo from 'bar'`, compilerConfig);
expect(result).toMatchInlineSnapshot(`
-"const bar$0 = require('bar');
-const foo = bar$0.default || bar$0;"
-`);
+ "const bar$0 = require('bar');
+ const foo = bar$0.default || bar$0;"
+ `);
});
test('transform async/await is not throw an error', () => {
@@ -42,13 +42,13 @@ import Button from 'button';
compilerConfig
);
expect(result).toMatchInlineSnapshot(`
-"
-const bar$0 = require('bar');
-const foo = bar$0.default || bar$0;
-const button$0 = require('button');
-const Button = button$0.default || button$0;
-React.createElement( Button, null )"
-`);
+ "
+ const bar$0 = require('bar');
+ const foo = bar$0.default || bar$0;
+ const button$0 = require('button');
+ const Button = button$0.default || button$0;
+ React.createElement( Button, null )"
+ `);
});
test('wrap JSX in Fragment if adjacent on line 1', () => {
@@ -72,12 +72,12 @@ React.createElement( Button, null )"
compilerConfig
);
expect(result).toMatchInlineSnapshot(`
-"var foo = baz.foo;
-var bar = baz.bar;
-React.createElement( 'div', null,
- React.createElement( 'button', null, \\"Click\\" )
-)"
-`);
+ "var foo = baz.foo;
+ var bar = baz.bar;
+ React.createElement( 'div', null,
+ React.createElement( 'button', null, "Click" )
+ )"
+ `);
});
test('tagged template literals', () => {
@@ -90,11 +90,11 @@ React.createElement( 'div', null,
compilerConfig
);
expect(result).toMatchInlineSnapshot(`
-"var templateObject = Object.freeze([\\"\\\\n\\\\tcolor: tomato;\\\\n\\"]);
-var Button = styled.button(templateObject);
-React.createElement( Button, null )
-"
-`);
+ "var templateObject = Object.freeze(["\\n\\tcolor: tomato;\\n"]);
+ var Button = styled.button(templateObject);
+ React.createElement( Button, null )
+ "
+ `);
});
test('onError callback', () => {
diff --git a/src/client/utils/__tests__/renderStyleguide.spec.ts b/src/client/utils/__tests__/renderStyleguide.spec.ts
index f2f21cf85..1e2997bac 100644
--- a/src/client/utils/__tests__/renderStyleguide.spec.ts
+++ b/src/client/utils/__tests__/renderStyleguide.spec.ts
@@ -71,5 +71,5 @@ test('should remove #/ from the address bar', () => {
const historyWithSpy = { replaceState: jest.fn() };
renderStyleguide(styleguide, codeRevision, location, doc, historyWithSpy);
- expect(historyWithSpy.replaceState).toBeCalledWith('', 'My Style Guide', '/pizza?foo=bar');
+ expect(historyWithSpy.replaceState).toHaveBeenCalledWith('', 'My Style Guide', '/pizza?foo=bar');
});
diff --git a/src/loaders/__tests__/examples-loader.spec.ts b/src/loaders/__tests__/examples-loader.spec.ts
index f37105110..a7021ada2 100644
--- a/src/loaders/__tests__/examples-loader.spec.ts
+++ b/src/loaders/__tests__/examples-loader.spec.ts
@@ -38,7 +38,7 @@ text
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
});
it('should replace all occurrences of __COMPONENT__ with provided query.displayName', () => {
@@ -62,7 +62,7 @@ it('should replace all occurrences of __COMPONENT__ with provided query.displayN
expect(result).not.toMatch(/__COMPONENT__/);
const componentHtml = result.match(/(.*?)<\/div>/);
expect(componentHtml && componentHtml[0]).toMatchInlineSnapshot(
- `"
\\\\n\\\\t\\\\n\\\\t\\\\ttext\\\\n\\\\t\\\\tName of component: FooComponent\\\\n\\\\t\\\\n\\\\t\\\\n
"`
+ `"
\\n\\t\\n\\t\\ttext\\n\\t\\tName of component: FooComponent\\n\\t\\n\\t\\n
"`
);
});
@@ -83,7 +83,7 @@ it('should pass updateExample function from config to chunkify', () => {
} as any,
exampleMarkdown
);
- expect(updateExample).toBeCalledWith(
+ expect(updateExample).toHaveBeenCalledWith(
{
content: '
Hello world!',
settings: { static: true },
@@ -113,7 +113,7 @@ Two:
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
expect(result).toMatch(`'lodash': require('lodash')`);
expect(result).toMatch(`'react': require('react')`);
});
@@ -134,7 +134,7 @@ One:
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
expect(result).toMatch(`'lodash': require('lodash')`);
expect(result).toMatch(`'react': require('react')`);
});
@@ -153,7 +153,7 @@ it('should work with multiple JSX element on the root level', () => {
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
});
it('should prepend example code with React require()', () => {
@@ -167,7 +167,7 @@ it('should prepend example code with React require()', () => {
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
expect(result).toMatch(
`const React$0 = require('react');\\nconst React = React$0.default || (React$0['React'] || React$0);`
);
@@ -184,7 +184,7 @@ it('should prepend example code with component require()', () => {
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
expect(result).toMatch(
`const FooComponent$0 = require('../foo.js');\\nconst FooComponent = FooComponent$0.default || (FooComponent$0['FooComponent'] || FooComponent$0);`
);
@@ -201,7 +201,7 @@ it('should prepend example code with root component require() for sub components
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
expect(result).toMatch(
`const FooComponentSubComponent$0 = require('../fooSub.js');\\nconst FooComponentSubComponent = FooComponentSubComponent$0.default || (FooComponentSubComponent$0['FooComponentSubComponent'] || FooComponentSubComponent$0);`
);
@@ -221,7 +221,7 @@ it('should allow explicit import of React and component module', () => {
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
expect(result).toMatch(
`const React$0 = require('react');\\nconst React = React$0.default || (React$0['React'] || React$0);`
);
@@ -244,7 +244,7 @@ it('should works for any Markdown file, without a current component', () => {
);
expect(result).toBeTruthy();
- expect(() => new Function(result)).not.toThrowError(SyntaxError);
+ expect(() => new Function(result)).not.toThrow(SyntaxError);
expect(result).toMatch(
`const React$0 = require('react');\\nconst React = React$0.default || (React$0['React'] || React$0);`
);
diff --git a/src/loaders/__tests__/props-loader.spec.ts b/src/loaders/__tests__/props-loader.spec.ts
index 3d928b20c..17e0c2a8b 100644
--- a/src/loaders/__tests__/props-loader.spec.ts
+++ b/src/loaders/__tests__/props-loader.spec.ts
@@ -185,7 +185,7 @@ it('should warn if no componets are exported', () => {
expect(result).toBeTruthy();
expect(() => new vm.Script(result)).not.toThrow();
- expect(warn).toBeCalledWith(expect.stringMatching('doesn’t export a component'));
+ expect(warn).toHaveBeenCalledWith(expect.stringMatching('doesn’t export a component'));
});
it('should warn if a file cannot be parsed', () => {
@@ -203,7 +203,7 @@ it('should warn if a file cannot be parsed', () => {
expect(result).toBeTruthy();
expect(() => new vm.Script(result)).not.toThrow();
- expect(warn).toBeCalledWith(expect.stringMatching('Cannot parse'));
+ expect(warn).toHaveBeenCalledWith(expect.stringMatching('Cannot parse'));
});
it('should add context dependencies to webpack from contextDependencies config option', () => {
@@ -221,8 +221,8 @@ it('should add context dependencies to webpack from contextDependencies config o
expect(() => new vm.Script(result)).not.toThrow();
expect(addContextDependency).toHaveBeenCalledTimes(2);
- expect(addContextDependency).toBeCalledWith(contextDependencies[0]);
- expect(addContextDependency).toBeCalledWith(contextDependencies[1]);
+ expect(addContextDependency).toHaveBeenCalledWith(contextDependencies[0]);
+ expect(addContextDependency).toHaveBeenCalledWith(contextDependencies[1]);
});
it('should update the returned props object after enhancing from the updateDocs config option', () => {
diff --git a/src/loaders/__tests__/styleguide-loader.spec.ts b/src/loaders/__tests__/styleguide-loader.spec.ts
index 9a7a8ff2a..38fe8ec2d 100644
--- a/src/loaders/__tests__/styleguide-loader.spec.ts
+++ b/src/loaders/__tests__/styleguide-loader.spec.ts
@@ -167,8 +167,8 @@ it('should add context dependencies to webpack from contextDependencies config o
addContextDependency,
} as any);
expect(addContextDependency).toHaveBeenCalledTimes(2);
- expect(addContextDependency).toBeCalledWith(contextDependencies[0]);
- expect(addContextDependency).toBeCalledWith(contextDependencies[1]);
+ expect(addContextDependency).toHaveBeenCalledWith(contextDependencies[0]);
+ expect(addContextDependency).toHaveBeenCalledWith(contextDependencies[1]);
});
it('should add common parent folder of all components to context dependencies', () => {
@@ -184,7 +184,9 @@ it('should add common parent folder of all components to context dependencies',
addContextDependency,
} as any);
expect(addContextDependency).toHaveBeenCalledTimes(1);
- expect(addContextDependency).toBeCalledWith(expect.stringMatching(/test[\\/]components[\\//]$/));
+ expect(addContextDependency).toHaveBeenCalledWith(
+ expect.stringMatching(/test[\\/]components[\\//]$/)
+ );
});
it('should convert styles and themes as string into requireIt objects', () => {
diff --git a/src/loaders/utils/__tests__/__snapshots__/chunkify.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/chunkify.spec.ts.snap
index c51b1bd33..190de2d2a 100644
--- a/src/loaders/utils/__tests__/__snapshots__/chunkify.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/chunkify.spec.ts.snap
@@ -1,55 +1,55 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should even parse examples with custom extensions 1`] = `
-Array [
- Object {
+[
+ {
"content": "Custom extensions",
"type": "markdown",
},
- Object {
+ {
"content": "Example in vue",
- "settings": Object {},
+ "settings": {},
"type": "code",
},
]
`;
exports[`should parse examples settings correctly 1`] = `
-Array [
- Object {
+[
+ {
"content": "Pass props to CodeRenderer",
"type": "markdown",
},
- Object {
+ {
"content": "Hello Markdown!
",
- "settings": Object {
+ "settings": {
"showcode": true,
},
"type": "code",
},
- Object {
+ {
"content": "Example in frame and Without editor
",
- "settings": Object {
- "frame": Object {
+ "settings": {
+ "frame": {
"width": "400px",
},
},
"type": "code",
},
- Object {
+ {
"content": "Pass props to PreviewRenderer",
"type": "markdown",
},
- Object {
+ {
"content": "Hello Markdown!
",
- "settings": Object {
+ "settings": {
"noeditor": true,
},
"type": "code",
},
- Object {
+ {
"content": "\`\`\`jsx
-<h2>This is Highlighted!</h2>
+<h2>This is Highlighted!</h2>
\`\`\`",
"type": "markdown",
},
@@ -57,17 +57,17 @@ Array [
`;
exports[`should parse undefined custom extensions without throwing 1`] = `
-Array [
- Object {
+[
+ {
"content": "Undefined extensions (default)",
"type": "markdown",
},
- Object {
+ {
"content": "Example in jsx with undefined extensions",
- "settings": Object {},
+ "settings": {},
"type": "code",
},
- Object {
+ {
"content": "\`\`\`pizza
Example in pizza with undefined extensions (test double)
\`\`\`",
@@ -77,8 +77,8 @@ Array [
`;
exports[`should separate Markdown and component examples 1`] = `
-Array [
- Object {
+[
+ {
"content": "# Header
Text with *some* **formatting** and a [link](/foo).
@@ -90,42 +90,42 @@ Text with *some* **formatting** and a [link](/foo).
This code example should be rendered as a playground:",
"type": "markdown",
},
- Object {
+ {
"content": "Hello Markdown!
",
- "settings": Object {},
+ "settings": {},
"type": "code",
},
- Object {
+ {
"content": "Text with some \`code\` (playground too).",
"type": "markdown",
},
- Object {
+ {
"content": "Hello Markdown!
",
- "settings": Object {},
+ "settings": {},
"type": "code",
},
- Object {
+ {
"content": "And some language and modifier (playground again):",
"type": "markdown",
},
- Object {
+ {
"content": "Hello Markdown!
",
- "settings": Object {
+ "settings": {
"noeditor": true,
},
"type": "code",
},
- Object {
+ {
"content": "This should be just highlighted:
\`\`\`jsx
-<h4>Hello Markdown!</h4>
+<h4>Hello Markdown!</h4>
\`\`\`
This should be highlighted too:
\`\`\`html
-<h5>Hello Markdown!</h5>
+<h5>Hello Markdown!</h5>
\`\`\`",
"type": "markdown",
},
diff --git a/src/loaders/utils/__tests__/__snapshots__/filterComponentsWithExample.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/filterComponentsWithExample.spec.ts.snap
index ec927650b..962741ace 100644
--- a/src/loaders/utils/__tests__/__snapshots__/filterComponentsWithExample.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/filterComponentsWithExample.spec.ts.snap
@@ -1,36 +1,36 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should skip components without example file 1`] = `
-Array [
- Object {
- "components": Array [],
+[
+ {
+ "components": [],
"content": "Readme.md",
"name": "Readme",
- "sections": Array [],
+ "sections": [],
},
- Object {
- "components": Array [
- Object {
+ {
+ "components": [
+ {
"filepath": "components/Button/Button.js",
"hasExamples": "require()",
},
],
"name": "Components",
- "sections": Array [],
+ "sections": [],
},
- Object {
- "components": Array [],
+ {
+ "components": [],
"name": "Nesting",
- "sections": Array [
- Object {
- "components": Array [
- Object {
+ "sections": [
+ {
+ "components": [
+ {
"filepath": "components/Modal/Modal.js",
"hasExamples": "require()",
},
],
"name": "Nested",
- "sections": Array [],
+ "sections": [],
},
],
},
diff --git a/src/loaders/utils/__tests__/__snapshots__/getAst.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/getAst.spec.ts.snap
index f16d7d86c..72ff34e16 100644
--- a/src/loaders/utils/__tests__/__snapshots__/getAst.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/getAst.spec.ts.snap
@@ -1,16 +1,16 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`getAst accept Acorn plugins 1`] = `
Node {
- "body": Array [
+ "body": [
Node {
"end": 5,
"expression": Node {
- "children": Array [],
+ "children": [],
"closingElement": null,
"end": 5,
"openingElement": Node {
- "attributes": Array [],
+ "attributes": [],
"end": 5,
"name": Node {
"end": 2,
@@ -38,7 +38,7 @@ Node {
exports[`getAst return AST 1`] = `
Node {
- "body": Array [
+ "body": [
Node {
"end": 2,
"expression": Node {
diff --git a/src/loaders/utils/__tests__/__snapshots__/getComponents.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/getComponents.spec.ts.snap
index a6b700ae6..1bddf43d6 100644
--- a/src/loaders/utils/__tests__/__snapshots__/getComponents.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/getComponents.spec.ts.snap
@@ -1,29 +1,29 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`getComponents() should return an object for components 1`] = `
-Array [
- Object {
+[
+ {
"filepath": "../../Foo.js",
"hasExamples": false,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "Foo.js",
},
"pathLine": "../../Foo.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!Foo.js",
},
"slug": "foo",
},
- Object {
+ {
"filepath": "../../Bar.js",
"hasExamples": false,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "Bar.js",
},
"pathLine": "../../Bar.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!Bar.js",
},
"slug": "bar",
diff --git a/src/loaders/utils/__tests__/__snapshots__/getProps.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/getProps.spec.ts.snap
index ca826119e..8150b0fee 100644
--- a/src/loaders/utils/__tests__/__snapshots__/getProps.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/getProps.spec.ts.snap
@@ -1,25 +1,25 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should accept @return as a synonym of @returns 1`] = `
-Array [
- Object {
+[
+ {
"docblock": "
Baz method with foo param
@public
@return {string} test
",
- "returns": Object {
+ "returns": {
"description": "test",
"title": "return",
- "type": Object {
+ "type": {
"name": "string",
"type": "NameExpression",
},
},
- "tags": Object {
- "public": Array [
- Object {
+ "tags": {
+ "public": [
+ {
"description": null,
"title": "public",
"type": null,
@@ -31,25 +31,25 @@ Baz method with foo param
`;
exports[`should get method info from docblock and merge it 1`] = `
-Array [
- Object {
+[
+ {
"docblock": "
Baz method with foo param
@public
@returns {string} test
",
- "returns": Object {
+ "returns": {
"description": "test",
"title": "returns",
- "type": Object {
+ "type": {
"name": "string",
"type": "NameExpression",
},
},
- "tags": Object {
- "public": Array [
- Object {
+ "tags": {
+ "public": [
+ {
"description": null,
"title": "public",
"type": null,
@@ -61,8 +61,8 @@ Baz method with foo param
`;
exports[`should get method params info from docblock and merge it with passed method info 1`] = `
-Array [
- Object {
+[
+ {
"docblock": "
Foo method with baz param
@@ -72,50 +72,50 @@ Foo method with baz param
@argument {string} test param described with @argument tag
@returns {string} test
",
- "params": Array [
- Object {
+ "params": [
+ {
"default": "bar",
"description": null,
"name": "baz",
"title": "param",
- "type": Object {
- "expression": Object {
+ "type": {
+ "expression": {
"name": "string",
"type": "NameExpression",
},
"type": "OptionalType",
},
},
- Object {
+ {
"description": "param described with @arg tag",
"name": "foo",
"title": "arg",
- "type": Object {
+ "type": {
"name": "string",
"type": "NameExpression",
},
},
- Object {
+ {
"description": "param described with @argument tag",
"name": "test",
"title": "argument",
- "type": Object {
+ "type": {
"name": "string",
"type": "NameExpression",
},
},
],
- "returns": Object {
+ "returns": {
"description": "test",
"title": "returns",
- "type": Object {
+ "type": {
"name": "string",
"type": "NameExpression",
},
},
- "tags": Object {
- "public": Array [
- Object {
+ "tags": {
+ "public": [
+ {
"description": null,
"title": "public",
"type": null,
@@ -127,48 +127,48 @@ Foo method with baz param
`;
exports[`should highlight code in description (fenced code block) 1`] = `
-Object {
+{
"description": "The only true button.
\`\`\`js
-alert('Hello world');
+alert('Hello world');
\`\`\`
",
"displayName": "",
- "doclets": Object {},
- "methods": Array [],
- "tags": Object {},
+ "doclets": {},
+ "methods": [],
+ "tags": {},
}
`;
exports[`should not crash when using doctrine to parse a default prop that isn't in the props list 1`] = `
-Object {
+{
"description": "The only true button.
",
"displayName": "",
- "doclets": Object {},
- "methods": Array [],
- "props": Object {
- "crash": Object {
+ "doclets": {},
+ "methods": [],
+ "props": {
+ "crash": {
"description": "",
- "tags": Object {},
+ "tags": {},
},
},
- "tags": Object {},
+ "tags": {},
}
`;
exports[`should remove non-public methods 1`] = `
-Object {
+{
"displayName": "Button",
- "doclets": Object {},
- "methods": Array [
- Object {
+ "doclets": {},
+ "methods": [
+ {
"docblock": "Public method.
@public",
- "tags": Object {
- "public": Array [
- Object {
+ "tags": {
+ "public": [
+ {
"description": null,
"title": "public",
},
@@ -180,56 +180,56 @@ Object {
`;
exports[`should return an object for props 1`] = `
-Object {
+{
"description": "The only true button.
",
"displayName": "Button",
- "doclets": Object {},
- "methods": Array [],
- "props": Object {
- "children": Object {
+ "doclets": {},
+ "methods": [],
+ "props": {
+ "children": {
"description": "Button label.",
"name": "children",
"required": true,
- "tags": Object {},
- "type": Object {
+ "tags": {},
+ "type": {
"name": "object",
},
},
- "color": Object {
+ "color": {
"description": "",
"name": "color",
"required": false,
- "tags": Object {},
- "type": Object {
+ "tags": {},
+ "type": {
"name": "string",
},
},
},
- "tags": Object {},
+ "tags": {},
}
`;
exports[`should return an object for props with doclets 1`] = `
-Object {
+{
"description": "The only true button.
",
"displayName": "Button",
- "doclets": Object {
+ "doclets": {
"bar": "Bar
",
"foo": "Foo",
},
- "methods": Array [],
- "tags": Object {
- "bar": Array [
- Object {
+ "methods": [],
+ "tags": {
+ "bar": [
+ {
"description": "Bar",
"title": "bar",
},
],
- "foo": Array [
- Object {
+ "foo": [
+ {
"description": "Foo",
"title": "foo",
},
@@ -239,17 +239,17 @@ Object {
`;
exports[`should return an object for props without description 1`] = `
-Object {
+{
"displayName": "Button",
- "doclets": Object {},
- "methods": Array [],
- "props": Object {
- "children": Object {
+ "doclets": {},
+ "methods": [],
+ "props": {
+ "children": {
"description": "Button label.",
"name": "children",
"required": true,
- "tags": Object {},
- "type": Object {
+ "tags": {},
+ "type": {
"name": "object",
},
},
@@ -258,18 +258,18 @@ Object {
`;
exports[`should return require statement for @example doclet 1`] = `
-Object {
+{
"description": "The only true button.
",
"displayName": "Button",
- "doclets": Object {
+ "doclets": {
"example": "../../../test/components/Placeholder/examples.md
",
},
- "methods": Array [],
- "tags": Object {
- "example": Array [
- Object {
+ "methods": [],
+ "tags": {
+ "example": [
+ {
"description": "../../../test/components/Placeholder/examples.md",
"title": "example",
},
@@ -279,18 +279,18 @@ Object {
`;
exports[`should return require statement for @example doclet only when the file exists 1`] = `
-Object {
+{
"description": "The only true button.
",
"displayName": "Button",
- "doclets": Object {
+ "doclets": {
"example": "example.md
",
},
- "methods": Array [],
- "tags": Object {
- "example": Array [
- Object {
+ "methods": [],
+ "tags": {
+ "example": [
+ {
"description": "example.md",
"title": "example",
},
diff --git a/src/loaders/utils/__tests__/__snapshots__/getSections.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/getSections.spec.ts.snap
index 4f84edb76..bb39c6a9c 100644
--- a/src/loaders/utils/__tests__/__snapshots__/getSections.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/getSections.spec.ts.snap
@@ -1,85 +1,85 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`getSections() should return an array 1`] = `
-Array [
- Object {
- "components": Array [],
- "content": Object {
+[
+ {
+ "components": [],
+ "content": {
"require": "!!~/src/loaders/examples-loader.js!~/test/components/Button/Readme.md",
},
"exampleMode": "collapse",
"href": undefined,
"name": "Readme",
"sectionDepth": 0,
- "sections": Array [],
+ "sections": [],
"slug": "section-readme-1",
"usageMode": "collapse",
},
- Object {
- "components": Array [
- Object {
+ {
+ "components": [
+ {
"filepath": "components/Annotation/Annotation.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Annotation/Annotation.js",
},
"pathLine": "components/Annotation/Annotation.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Annotation/Annotation.js",
},
"slug": "annotation-1",
},
- Object {
+ {
"filepath": "components/Button/Button.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Button/Button.js",
},
"pathLine": "components/Button/Button.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Button/Button.js",
},
"slug": "button-2",
},
- Object {
+ {
"filepath": "components/Placeholder/Placeholder.js",
"hasExamples": true,
- "metadata": Object {
+ "metadata": {
"require": "~/test/components/Placeholder/Placeholder.json",
},
- "module": Object {
+ "module": {
"require": "~/test/components/Placeholder/Placeholder.js",
},
"pathLine": "components/Placeholder/Placeholder.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Placeholder/Placeholder.js",
},
"slug": "placeholder-2",
},
- Object {
+ {
"filepath": "components/Price/Price.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Price/Price.js",
},
"pathLine": "components/Price/Price.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Price/Price.js",
},
"slug": "price-2",
},
- Object {
+ {
"filepath": "components/RandomButton/RandomButton.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/RandomButton/RandomButton.js",
},
"pathLine": "components/RandomButton/RandomButton.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/RandomButton/RandomButton.js",
},
"slug": "randombutton-2",
@@ -90,75 +90,75 @@ Array [
"href": undefined,
"name": "Components",
"sectionDepth": 0,
- "sections": Array [],
+ "sections": [],
"slug": "section-components-1",
"usageMode": "collapse",
},
- Object {
- "components": Array [
- Object {
+ {
+ "components": [
+ {
"filepath": "components/Button/Button.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Button/Button.js",
},
"pathLine": "components/Button/Button.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Button/Button.js",
},
"slug": "button-3",
},
- Object {
+ {
"filepath": "components/Label/index.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Label/index.js",
},
"pathLine": "components/Label/index.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Label/index.js",
},
"slug": "label-1",
},
- Object {
+ {
"filepath": "components/Placeholder/Placeholder.js",
"hasExamples": true,
- "metadata": Object {
+ "metadata": {
"require": "~/test/components/Placeholder/Placeholder.json",
},
- "module": Object {
+ "module": {
"require": "~/test/components/Placeholder/Placeholder.js",
},
"pathLine": "components/Placeholder/Placeholder.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Placeholder/Placeholder.js",
},
"slug": "placeholder-3",
},
- Object {
+ {
"filepath": "components/Price/Price.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Price/Price.js",
},
"pathLine": "components/Price/Price.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Price/Price.js",
},
"slug": "price-3",
},
- Object {
+ {
"filepath": "components/RandomButton/RandomButton.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/RandomButton/RandomButton.js",
},
"pathLine": "components/RandomButton/RandomButton.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/RandomButton/RandomButton.js",
},
"slug": "randombutton-3",
@@ -170,13 +170,13 @@ Array [
"ignore": "**/components/Annotation/*",
"name": "Ignore",
"sectionDepth": 0,
- "sections": Array [],
+ "sections": [],
"slug": "section-ignore-2",
"usageMode": "collapse",
},
- Object {
- "components": Array [],
- "content": Object {
+ {
+ "components": [],
+ "content": {
"content": "Hello World",
"type": "markdown",
},
@@ -184,7 +184,7 @@ Array [
"href": undefined,
"name": "Ignore",
"sectionDepth": 0,
- "sections": Array [],
+ "sections": [],
"slug": "section-ignore-3",
"usageMode": "collapse",
},
@@ -192,71 +192,71 @@ Array [
`;
exports[`processSection() should return an object for section with components 1`] = `
-Object {
- "components": Array [
- Object {
+{
+ "components": [
+ {
"filepath": "components/Annotation/Annotation.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Annotation/Annotation.js",
},
"pathLine": "components/Annotation/Annotation.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Annotation/Annotation.js",
},
"slug": "annotation",
},
- Object {
+ {
"filepath": "components/Button/Button.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Button/Button.js",
},
"pathLine": "components/Button/Button.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Button/Button.js",
},
"slug": "button",
},
- Object {
+ {
"filepath": "components/Placeholder/Placeholder.js",
"hasExamples": true,
- "metadata": Object {
+ "metadata": {
"require": "~/test/components/Placeholder/Placeholder.json",
},
- "module": Object {
+ "module": {
"require": "~/test/components/Placeholder/Placeholder.js",
},
"pathLine": "components/Placeholder/Placeholder.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Placeholder/Placeholder.js",
},
"slug": "placeholder",
},
- Object {
+ {
"filepath": "components/Price/Price.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Price/Price.js",
},
"pathLine": "components/Price/Price.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Price/Price.js",
},
"slug": "price",
},
- Object {
+ {
"filepath": "components/RandomButton/RandomButton.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/RandomButton/RandomButton.js",
},
"pathLine": "components/RandomButton/RandomButton.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/RandomButton/RandomButton.js",
},
"slug": "randombutton",
@@ -267,32 +267,32 @@ Object {
"href": undefined,
"name": "Components",
"sectionDepth": 0,
- "sections": Array [],
+ "sections": [],
"slug": "section-components",
"usageMode": "collapse",
}
`;
exports[`processSection() should return an object for section with content 1`] = `
-Object {
- "components": Array [],
- "content": Object {
+{
+ "components": [],
+ "content": {
"require": "!!~/src/loaders/examples-loader.js!~/test/components/Button/Readme.md",
},
"exampleMode": "collapse",
"href": undefined,
"name": "Readme",
"sectionDepth": 0,
- "sections": Array [],
+ "sections": [],
"slug": "section-readme",
"usageMode": "collapse",
}
`;
exports[`processSection() should return an object for section with content as function 1`] = `
-Object {
- "components": Array [],
- "content": Object {
+{
+ "components": [],
+ "content": {
"content": "Hello World",
"type": "markdown",
},
@@ -300,78 +300,78 @@ Object {
"href": undefined,
"name": "Ignore",
"sectionDepth": 0,
- "sections": Array [],
+ "sections": [],
"slug": "section-ignore-1",
"usageMode": "collapse",
}
`;
exports[`processSection() should return an object for section without ignored components 1`] = `
-Object {
- "components": Array [
- Object {
+{
+ "components": [
+ {
"filepath": "components/Button/Button.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Button/Button.js",
},
"pathLine": "components/Button/Button.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Button/Button.js",
},
"slug": "button-1",
},
- Object {
+ {
"filepath": "components/Label/index.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Label/index.js",
},
"pathLine": "components/Label/index.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Label/index.js",
},
"slug": "label",
},
- Object {
+ {
"filepath": "components/Placeholder/Placeholder.js",
"hasExamples": true,
- "metadata": Object {
+ "metadata": {
"require": "~/test/components/Placeholder/Placeholder.json",
},
- "module": Object {
+ "module": {
"require": "~/test/components/Placeholder/Placeholder.js",
},
"pathLine": "components/Placeholder/Placeholder.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Placeholder/Placeholder.js",
},
"slug": "placeholder-1",
},
- Object {
+ {
"filepath": "components/Price/Price.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/Price/Price.js",
},
"pathLine": "components/Price/Price.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/Price/Price.js",
},
"slug": "price-1",
},
- Object {
+ {
"filepath": "components/RandomButton/RandomButton.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "~/test/components/RandomButton/RandomButton.js",
},
"pathLine": "components/RandomButton/RandomButton.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!~/test/components/RandomButton/RandomButton.js",
},
"slug": "randombutton-1",
@@ -383,7 +383,7 @@ Object {
"ignore": "**/components/Annotation/*",
"name": "Ignore",
"sectionDepth": 0,
- "sections": Array [],
+ "sections": [],
"slug": "section-ignore",
"usageMode": "collapse",
}
diff --git a/src/loaders/utils/__tests__/__snapshots__/highlightCode.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/highlightCode.spec.ts.snap
index ed824d848..d3c5b0d7f 100644
--- a/src/loaders/utils/__tests__/__snapshots__/highlightCode.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/highlightCode.spec.ts.snap
@@ -1,3 +1,3 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
-exports[`should highlight code with specified language 1`] = `"<p>Hello React</p>"`;
+exports[`should highlight code with specified language 1`] = `"<p>Hello React</p>"`;
diff --git a/src/loaders/utils/__tests__/__snapshots__/highlightCodeInMarkdown.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/highlightCodeInMarkdown.spec.ts.snap
index aa161d1e7..ba9c068fb 100644
--- a/src/loaders/utils/__tests__/__snapshots__/highlightCodeInMarkdown.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/highlightCodeInMarkdown.spec.ts.snap
@@ -1,10 +1,10 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should highlight code with specified language 1`] = `
"The only true button.
\`\`\`html
-<p>Hello React</p>
+<p>Hello React</p>
\`\`\`
"
`;
diff --git a/src/loaders/utils/__tests__/__snapshots__/processComponent.spec.ts.snap b/src/loaders/utils/__tests__/__snapshots__/processComponent.spec.ts.snap
index bf53a3f76..afb560907 100644
--- a/src/loaders/utils/__tests__/__snapshots__/processComponent.spec.ts.snap
+++ b/src/loaders/utils/__tests__/__snapshots__/processComponent.spec.ts.snap
@@ -1,15 +1,15 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`processComponent() should return an object for section with content 1`] = `
-Object {
+{
"filepath": "../../../../pizza.js",
"hasExamples": true,
- "metadata": Object {},
- "module": Object {
+ "metadata": {},
+ "module": {
"require": "pizza.js",
},
"pathLine": "../../../../pizza.js",
- "props": Object {
+ "props": {
"require": "!!~/src/loaders/props-loader.js!pizza.js",
},
"slug": "pizza",
diff --git a/src/loaders/utils/__tests__/getComponentFiles.spec.ts b/src/loaders/utils/__tests__/getComponentFiles.spec.ts
index bd9f4f2d9..14f0c12ac 100644
--- a/src/loaders/utils/__tests__/getComponentFiles.spec.ts
+++ b/src/loaders/utils/__tests__/getComponentFiles.spec.ts
@@ -4,7 +4,7 @@ import getComponentFiles from '../getComponentFiles';
const configDir = path.resolve(__dirname, '../../../../test');
const components = ['components/Annotation/Annotation.js', 'components/Button/Button.js'];
-const processedComponents = components.map(c => `~/${c}`);
+const processedComponents = components.map((c) => `~/${c}`);
const glob = 'components/**/[A-Z]*.js';
const globArray = ['components/Annotation/[A-Z]*.js', 'components/Button/[A-Z]*.js'];
@@ -21,7 +21,7 @@ it('getComponentFiles() should accept components as a function that returns file
});
it('getComponentFiles() should accept components as a function that returns absolute paths', () => {
- const absolutize = (files: string[]) => files.map(file => path.join(configDir, file));
+ const absolutize = (files: string[]) => files.map((file) => path.join(configDir, file));
const result = getComponentFiles(() => absolutize(components), configDir);
expect(deabs(result)).toEqual(processedComponents);
});
@@ -40,7 +40,7 @@ it('getComponentFiles() should accept components as an array of file names', ()
});
it('getComponentFiles() should accept components as an array of absolute paths', () => {
- const absolutize = (files: string[]) => files.map(file => path.join(configDir, file));
+ const absolutize = (files: string[]) => files.map((file) => path.join(configDir, file));
const result = getComponentFiles(absolutize(components), configDir);
expect(deabs(result)).toEqual(processedComponents);
});
@@ -85,5 +85,5 @@ it('getComponentFiles() should ignore specified patterns for globs from function
it('getComponentFiles() should throw if components is not a function, array or a string', () => {
const fn = () => getComponentFiles(42 as any, configDir);
- expect(fn).toThrowError('should be string, function or array');
+ expect(fn).toThrow('should be string, function or array');
});
diff --git a/src/loaders/utils/__tests__/getSections.spec.ts b/src/loaders/utils/__tests__/getSections.spec.ts
index 0f606fed7..961cb0d70 100644
--- a/src/loaders/utils/__tests__/getSections.spec.ts
+++ b/src/loaders/utils/__tests__/getSections.spec.ts
@@ -94,7 +94,7 @@ it('processSection() should return an object for section with content', () => {
it('processSection() should throw when content file not found', () => {
const fn = () => processSection({ content: 'pizza' }, config);
- expect(fn).toThrowError('Section content file not found');
+ expect(fn).toThrow('Section content file not found');
});
it('processSection() should return an object for section with components', () => {
@@ -151,7 +151,7 @@ it('getSections() should return an array of sectionsWithDepth with sectionDepth
it('getSections() should make custom options by user available', () => {
const result = getSections(sectionsWithDepth, config);
- const expandSection = result.find(section => section.name === 'Components');
+ const expandSection = result.find((section) => section.name === 'Components');
expect(expandSection).toHaveProperty('expand');
});
diff --git a/src/loaders/utils/__tests__/highlightCode.spec.ts b/src/loaders/utils/__tests__/highlightCode.spec.ts
index 22bf714b5..a1ae77c34 100644
--- a/src/loaders/utils/__tests__/highlightCode.spec.ts
+++ b/src/loaders/utils/__tests__/highlightCode.spec.ts
@@ -16,7 +16,7 @@ it('should warn when language not found', () => {
const actual = highlightCode(code, 'pizza');
expect(actual).toBe(code);
- expect(warn).toBeCalledWith(
+ expect(warn).toHaveBeenCalledWith(
'Syntax highlighting for “pizza” isn’t supported. Supported languages are: markup, html, mathml, svg, xml, ssml, atom, rss, css, clike, javascript, js, markdown, md, scss, less, flow, typescript, ts, jsx, tsx, graphql, json, webmanifest, bash, shell, diff.'
);
});
diff --git a/src/loaders/utils/client/__tests__/requireInRuntime.spec.js b/src/loaders/utils/client/__tests__/requireInRuntime.spec.js
index dfe65f9ca..a66f03561 100644
--- a/src/loaders/utils/client/__tests__/requireInRuntime.spec.js
+++ b/src/loaders/utils/client/__tests__/requireInRuntime.spec.js
@@ -12,5 +12,5 @@ test('return a module from the map', () => {
test('throw if module is not in the map', () => {
const fn = () => requireInRuntime(map, 'pizza');
- expect(fn).toThrowError('require() statements can be added');
+ expect(fn).toThrow('require() statements can be added');
});
diff --git a/src/scripts/__tests__/__snapshots__/make-webpack-config.spec.ts.snap b/src/scripts/__tests__/__snapshots__/make-webpack-config.spec.ts.snap
index 3ca3b9057..0b3cb2e4d 100644
--- a/src/scripts/__tests__/__snapshots__/make-webpack-config.spec.ts.snap
+++ b/src/scripts/__tests__/__snapshots__/make-webpack-config.spec.ts.snap
@@ -1,30 +1,30 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`should merge user webpack config 1`] = `
-Object {
+{
"foo": "bar",
"rsg-components": "~/src/client/rsg-components",
}
`;
exports[`should not owerwrite user DefinePlugin 1`] = `
-Array [
+[
DefinePlugin {
- "definitions": Object {
- "process.env.NODE_ENV": "\\"test\\"",
- "process.env.STYLEGUIDIST_ENV": "\\"development\\"",
+ "definitions": {
+ "process.env.NODE_ENV": ""test"",
+ "process.env.STYLEGUIDIST_ENV": ""development"",
},
},
DefinePlugin {
- "definitions": Object {
- "process.env.PIZZA": "\\"salami\\"",
+ "definitions": {
+ "process.env.PIZZA": ""salami"",
},
},
]
`;
exports[`should prepend requires as webpack entries 1`] = `
-Array [
+[
"a/b.js",
"c/d.css",
"~/src/client/index",
@@ -32,20 +32,20 @@ Array [
`;
exports[`should set aliases 1`] = `
-Object {
+{
"rsg-components": "~/src/client/rsg-components",
}
`;
exports[`should set aliases from moduleAliases option 1`] = `
-Object {
+{
"foo": "bar",
"rsg-components": "~/src/client/rsg-components",
}
`;
exports[`should set aliases from styleguideComponents option 1`] = `
-Object {
+{
"rsg-components": "~/src/client/rsg-components",
"rsg-components/foo": "bar",
}
diff --git a/src/scripts/__tests__/index.esm.spec.ts b/src/scripts/__tests__/index.esm.spec.ts
index 38455b19f..008eaf601 100644
--- a/src/scripts/__tests__/index.esm.spec.ts
+++ b/src/scripts/__tests__/index.esm.spec.ts
@@ -151,7 +151,7 @@ describe('build', () => {
const api = styleguidist(config);
api.build(callback);
- expect(callback).toBeCalled();
+ expect(callback).toHaveBeenCalled();
expect(callback.mock.calls[0][1].components).toBe(config.components);
expect(callback.mock.calls[0][2]).toEqual({ stats: true });
});
@@ -166,7 +166,7 @@ describe('server', () => {
const api = styleguidist(config);
api.server(callback);
- expect(callback).toBeCalled();
+ expect(callback).toHaveBeenCalled();
expect(callback.mock.calls[0][1].components).toBe(config.components);
});
});
diff --git a/src/scripts/__tests__/logger.spec.ts b/src/scripts/__tests__/logger.spec.ts
index 055a38324..5edcc5b2f 100644
--- a/src/scripts/__tests__/logger.spec.ts
+++ b/src/scripts/__tests__/logger.spec.ts
@@ -11,7 +11,7 @@ test('should setup custom logger function', () => {
const message = 'pizza';
setupLogger({ info }, false);
logger.info(message);
- expect(info).toBeCalledWith(message);
+ expect(info).toHaveBeenCalledWith(message);
});
test('should setup debug logger in verbose mode', () => {
@@ -19,7 +19,7 @@ test('should setup debug logger in verbose mode', () => {
const message = 'pizza';
setupLogger({ debug }, true);
logger.debug(message);
- expect(debug).toBeCalledWith(message);
+ expect(debug).toHaveBeenCalledWith(message);
});
test('should not setup debug logger in non-verbose mode', () => {
@@ -35,5 +35,5 @@ test('should accept default loggers', () => {
const message = 'pizza';
setupLogger(undefined, false, { info });
logger.info(message);
- expect(info).toBeCalledWith(message);
+ expect(info).toHaveBeenCalledWith(message);
});
diff --git a/src/scripts/__tests__/server.spec.ts b/src/scripts/__tests__/server.spec.ts
index ff0206caa..25d280468 100644
--- a/src/scripts/__tests__/server.spec.ts
+++ b/src/scripts/__tests__/server.spec.ts
@@ -16,7 +16,7 @@ test('server should return an object containing a server instance', () => {
const callback = jest.fn();
const serverInfo = server(config, callback);
- expect(callback).toBeCalled();
+ expect(callback).toHaveBeenCalled();
expect(serverInfo.app).toBeTruthy();
expect(serverInfo.compiler).toBeTruthy();
expect(typeof serverInfo.app.startCallback).toBe('function');
diff --git a/src/scripts/utils/__tests__/findFileCaseInsensitive.spec.ts b/src/scripts/utils/__tests__/findFileCaseInsensitive.spec.ts
index 8c9325e95..5800b4ba0 100644
--- a/src/scripts/utils/__tests__/findFileCaseInsensitive.spec.ts
+++ b/src/scripts/utils/__tests__/findFileCaseInsensitive.spec.ts
@@ -13,5 +13,5 @@ it('should return undefined if a file doesn’t exist', () => {
it('cache clean function shouldn’t throw', () => {
const fn = () => clearCache();
- expect(fn).not.toThrowError();
+ expect(fn).not.toThrow();
});
diff --git a/src/scripts/utils/__tests__/mergeWebpackConfig.spec.ts b/src/scripts/utils/__tests__/mergeWebpackConfig.spec.ts
index a5a1ef987..79ef77787 100644
--- a/src/scripts/utils/__tests__/mergeWebpackConfig.spec.ts
+++ b/src/scripts/utils/__tests__/mergeWebpackConfig.spec.ts
@@ -29,7 +29,7 @@ it('should pass an environment to a user config', () => {
const env = 'production';
const userConfig = jest.fn();
mergeWebpackConfig({}, userConfig, env);
- expect(userConfig).toBeCalledWith(env);
+ expect(userConfig).toHaveBeenCalledWith(env);
});
it('should ignore certain sections', () => {
@@ -40,7 +40,7 @@ it('should ignore certain sections', () => {
expect(result).toEqual({ entry: 'main', module: { rules: [] } });
});
-it('should ignore certain Webpack plugins', done => {
+it('should ignore certain Webpack plugins', (done) => {
const baseInstance = new TerserPlugin();
const userInstance = new TerserPlugin();
const result = mergeWebpackConfig(
diff --git a/src/scripts/utils/__tests__/sanitizeConfig.spec.ts b/src/scripts/utils/__tests__/sanitizeConfig.spec.ts
index ecb940d04..e8c7ebd51 100644
--- a/src/scripts/utils/__tests__/sanitizeConfig.spec.ts
+++ b/src/scripts/utils/__tests__/sanitizeConfig.spec.ts
@@ -74,7 +74,7 @@ it('should throw if required field is undefined', () => {
},
''
);
- expect(fn).toThrowError('config option is required');
+ expect(fn).toThrow('config option is required');
});
it('should throw with custom message returned by required function', () => {
@@ -88,7 +88,7 @@ it('should throw with custom message returned by required function', () => {
},
''
);
- expect(fn).toThrowError('Not good');
+ expect(fn).toThrow('Not good');
});
it('should throw when type in schema is incorrect', () => {
@@ -104,7 +104,7 @@ it('should throw when type in schema is incorrect', () => {
},
''
);
- expect(fn).toThrowError('Wrong type');
+ expect(fn).toThrow('Wrong type');
});
it('should check type for number', () => {
@@ -135,7 +135,7 @@ it('should throw when field is not a number', () => {
},
''
);
- expect(fn).toThrowError('config option should be');
+ expect(fn).toThrow('config option should be');
});
it('should check type for string', () => {
@@ -166,7 +166,7 @@ it('should throw when field is not a string', () => {
},
''
);
- expect(fn).toThrowError('config option should be');
+ expect(fn).toThrow('config option should be');
});
it('should check type for boolean', () => {
@@ -197,7 +197,7 @@ it('should throw when field is not a boolean', () => {
},
''
);
- expect(fn).toThrowError('config option should be');
+ expect(fn).toThrow('config option should be');
});
it('should check type for array', () => {
@@ -228,7 +228,7 @@ it('should throw when field is not an array', () => {
},
''
);
- expect(fn).toThrowError('config option should be');
+ expect(fn).toThrow('config option should be');
});
it('should check type for function', () => {
@@ -259,7 +259,7 @@ it('should throw when field is not a function', () => {
},
''
);
- expect(fn).toThrowError('config option should be');
+ expect(fn).toThrow('config option should be');
});
it('should check type for object', () => {
@@ -290,7 +290,7 @@ it('should throw when field is not an object', () => {
},
''
);
- expect(fn).toThrowError('config option should be');
+ expect(fn).toThrow('config option should be');
});
it('should check type for file path', () => {
@@ -336,7 +336,7 @@ it('should throw when file does not exist', () => {
},
__dirname
);
- expect(fn).toThrowError('does not exist');
+ expect(fn).toThrow('does not exist');
});
it('should check type for directory path', () => {
@@ -382,7 +382,7 @@ it('should throw with correct type name', () => {
},
''
);
- expect(fn).toThrowError('config option should be object, received null');
+ expect(fn).toThrow('config option should be object, received null');
});
it('should pass value to a custom process function', () => {
@@ -393,7 +393,7 @@ it('should pass value to a custom process function', () => {
{
food: {
type: ['boolean', 'string'],
- process: val => (val === true ? 'pizza' : val),
+ process: (val) => (val === true ? 'pizza' : val),
},
},
''
@@ -413,7 +413,7 @@ it('should not throw if process function returns value for undefined required fi
},
''
);
- expect(fn).not.toThrowError('config option is required');
+ expect(fn).not.toThrow('config option is required');
});
it('should throw when directory does not exist', () => {
@@ -429,7 +429,7 @@ it('should throw when directory does not exist', () => {
},
__dirname
);
- expect(fn).toThrowError('does not exist');
+ expect(fn).toThrow('does not exist');
});
it('should throw for unknown options', () => {
@@ -444,7 +444,7 @@ it('should throw for unknown options', () => {
},
''
);
- expect(fn).toThrowError('Unknown config option');
+ expect(fn).toThrow('Unknown config option');
});
it('should throw for unknown options with suggestion', () => {
@@ -459,7 +459,7 @@ it('should throw for unknown options with suggestion', () => {
},
''
);
- expect(fn).toThrowError('Did you mean');
+ expect(fn).toThrow('Did you mean');
});
it('should warn for deprecated options', () => {
@@ -478,7 +478,9 @@ it('should warn for deprecated options', () => {
''
);
expect(result.food).toBe('pizza');
- expect(warn).toBeCalledWith(expect.stringMatching('config option is deprecated. Don’t use!'));
+ expect(warn).toHaveBeenCalledWith(
+ expect.stringMatching('config option is deprecated. Don’t use!')
+ );
});
it('should throw for removed options', () => {
@@ -494,5 +496,5 @@ it('should throw for removed options', () => {
},
''
);
- expect(fn).toThrowError('was removed');
+ expect(fn).toThrow('was removed');
});