sforkowany z mirror/soapbox
Switch to @jedmao/redux-mock-store
rodzic
2dd1631162
commit
06d3f00170
|
@ -1,3 +1,4 @@
|
||||||
|
import { configureMockStore } from '@jedmao/redux-mock-store';
|
||||||
import { render, RenderOptions } from '@testing-library/react';
|
import { render, RenderOptions } from '@testing-library/react';
|
||||||
import { merge } from 'immutable';
|
import { merge } from 'immutable';
|
||||||
import React, { FC, ReactElement } from 'react';
|
import React, { FC, ReactElement } from 'react';
|
||||||
|
@ -5,20 +6,19 @@ import { IntlProvider } from 'react-intl';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { Action, applyMiddleware, createStore } from 'redux';
|
import { Action, applyMiddleware, createStore } from 'redux';
|
||||||
import configureMockStore from 'redux-mock-store';
|
|
||||||
import thunk from 'redux-thunk';
|
import thunk from 'redux-thunk';
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
|
|
||||||
import NotificationsContainer from '../features/ui/containers/notifications_container';
|
import NotificationsContainer from '../features/ui/containers/notifications_container';
|
||||||
import { default as rootReducer } from '../reducers';
|
import { default as rootReducer } from '../reducers';
|
||||||
|
|
||||||
import type { StateRecord } from 'soapbox/reducers';
|
import type { AnyAction } from 'redux';
|
||||||
|
import type { AppDispatch } from 'soapbox/store';
|
||||||
|
|
||||||
// Mock Redux
|
// Mock Redux
|
||||||
// https://redux.js.org/recipes/writing-tests/
|
// https://redux.js.org/recipes/writing-tests/
|
||||||
const middlewares = [thunk];
|
let rootState = rootReducer(undefined, {} as Action);
|
||||||
const mockStore = configureMockStore(middlewares);
|
const mockStore = configureMockStore<typeof rootState, AnyAction, AppDispatch>([thunk]);
|
||||||
let rootState = rootReducer(undefined, {} as Action) as unknown as ReturnType<typeof StateRecord>;
|
|
||||||
|
|
||||||
/** Apply actions to the state, one at a time. */
|
/** Apply actions to the state, one at a time. */
|
||||||
const applyActions = (state: any, actions: any, reducer: any) => {
|
const applyActions = (state: any, actions: any, reducer: any) => {
|
||||||
|
|
|
@ -202,6 +202,7 @@
|
||||||
"wicg-inert": "^3.1.1"
|
"wicg-inert": "^3.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@jedmao/redux-mock-store": "^3.0.5",
|
||||||
"@testing-library/jest-dom": "^5.16.4",
|
"@testing-library/jest-dom": "^5.16.4",
|
||||||
"@testing-library/react-hooks": "^8.0.1",
|
"@testing-library/react-hooks": "^8.0.1",
|
||||||
"@testing-library/user-event": "^14.0.3",
|
"@testing-library/user-event": "^14.0.3",
|
||||||
|
@ -225,7 +226,6 @@
|
||||||
"lint-staged": ">=10",
|
"lint-staged": ">=10",
|
||||||
"raf": "^3.4.1",
|
"raf": "^3.4.1",
|
||||||
"react-intl-translations-manager": "^5.0.3",
|
"react-intl-translations-manager": "^5.0.3",
|
||||||
"redux-mock-store": "^1.5.4",
|
|
||||||
"stylelint": "^13.7.2",
|
"stylelint": "^13.7.2",
|
||||||
"stylelint-config-standard": "^22.0.0",
|
"stylelint-config-standard": "^22.0.0",
|
||||||
"stylelint-scss": "^3.18.0",
|
"stylelint-scss": "^3.18.0",
|
||||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -1603,6 +1603,11 @@
|
||||||
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98"
|
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98"
|
||||||
integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==
|
integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==
|
||||||
|
|
||||||
|
"@jedmao/redux-mock-store@^3.0.5":
|
||||||
|
version "3.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/@jedmao/redux-mock-store/-/redux-mock-store-3.0.5.tgz#015fa4fc96bfc02b61ca221d9ea0476b78c70c97"
|
||||||
|
integrity sha512-zNcVCd5/ekSMdQWk64CqTPM24D9Lo59st9KvS+fljGpQXV4SliB7Vo0NFQIgvQJWPYeeobdngnrGy0XbCaARNw==
|
||||||
|
|
||||||
"@jest/console@^27.5.1":
|
"@jest/console@^27.5.1":
|
||||||
version "27.5.1"
|
version "27.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/@jest/console/-/console-27.5.1.tgz#260fe7239602fe5130a94f1aa386eff54b014bba"
|
resolved "https://registry.yarnpkg.com/@jest/console/-/console-27.5.1.tgz#260fe7239602fe5130a94f1aa386eff54b014bba"
|
||||||
|
@ -10028,13 +10033,6 @@ redux-immutable@^4.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/redux-immutable/-/redux-immutable-4.0.0.tgz#3a1a32df66366462b63691f0e1dc35e472bbc9f3"
|
resolved "https://registry.yarnpkg.com/redux-immutable/-/redux-immutable-4.0.0.tgz#3a1a32df66366462b63691f0e1dc35e472bbc9f3"
|
||||||
integrity sha1-Ohoy32Y2ZGK2NpHw4dw15HK7yfM=
|
integrity sha1-Ohoy32Y2ZGK2NpHw4dw15HK7yfM=
|
||||||
|
|
||||||
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.2.0:
|
redux-thunk@^2.2.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"
|
||||||
|
|
Ładowanie…
Reference in New Issue