Browse Source

update default tests to include store mock

master
jeffvli 3 years ago
parent
commit
6dec738cbe
  1. 2
      package.json
  2. 54
      src/__tests__/App.test.tsx
  3. 19
      yarn.lock

2
package.json

@ -178,6 +178,7 @@
"@types/react-virtualized": "^9.21.13", "@types/react-virtualized": "^9.21.13",
"@types/react-virtualized-auto-sizer": "^1.0.1", "@types/react-virtualized-auto-sizer": "^1.0.1",
"@types/react-window": "^1.8.5", "@types/react-window": "^1.8.5",
"@types/redux-mock-store": "^1.0.3",
"@types/styled-components": "^5.1.12", "@types/styled-components": "^5.1.12",
"@types/webpack-env": "^1.15.2", "@types/webpack-env": "^1.15.2",
"@typescript-eslint/eslint-plugin": "^4.8.1", "@typescript-eslint/eslint-plugin": "^4.8.1",
@ -231,6 +232,7 @@
"prettier": "^2.0.5", "prettier": "^2.0.5",
"react-refresh": "^0.10.0", "react-refresh": "^0.10.0",
"react-test-renderer": "^17.0.1", "react-test-renderer": "^17.0.1",
"redux-mock-store": "^1.5.4",
"rimraf": "^3.0.0", "rimraf": "^3.0.0",
"sass-loader": "^10.1.0", "sass-loader": "^10.1.0",
"style-loader": "^2.0.0", "style-loader": "^2.0.0",

54
src/__tests__/App.test.tsx

@ -1,9 +1,59 @@
import React from 'react'; import React from 'react';
import '@testing-library/jest-dom'; import '@testing-library/jest-dom';
import { Provider } from 'react-redux';
import { Middleware, Dispatch, AnyAction } from 'redux';
import configureMockStore from 'redux-mock-store';
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';
import App from '../App'; import App from '../App';
// Remove until I can resolve mocking settings into components const middlewares:
| Middleware<Record<string, unknown>, any, Dispatch<AnyAction>>[]
| undefined = [];
const mockStore = configureMockStore(middlewares);
describe('App', () => { describe('App', () => {
it('should render', () => {}); it('Should render with dark theme', () => {
const store = mockStore({
misc: {
theme: 'defaultDark',
},
});
expect(
render(
<Provider store={store}>
<App />
</Provider>
)
).toBeTruthy();
});
it('Should render with light theme', () => {
const store = mockStore({
misc: {
theme: 'defaultLight',
},
});
expect(
render(
<Provider store={store}>
<App />
</Provider>
)
).toBeTruthy();
});
it('Should render with no theme specified', () => {
const store = mockStore({
misc: {
theme: '',
},
});
expect(
render(
<Provider store={store}>
<App />
</Provider>
)
).toBeTruthy();
});
}); });

19
yarn.lock

@ -1868,6 +1868,13 @@
"@types/prop-types" "*" "@types/prop-types" "*"
csstype "^3.0.2" csstype "^3.0.2"
"@types/redux-mock-store@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@types/redux-mock-store/-/redux-mock-store-1.0.3.tgz#895de4a364bc4836661570aec82f2eef5989d1fb"
integrity sha512-Wqe3tJa6x9MxMN4DJnMfZoBRBRak1XTPklqj4qkVm5VBpZnC8PSADf4kLuFQ9NAdHaowfWoEeUMz7NWc2GMtnA==
dependencies:
redux "^4.0.5"
"@types/responselike@*", "@types/responselike@^1.0.0": "@types/responselike@*", "@types/responselike@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29"
@ -8177,6 +8184,11 @@ lodash.isequal@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA= integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=
lodash.isplainobject@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=
lodash.memoize@4.1.2, lodash.memoize@^4.1.2: lodash.memoize@4.1.2, lodash.memoize@^4.1.2:
version "4.1.2" version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
@ -10556,6 +10568,13 @@ reduce-flatten@^2.0.0:
resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27"
integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==
redux-mock-store@^1.5.4:
version "1.5.4"
resolved "https://registry.yarnpkg.com/redux-mock-store/-/redux-mock-store-1.5.4.tgz#90d02495fd918ddbaa96b83aef626287c9ab5872"
integrity sha512-xmcA0O/tjCLXhh9Fuiq6pMrJCwFRaouA8436zcikdIpYWWCjU76CRk+i2bHx8EeiSiMGnB85/lZdU3wIJVXHTA==
dependencies:
lodash.isplainobject "^4.0.6"
redux-thunk@^2.3.0: redux-thunk@^2.3.0:
version "2.3.0" version "2.3.0"
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622" resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.3.0.tgz#51c2c19a185ed5187aaa9a2d08b666d0d6467622"

Loading…
Cancel
Save