Adding Jest for testing

This commit is contained in:
Jeff Avallone 2019-01-04 18:38:49 -05:00
parent 6cff032efb
commit 8a3471b916
28 changed files with 5523 additions and 54 deletions

View File

@ -2,11 +2,13 @@
"env": { "env": {
"browser": true, "browser": true,
"es6": true, "es6": true,
"node": true "node": true,
"jest/globals": true
}, },
"extends": [ "extends": [
"eslint:recommended", "eslint:recommended",
"plugin:react/recommended" "plugin:react/recommended",
"plugin:jest/recommended"
], ],
"parser": "babel-eslint", "parser": "babel-eslint",
"parserOptions": { "parserOptions": {
@ -17,7 +19,8 @@
"sourceType": "module" "sourceType": "module"
}, },
"plugins": [ "plugins": [
"react" "react",
"jest"
], ],
"rules": { "rules": {
"indent": [ "indent": [

3
.gitignore vendored
View File

@ -21,3 +21,6 @@ node_modules/
# Gatsby build files # Gatsby build files
.cache/ .cache/
public/ public/
# Test coverage
coverage/

View File

@ -11,11 +11,20 @@ cache:
before_script: before_script:
- yarn install - yarn install
lint: test-lint:
stage: test stage: test
script: script:
- yarn test:lint - yarn test:lint
test-unit:
stage: test
coverage: '/^Statements\s*:\s*([^%]+)/'
script:
- yarn test:unit
artifacts:
paths:
- coverage/
pages: pages:
stage: build stage: build
script: script:

5
jest/preprocess.js Normal file
View File

@ -0,0 +1,5 @@
const babelOptions = {
presets: ['babel-preset-gatsby']
};
module.exports = require('babel-jest').createTransformer(babelOptions);

8
jest/setup.js Normal file
View File

@ -0,0 +1,8 @@
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
global.___loader = {
enqueue: jest.fn()
};

View File

@ -12,7 +12,9 @@
"scripts": { "scripts": {
"start": "gatsby develop", "start": "gatsby develop",
"build": "gatsby build", "build": "gatsby build",
"test:lint": "eslint --ignore-path .gitignore ." "test:lint": "eslint --ignore-path .gitignore .",
"test:unit": "jest --coverage",
"test:watch": "jest --watch"
}, },
"browserslist": [ "browserslist": [
">1%", ">1%",
@ -28,14 +30,55 @@
} }
} }
}, },
"jest": {
"clearMocks": true,
"collectCoverageFrom": [
"src/**/*.js"
],
"coverageReporters": [
"text-summary",
"html"
],
"globals": {
"__PATH_PREFIX__": ""
},
"moduleNameMapper": {
"\\.css$": "identity-obj-proxy"
},
"modulePaths": [
"src",
"node_modules"
],
"setupTestFrameworkScriptFile": "<rootDir>/jest/setup.js",
"testPathIgnorePatterns": [
"node_modules",
".cache"
],
"transform": {
"\\.js$": "<rootDir>/jest/preprocess.js"
},
"transformIgnorePatterns": [
"node_modules/(?!(gatsby)/)"
]
},
"dependencies": { "dependencies": {
"@babel/core": "^7.2.2",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-preset-gatsby": "^0.1.6",
"enzyme": "^3.8.0",
"enzyme-adapter-react-16": "^1.7.1",
"enzyme-to-json": "^3.3.5",
"eslint": "^5.11.1", "eslint": "^5.11.1",
"eslint-plugin-jest": "^22.1.2",
"eslint-plugin-react": "^7.12.1", "eslint-plugin-react": "^7.12.1",
"gatsby": "^2.0.81", "gatsby": "^2.0.81",
"gatsby-plugin-google-analytics": "^2.0.8", "gatsby-plugin-google-analytics": "^2.0.8",
"gatsby-plugin-postcss": "^2.0.2", "gatsby-plugin-postcss": "^2.0.2",
"gatsby-plugin-react-helmet": "^3.0.5", "gatsby-plugin-react-helmet": "^3.0.5",
"gatsby-plugin-sentry": "^1.0.0", "gatsby-plugin-sentry": "^1.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^23.6.0",
"postcss-cssnext": "^3.1.0", "postcss-cssnext": "^3.1.0",
"postcss-import": "^12.0.1", "postcss-import": "^12.0.1",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",

14
src/__mocks__/gatsby.js Normal file
View File

@ -0,0 +1,14 @@
const React = require('react');
const gatsby = jest.requireActual('gatsby');
module.exports = {
...gatsby,
graphql: jest.fn().mockImplementation(([query]) => query),
Link: jest.fn().mockImplementation(({ to, ...rest }) =>
React.createElement('a', {
...rest,
href: to
})
),
StaticQuery: jest.fn()
};

View File

@ -0,0 +1,469 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Footer rendering implementation 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <FooterImpl
site={
Object {
"siteMetadata": Object {
"buildId": "abc-123",
},
}
}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<ul
className="list"
>
<li>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</li>
<li>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</li>
</ul>,
<div
className="buildId"
>
abc-123
</div>,
],
"className": "footer",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<li>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</li>,
<li>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</li>,
],
"className": "list",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"Created by ",
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>,
],
},
"ref": null,
"rendered": Array [
"Created by ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Jeff Avallone",
"href": "mailto:jeff.avallone@gmail.com",
},
"ref": null,
"rendered": "Jeff Avallone",
"type": "a",
},
],
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"Generated images licensed: ",
<a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>,
],
},
"ref": null,
"rendered": Array [
"Generated images licensed: ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <img
alt="Creative Commons CC-BY-3.0 License"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>,
"href": "http://creativecommons.org/licenses/by/3.0/",
"rel": "license external noopener noreferrer",
"target": "_blank",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"alt": "Creative Commons CC-BY-3.0 License",
"src": "https://licensebuttons.net/l/by/3.0/80x15.png",
},
"ref": null,
"rendered": null,
"type": "img",
},
"type": "a",
},
],
"type": "li",
},
],
"type": "ul",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "abc-123",
"className": "buildId",
},
"ref": null,
"rendered": "abc-123",
"type": "div",
},
],
"type": "footer",
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<ul
className="list"
>
<li>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</li>
<li>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</li>
</ul>,
<div
className="buildId"
>
abc-123
</div>,
],
"className": "footer",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<li>
Created by
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>
</li>,
<li>
Generated images licensed:
<a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>
</li>,
],
"className": "list",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"Created by ",
<a
href="mailto:jeff.avallone@gmail.com"
>
Jeff Avallone
</a>,
],
},
"ref": null,
"rendered": Array [
"Created by ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Jeff Avallone",
"href": "mailto:jeff.avallone@gmail.com",
},
"ref": null,
"rendered": "Jeff Avallone",
"type": "a",
},
],
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"Generated images licensed: ",
<a
href="http://creativecommons.org/licenses/by/3.0/"
rel="license external noopener noreferrer"
target="_blank"
>
<img
alt="Creative Commons CC-BY-3.0 License"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>
</a>,
],
},
"ref": null,
"rendered": Array [
"Generated images licensed: ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <img
alt="Creative Commons CC-BY-3.0 License"
src="https://licensebuttons.net/l/by/3.0/80x15.png"
/>,
"href": "http://creativecommons.org/licenses/by/3.0/",
"rel": "license external noopener noreferrer",
"target": "_blank",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"alt": "Creative Commons CC-BY-3.0 License",
"src": "https://licensebuttons.net/l/by/3.0/80x15.png",
},
"ref": null,
"rendered": null,
"type": "img",
},
"type": "a",
},
],
"type": "li",
},
],
"type": "ul",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "abc-123",
"className": "buildId",
},
"ref": null,
"rendered": "abc-123",
"type": "div",
},
],
"type": "footer",
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`Footer rendering with query 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Footer />,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"query": "
query FooterQuery {
site {
siteMetadata {
buildId
}
}
}
",
"render": [Function],
},
"ref": null,
"rendered": null,
"type": [MockFunction],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"query": "
query FooterQuery {
site {
siteMetadata {
buildId
}
}
}
",
"render": [Function],
},
"ref": null,
"rendered": null,
"type": [MockFunction],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { StaticQuery, graphql } from 'gatsby'; import { StaticQuery, graphql } from 'gatsby';
import style from './style.module.css'; import style from './style.module.css';
@ -13,7 +14,7 @@ const query = graphql`
} }
`; `;
const Footer = () => ( export const FooterImpl = ({ site: { siteMetadata } }) => (
<footer className={ style.footer }> <footer className={ style.footer }>
<ul className={ style.list }> <ul className={ style.list }>
<li> <li>
@ -26,9 +27,21 @@ const Footer = () => (
</li> </li>
</ul> </ul>
<div className={ style.buildId }> <div className={ style.buildId }>
<StaticQuery query={ query } render={ ({ site: { siteMetadata } }) => siteMetadata.buildId } /> { siteMetadata.buildId }
</div> </div>
</footer> </footer>
); );
FooterImpl.propTypes = {
site: PropTypes.shape({
siteMetadata: PropTypes.shape({
buildId: PropTypes.string.isRequired
}).isRequired
}).isRequired
};
const Footer = () => <StaticQuery query={ query } render={ data => (
<FooterImpl { ...data } />
) } />;
export default Footer; export default Footer;

View File

@ -0,0 +1,20 @@
import React from 'react';
import { shallow } from 'enzyme';
import Footer, { FooterImpl } from 'components/Footer';
describe('Footer', () => {
test('rendering with query', () => {
const component = shallow(
<Footer />
);
expect(component).toMatchSnapshot();
});
test('rendering implementation', () => {
const component = shallow(
<FooterImpl site={{ siteMetadata: { buildId: 'abc-123' } }} />
);
expect(component).toMatchSnapshot();
});
});

View File

@ -0,0 +1,903 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Header rendering implementation 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <HeaderImpl
site={
Object {
"siteMetadata": Object {
"banner": "testing",
},
}
}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<h1>
<mockConstructor
to="/"
>
Regexper
</mockConstructor>
</h1>,
<ul
className="list"
>
<li>
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>
</li>
<li>
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
</li>
</ul>,
],
"className": "header",
"data-banner": "testing",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <mockConstructor
to="/"
>
Regexper
</mockConstructor>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Regexper",
"to": "/",
},
"ref": null,
"rendered": "Regexper",
"type": [MockFunction],
},
"type": "h1",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<li>
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>
</li>,
<li>
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
</li>,
],
"className": "list",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<Gitlab
color="currentColor"
size="24"
/>,
"Source on GitLab",
],
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
"target": "_blank",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"color": "currentColor",
"size": "24",
},
"ref": null,
"rendered": null,
"type": [Function],
},
"Source on GitLab",
],
"type": "a",
},
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"to": "/privacy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [MockFunction],
},
"type": "li",
},
],
"type": "ul",
},
],
"type": "header",
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<h1>
<mockConstructor
to="/"
>
Regexper
</mockConstructor>
</h1>,
<ul
className="list"
>
<li>
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>
</li>
<li>
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
</li>
</ul>,
],
"className": "header",
"data-banner": "testing",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <mockConstructor
to="/"
>
Regexper
</mockConstructor>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Regexper",
"to": "/",
},
"ref": null,
"rendered": "Regexper",
"type": [MockFunction],
},
"type": "h1",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<li>
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>
</li>,
<li>
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
</li>,
],
"className": "list",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<Gitlab
color="currentColor"
size="24"
/>,
"Source on GitLab",
],
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
"target": "_blank",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"color": "currentColor",
"size": "24",
},
"ref": null,
"rendered": null,
"type": [Function],
},
"Source on GitLab",
],
"type": "a",
},
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"to": "/privacy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [MockFunction],
},
"type": "li",
},
],
"type": "ul",
},
],
"type": "header",
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`Header rendering implementation with no banner 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <HeaderImpl
site={
Object {
"siteMetadata": Object {
"banner": false,
},
}
}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<h1>
<mockConstructor
to="/"
>
Regexper
</mockConstructor>
</h1>,
<ul
className="list"
>
<li>
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>
</li>
<li>
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
</li>
</ul>,
],
"className": "header",
"data-banner": null,
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <mockConstructor
to="/"
>
Regexper
</mockConstructor>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Regexper",
"to": "/",
},
"ref": null,
"rendered": "Regexper",
"type": [MockFunction],
},
"type": "h1",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<li>
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>
</li>,
<li>
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
</li>,
],
"className": "list",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<Gitlab
color="currentColor"
size="24"
/>,
"Source on GitLab",
],
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
"target": "_blank",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"color": "currentColor",
"size": "24",
},
"ref": null,
"rendered": null,
"type": [Function],
},
"Source on GitLab",
],
"type": "a",
},
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"to": "/privacy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [MockFunction],
},
"type": "li",
},
],
"type": "ul",
},
],
"type": "header",
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<h1>
<mockConstructor
to="/"
>
Regexper
</mockConstructor>
</h1>,
<ul
className="list"
>
<li>
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>
</li>
<li>
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
</li>
</ul>,
],
"className": "header",
"data-banner": null,
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <mockConstructor
to="/"
>
Regexper
</mockConstructor>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Regexper",
"to": "/",
},
"ref": null,
"rendered": "Regexper",
"type": [MockFunction],
},
"type": "h1",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<li>
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>
</li>,
<li>
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
</li>,
],
"className": "list",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
<Gitlab
color="currentColor"
size="24"
/>
Source on GitLab
</a>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<Gitlab
color="currentColor"
size="24"
/>,
"Source on GitLab",
],
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
"target": "_blank",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"color": "currentColor",
"size": "24",
},
"ref": null,
"rendered": null,
"type": [Function],
},
"Source on GitLab",
],
"type": "a",
},
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"to": "/privacy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [MockFunction],
},
"type": "li",
},
],
"type": "ul",
},
],
"type": "header",
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`Header rendering with query 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Header />,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"query": "
query HeaderQuery {
site {
siteMetadata {
banner
}
}
}
",
"render": [Function],
},
"ref": null,
"rendered": null,
"type": [MockFunction],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"query": "
query HeaderQuery {
site {
siteMetadata {
banner
}
}
}
",
"render": [Function],
},
"ref": null,
"rendered": null,
"type": [MockFunction],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { Link, StaticQuery, graphql } from 'gatsby'; import { Link, StaticQuery, graphql } from 'gatsby';
import GitlabIcon from 'react-feather/dist/icons/gitlab'; import GitlabIcon from 'react-feather/dist/icons/gitlab';
@ -15,7 +16,7 @@ const query = graphql`
} }
`; `;
const Header = () => <StaticQuery query={ query } render={ ({ site: { siteMetadata } }) => ( export const HeaderImpl = ({ site: { siteMetadata } }) => (
<header className={ style.header } data-banner={ siteMetadata.banner || null }> <header className={ style.header } data-banner={ siteMetadata.banner || null }>
<h1> <h1>
<Link to="/">Regexper</Link> <Link to="/">Regexper</Link>
@ -33,6 +34,21 @@ const Header = () => <StaticQuery query={ query } render={ ({ site: { siteMetada
</li> </li>
</ul> </ul>
</header> </header>
);
HeaderImpl.propTypes = {
site: PropTypes.shape({
siteMetadata: PropTypes.shape({
banner: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string
]).isRequired
}).isRequired
}).isRequired
};
const Header = () => <StaticQuery query={ query } render={ data => (
<HeaderImpl { ...data } />
) } />; ) } />;
export default Header; export default Header;

View File

@ -0,0 +1,27 @@
import React from 'react';
import { shallow } from 'enzyme';
import Header, { HeaderImpl } from 'components/Header';
describe('Header', () => {
test('rendering with query', () => {
const component = shallow(
<Header />
);
expect(component).toMatchSnapshot();
});
test('rendering implementation', () => {
const component = shallow(
<HeaderImpl site={{ siteMetadata: { banner: 'testing' } }} />
);
expect(component).toMatchSnapshot();
});
test('rendering implementation with no banner', () => {
const component = shallow(
<HeaderImpl site={{ siteMetadata: { banner: false } }} />
);
expect(component).toMatchSnapshot();
});
});

View File

@ -0,0 +1,395 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Layout rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Layout>
Example content
</Layout>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
>
<title>
Regexper
</title>
</HelmetWrapper>,
<Header />,
<SentryBoundary>
Example content
</SentryBoundary>,
<Footer />,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": <title>
Regexper
</title>,
"defer": true,
"encodeSpecialCharacters": true,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Regexper",
},
"ref": null,
"rendered": "Regexper",
"type": "title",
},
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Example content",
},
"ref": null,
"rendered": "Example content",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
>
<title>
Regexper
</title>
</HelmetWrapper>,
<Header />,
<SentryBoundary>
Example content
</SentryBoundary>,
<Footer />,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": <title>
Regexper
</title>,
"defer": true,
"encodeSpecialCharacters": true,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Regexper",
},
"ref": null,
"rendered": "Regexper",
"type": "title",
},
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Example content",
},
"ref": null,
"rendered": "Example content",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`Layout rendering with a title 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Layout
title="Testing"
>
Example content
</Layout>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
>
<title>
Regexper - Testing
</title>
</HelmetWrapper>,
<Header />,
<SentryBoundary>
Example content
</SentryBoundary>,
<Footer />,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": <title>
Regexper - Testing
</title>,
"defer": true,
"encodeSpecialCharacters": true,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Regexper - Testing",
},
"ref": null,
"rendered": "Regexper - Testing",
"type": "title",
},
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Example content",
},
"ref": null,
"rendered": "Example content",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": Array [
<HelmetWrapper
defer={true}
encodeSpecialCharacters={true}
>
<title>
Regexper - Testing
</title>
</HelmetWrapper>,
<Header />,
<SentryBoundary>
Example content
</SentryBoundary>,
<Footer />,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": <title>
Regexper - Testing
</title>,
"defer": true,
"encodeSpecialCharacters": true,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Regexper - Testing",
},
"ref": null,
"rendered": "Regexper - Testing",
"type": "title",
},
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Example content",
},
"ref": null,
"rendered": "Example content",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
],
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

View File

@ -0,0 +1,24 @@
import React from 'react';
import { shallow } from 'enzyme';
import Layout from 'components/Layout';
describe('Layout', () => {
test('rendering', () => {
const component = shallow(
<Layout>
Example content
</Layout>
);
expect(component).toMatchSnapshot();
});
test('rendering with a title', () => {
const component = shallow(
<Layout title="Testing">
Example content
</Layout>
);
expect(component).toMatchSnapshot();
});
});

View File

@ -0,0 +1,669 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Message rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Message
heading="Testing"
>
<p>
Message content
</p>
</Message>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<div
className="header"
>
<h2>
Testing
</h2>
</div>,
<div
className="content"
>
<p>
Message content
</p>
</div>,
],
"className": "message",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
undefined,
<h2>
Testing
</h2>,
],
"className": "header",
},
"ref": null,
"rendered": Array [
undefined,
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Testing",
},
"ref": null,
"rendered": "Testing",
"type": "h2",
},
],
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <p>
Message content
</p>,
"className": "content",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Message content",
},
"ref": null,
"rendered": "Message content",
"type": "p",
},
"type": "div",
},
],
"type": "div",
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<div
className="header"
>
<h2>
Testing
</h2>
</div>,
<div
className="content"
>
<p>
Message content
</p>
</div>,
],
"className": "message",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
undefined,
<h2>
Testing
</h2>,
],
"className": "header",
},
"ref": null,
"rendered": Array [
undefined,
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Testing",
},
"ref": null,
"rendered": "Testing",
"type": "h2",
},
],
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <p>
Message content
</p>,
"className": "content",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Message content",
},
"ref": null,
"rendered": "Message content",
"type": "p",
},
"type": "div",
},
],
"type": "div",
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`Message rendering with icon 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Message
heading="Testing"
icon={[Function]}
>
<p>
Message content
</p>
</Message>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<div
className="header"
>
<Icon />
<h2>
Testing
</h2>
</div>,
<div
className="content"
>
<p>
Message content
</p>
</div>,
],
"className": "message",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<Icon />,
<h2>
Testing
</h2>,
],
"className": "header",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Testing",
},
"ref": null,
"rendered": "Testing",
"type": "h2",
},
],
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <p>
Message content
</p>,
"className": "content",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Message content",
},
"ref": null,
"rendered": "Message content",
"type": "p",
},
"type": "div",
},
],
"type": "div",
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<div
className="header"
>
<Icon />
<h2>
Testing
</h2>
</div>,
<div
className="content"
>
<p>
Message content
</p>
</div>,
],
"className": "message",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<Icon />,
<h2>
Testing
</h2>,
],
"className": "header",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Testing",
},
"ref": null,
"rendered": "Testing",
"type": "h2",
},
],
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <p>
Message content
</p>,
"className": "content",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Message content",
},
"ref": null,
"rendered": "Message content",
"type": "p",
},
"type": "div",
},
],
"type": "div",
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`Message rendering with type 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Message
heading="Testing"
type="error"
>
<p>
Message content
</p>
</Message>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<div
className="header"
>
<AlertOctagon
color="currentColor"
size="24"
/>
<h2>
Testing
</h2>
</div>,
<div
className="content"
>
<p>
Message content
</p>
</div>,
],
"className": "message error",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<AlertOctagon
color="currentColor"
size="24"
/>,
<h2>
Testing
</h2>,
],
"className": "header",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"color": "currentColor",
"size": "24",
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Testing",
},
"ref": null,
"rendered": "Testing",
"type": "h2",
},
],
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <p>
Message content
</p>,
"className": "content",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Message content",
},
"ref": null,
"rendered": "Message content",
"type": "p",
},
"type": "div",
},
],
"type": "div",
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<div
className="header"
>
<AlertOctagon
color="currentColor"
size="24"
/>
<h2>
Testing
</h2>
</div>,
<div
className="content"
>
<p>
Message content
</p>
</div>,
],
"className": "message error",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<AlertOctagon
color="currentColor"
size="24"
/>,
<h2>
Testing
</h2>,
],
"className": "header",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"color": "currentColor",
"size": "24",
},
"ref": null,
"rendered": null,
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Testing",
},
"ref": null,
"rendered": "Testing",
"type": "h2",
},
],
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <p>
Message content
</p>,
"className": "content",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Message content",
},
"ref": null,
"rendered": "Message content",
"type": "p",
},
"type": "div",
},
],
"type": "div",
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

View File

@ -0,0 +1,34 @@
import React from 'react';
import { shallow } from 'enzyme';
import Message from 'components/Message';
describe('Message', () => {
test('rendering', () => {
const component = shallow(
<Message heading="Testing">
<p>Message content</p>
</Message>
);
expect(component).toMatchSnapshot();
});
test('rendering with icon', () => {
const Icon = () => 'Sample icon SVG';
const component = shallow(
<Message heading="Testing" icon={ Icon }>
<p>Message content</p>
</Message>
);
expect(component).toMatchSnapshot();
});
test('rendering with type', () => {
const component = shallow(
<Message heading="Testing" type="error">
<p>Message content</p>
</Message>
);
expect(component).toMatchSnapshot();
});
});

View File

@ -0,0 +1,147 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SentryBoundary error handling 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <SentryBoundary>
<Child />
</SentryBoundary>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`SentryBoundary error handling 2`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <SentryBoundary>
<Child />
</SentryBoundary>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {},
"ref": null,
"rendered": null,
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;
exports[`SentryBoundary rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <SentryBoundary>
Example content
</SentryBoundary>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): "Example content",
Symbol(enzyme.__nodes__): Array [
"Example content",
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

View File

@ -0,0 +1,35 @@
jest.mock('@sentry/browser');
import React from 'react';
import { shallow } from 'enzyme';
import * as Sentry from '@sentry/browser';
import SentryBoundary from 'components/SentryBoundary';
describe('SentryBoundary', () => {
test('rendering', () => {
const component = shallow(
<SentryBoundary>
Example content
</SentryBoundary>
);
expect(component).toMatchSnapshot();
});
test('error handling', () => {
const Child = () => 'Example content';
const component = shallow(
<SentryBoundary>
<Child />
</SentryBoundary>
);
expect(component).toMatchSnapshot();
const error = new Error('Example error');
component.find('Child').simulateError(error);
component.setState({ hasError: true }); // NOTE: Enzyme doesn't call getDerivedStateFromError yet
expect(Sentry.captureException).toHaveBeenCalledWith(error, expect.anything());
expect(component).toMatchSnapshot();
});
});

View File

@ -0,0 +1,149 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SentryError rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <SentryError />,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <p>
This error has been logged. You may also
<a
href="#error-report"
onClick={[Function]}
>
fill out a report
</a>
.
</p>,
"heading": "An error has occurred",
"type": "error",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"This error has been logged. You may also ",
<a
href="#error-report"
onClick={[Function]}
>
fill out a report
</a>,
".",
],
},
"ref": null,
"rendered": Array [
"This error has been logged. You may also ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "fill out a report",
"href": "#error-report",
"onClick": [Function],
},
"ref": null,
"rendered": "fill out a report",
"type": "a",
},
".",
],
"type": "p",
},
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <p>
This error has been logged. You may also
<a
href="#error-report"
onClick={[Function]}
>
fill out a report
</a>
.
</p>,
"heading": "An error has occurred",
"type": "error",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"This error has been logged. You may also ",
<a
href="#error-report"
onClick={[Function]}
>
fill out a report
</a>,
".",
],
},
"ref": null,
"rendered": Array [
"This error has been logged. You may also ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "fill out a report",
"href": "#error-report",
"onClick": [Function],
},
"ref": null,
"rendered": "fill out a report",
"type": "a",
},
".",
],
"type": "p",
},
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

View File

@ -0,0 +1,42 @@
jest.mock('@sentry/browser');
import React from 'react';
import { shallow } from 'enzyme';
import * as Sentry from '@sentry/browser';
import SentryError from 'components/SentryError';
describe('SentryError', () => {
test('rendering', () => {
const component = shallow(
<SentryError />
);
expect(component).toMatchSnapshot();
});
describe('error reporting', () => {
test('clicking to fill out a report when an event has been logged', () => {
Sentry.lastEventId.mockReturnValue(1);
const component = shallow(
<SentryError />
);
const eventObj = { preventDefault: jest.fn() };
component.find('a').simulate('click', eventObj);
expect(eventObj.preventDefault).toHaveBeenCalled();
expect(Sentry.showReportDialog).toHaveBeenCalled();
});
test('clicking to fill out a report when an event has not been logged', () => {
Sentry.lastEventId.mockReturnValue(false);
const component = shallow(
<SentryError />
);
const eventObj = { preventDefault: jest.fn() };
component.find('a').simulate('click', eventObj);
expect(eventObj.preventDefault).toHaveBeenCalled();
expect(Sentry.showReportDialog).not.toHaveBeenCalled();
});
});
});

13
src/pages/404.test.js Normal file
View File

@ -0,0 +1,13 @@
import React from 'react';
import { shallow } from 'enzyme';
import ErrorPage from 'pages/404';
describe('Error Page', () => {
test('rendering', () => {
const component = shallow(
<ErrorPage />
);
expect(component).toMatchSnapshot();
});
});

View File

@ -0,0 +1,121 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Error Page rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <ErrorPage />,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <Message
heading="404 Page Not Found"
type="error"
>
<p>
The page you have requrested could not be found.
</p>
</Message>,
"title": "Page Not Found",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <p>
The page you have requrested could not be found.
</p>,
"heading": "404 Page Not Found",
"type": "error",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "The page you have requrested could not be found.",
},
"ref": null,
"rendered": "The page you have requrested could not be found.",
"type": "p",
},
"type": [Function],
},
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <Message
heading="404 Page Not Found"
type="error"
>
<p>
The page you have requrested could not be found.
</p>
</Message>,
"title": "Page Not Found",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <p>
The page you have requrested could not be found.
</p>,
"heading": "404 Page Not Found",
"type": "error",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "The page you have requrested could not be found.",
},
"ref": null,
"rendered": "The page you have requrested could not be found.",
"type": "p",
},
"type": [Function],
},
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

View File

@ -0,0 +1,323 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Index Page rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <IndexPage />,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<noscript>
<Message
heading="JavaScript Required"
type="error"
>
<p>
You need JavaScript to use Regexper.
</p>
<p>
If you have concerns regarding the use of tracking code on Regexper, please see the
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
.
</p>
</Message>
</noscript>,
<div>
Hello world
</div>,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <Message
heading="JavaScript Required"
type="error"
>
<p>
You need JavaScript to use Regexper.
</p>
<p>
If you have concerns regarding the use of tracking code on Regexper, please see the
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
.
</p>
</Message>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<p>
You need JavaScript to use Regexper.
</p>,
<p>
If you have concerns regarding the use of tracking code on Regexper, please see the
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
.
</p>,
],
"heading": "JavaScript Required",
"type": "error",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "You need JavaScript to use Regexper.",
},
"ref": null,
"rendered": "You need JavaScript to use Regexper.",
"type": "p",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"If you have concerns regarding the use of tracking code on Regexper, please see the ",
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>,
".",
],
},
"ref": null,
"rendered": Array [
"If you have concerns regarding the use of tracking code on Regexper, please see the ",
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"to": "/privacy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [MockFunction],
},
".",
],
"type": "p",
},
],
"type": [Function],
},
"type": "noscript",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Hello world",
},
"ref": null,
"rendered": "Hello world",
"type": "div",
},
],
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<noscript>
<Message
heading="JavaScript Required"
type="error"
>
<p>
You need JavaScript to use Regexper.
</p>
<p>
If you have concerns regarding the use of tracking code on Regexper, please see the
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
.
</p>
</Message>
</noscript>,
<div>
Hello world
</div>,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <Message
heading="JavaScript Required"
type="error"
>
<p>
You need JavaScript to use Regexper.
</p>
<p>
If you have concerns regarding the use of tracking code on Regexper, please see the
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
.
</p>
</Message>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<p>
You need JavaScript to use Regexper.
</p>,
<p>
If you have concerns regarding the use of tracking code on Regexper, please see the
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>
.
</p>,
],
"heading": "JavaScript Required",
"type": "error",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "You need JavaScript to use Regexper.",
},
"ref": null,
"rendered": "You need JavaScript to use Regexper.",
"type": "p",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"If you have concerns regarding the use of tracking code on Regexper, please see the ",
<mockConstructor
to="/privacy"
>
Privacy Policy
</mockConstructor>,
".",
],
},
"ref": null,
"rendered": Array [
"If you have concerns regarding the use of tracking code on Regexper, please see the ",
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": "Privacy Policy",
"to": "/privacy",
},
"ref": null,
"rendered": "Privacy Policy",
"type": [MockFunction],
},
".",
],
"type": "p",
},
],
"type": [Function],
},
"type": "noscript",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Hello world",
},
"ref": null,
"rendered": "Hello world",
"type": "div",
},
],
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

View File

@ -0,0 +1,643 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Privacy Page rendering 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <PrivacyPage />,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateError": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <Message
heading="Privacy Policy"
type="info"
>
<p>
Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
GitLab repository
</a>
.
</p>
<p>
There are two data collection tools integrated in the app. These tools are not used to collect personal information:
</p>
<ul>
<li>
<b>
Google Analytics
</b>
is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
</li>
<li>
<b>
Sentry.io
</b>
is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
</li>
</ul>
<p>
Regexper honors the browser
<b>
“Do Not Track”
</b>
setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will
<b>
not
</b>
impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.
</p>
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>
</Message>,
"title": "Privacy Policy",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<p>
Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
GitLab repository
</a>
.
</p>,
<p>
There are two data collection tools integrated in the app. These tools are not used to collect personal information:
</p>,
<ul>
<li>
<b>
Google Analytics
</b>
is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
</li>
<li>
<b>
Sentry.io
</b>
is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
</li>
</ul>,
<p>
Regexper honors the browser
<b>
“Do Not Track”
</b>
setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will
<b>
not
</b>
impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.
</p>,
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>,
],
"heading": "Privacy Policy",
"type": "info",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the ",
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
GitLab repository
</a>,
".",
],
},
"ref": null,
"rendered": Array [
"Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "GitLab repository",
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
"target": "_blank",
},
"ref": null,
"rendered": "GitLab repository",
"type": "a",
},
".",
],
"type": "p",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "There are two data collection tools integrated in the app. These tools are not used to collect personal information:",
},
"ref": null,
"rendered": "There are two data collection tools integrated in the app. These tools are not used to collect personal information:",
"type": "p",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<li>
<b>
Google Analytics
</b>
is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
</li>,
<li>
<b>
Sentry.io
</b>
is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
</li>,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<b>
Google Analytics
</b>,
" is used to track browser usage data and application performance. It is configured to anonymize the client IP address.",
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Google Analytics",
},
"ref": null,
"rendered": "Google Analytics",
"type": "b",
},
" is used to track browser usage data and application performance. It is configured to anonymize the client IP address.",
],
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<b>
Sentry.io
</b>,
" is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.",
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Sentry.io",
},
"ref": null,
"rendered": "Sentry.io",
"type": "b",
},
" is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.",
],
"type": "li",
},
],
"type": "ul",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"Regexper honors the browser ",
<b>
“Do Not Track”
</b>,
" setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will ",
<b>
not
</b>,
" impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.",
],
},
"ref": null,
"rendered": Array [
"Regexper honors the browser ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "“Do Not Track”",
},
"ref": null,
"rendered": "“Do Not Track”",
"type": "b",
},
" setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "not",
},
"ref": null,
"rendered": "not",
"type": "b",
},
" impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.",
],
"type": "p",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Regexper is not supported by ad revenue or sales of any kind.",
},
"ref": null,
"rendered": "Regexper is not supported by ad revenue or sales of any kind.",
"type": "p",
},
],
"type": [Function],
},
"type": [Function],
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": <Message
heading="Privacy Policy"
type="info"
>
<p>
Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
GitLab repository
</a>
.
</p>
<p>
There are two data collection tools integrated in the app. These tools are not used to collect personal information:
</p>
<ul>
<li>
<b>
Google Analytics
</b>
is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
</li>
<li>
<b>
Sentry.io
</b>
is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
</li>
</ul>
<p>
Regexper honors the browser
<b>
“Do Not Track”
</b>
setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will
<b>
not
</b>
impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.
</p>
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>
</Message>,
"title": "Privacy Policy",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<p>
Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
GitLab repository
</a>
.
</p>,
<p>
There are two data collection tools integrated in the app. These tools are not used to collect personal information:
</p>,
<ul>
<li>
<b>
Google Analytics
</b>
is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
</li>
<li>
<b>
Sentry.io
</b>
is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
</li>
</ul>,
<p>
Regexper honors the browser
<b>
“Do Not Track”
</b>
setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will
<b>
not
</b>
impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.
</p>,
<p>
Regexper is not supported by ad revenue or sales of any kind.
</p>,
],
"heading": "Privacy Policy",
"type": "info",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the ",
<a
href="https://gitlab.com/javallone/regexper-static"
rel="external noopener noreferrer"
target="_blank"
>
GitLab repository
</a>,
".",
],
},
"ref": null,
"rendered": Array [
"Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "GitLab repository",
"href": "https://gitlab.com/javallone/regexper-static",
"rel": "external noopener noreferrer",
"target": "_blank",
},
"ref": null,
"rendered": "GitLab repository",
"type": "a",
},
".",
],
"type": "p",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "There are two data collection tools integrated in the app. These tools are not used to collect personal information:",
},
"ref": null,
"rendered": "There are two data collection tools integrated in the app. These tools are not used to collect personal information:",
"type": "p",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<li>
<b>
Google Analytics
</b>
is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
</li>,
<li>
<b>
Sentry.io
</b>
is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
</li>,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<b>
Google Analytics
</b>,
" is used to track browser usage data and application performance. It is configured to anonymize the client IP address.",
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Google Analytics",
},
"ref": null,
"rendered": "Google Analytics",
"type": "b",
},
" is used to track browser usage data and application performance. It is configured to anonymize the client IP address.",
],
"type": "li",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<b>
Sentry.io
</b>,
" is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.",
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Sentry.io",
},
"ref": null,
"rendered": "Sentry.io",
"type": "b",
},
" is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.",
],
"type": "li",
},
],
"type": "ul",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
"Regexper honors the browser ",
<b>
“Do Not Track”
</b>,
" setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will ",
<b>
not
</b>,
" impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.",
],
},
"ref": null,
"rendered": Array [
"Regexper honors the browser ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "“Do Not Track”",
},
"ref": null,
"rendered": "“Do Not Track”",
"type": "b",
},
" setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will ",
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "not",
},
"ref": null,
"rendered": "not",
"type": "b",
},
" impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.",
],
"type": "p",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Regexper is not supported by ad revenue or sales of any kind.",
},
"ref": null,
"rendered": "Regexper is not supported by ad revenue or sales of any kind.",
"type": "p",
},
],
"type": [Function],
},
"type": [Function],
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getDerivedStateFromProps": true,
"getSnapshotBeforeUpdate": true,
"setState": Object {
"skipsComponentDidUpdateOnNullish": true,
},
},
},
},
},
}
`;

13
src/pages/index.test.js Normal file
View File

@ -0,0 +1,13 @@
import React from 'react';
import { shallow } from 'enzyme';
import IndexPage from 'pages/index';
describe('Index Page', () => {
test('rendering', () => {
const component = shallow(
<IndexPage />
);
expect(component).toMatchSnapshot();
});
});

13
src/pages/privacy.test.js Normal file
View File

@ -0,0 +1,13 @@
import React from 'react';
import { shallow } from 'enzyme';
import PrivacyPage from 'pages/privacy';
describe('Privacy Page', () => {
test('rendering', () => {
const component = shallow(
<PrivacyPage />
);
expect(component).toMatchSnapshot();
});
});

1399
yarn.lock

File diff suppressed because it is too large Load Diff