Skip to content

Commit

Permalink
Remove deprecated redux-mock-store dep
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarnakken committed Oct 30, 2024
1 parent dc25271 commit a4a1513
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 31 deletions.
46 changes: 33 additions & 13 deletions app/components/Comments/__tests__/CommentTree.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
import { configureStore } from '@reduxjs/toolkit';
import { mount, shallow } from 'enzyme';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import configureStore from 'redux-mock-store';
import { describe, it, expect } from 'vitest';
import createRootReducer from 'app/store/createRootReducer';
import { generateTreeStructure } from 'app/utils';
import CommentTree from '../CommentTree';
import comments from './fixtures/comments';

const store = configureStore([])({
theme: {
theme: 'light',
},
auth: {},
users: {
entities: {},
},
emojis: {
ids: [],
entities: {},
const store = configureStore({
reducer: createRootReducer(),
preloadedState: {
theme: {
theme: 'light',
},
auth: {
id: 1,
username: 'webkom',
token: 'token',
loginFailed: false,
loggingIn: false,
registrationToken: null,
studentConfirmed: true,
},
users: {
ids: [],
entities: {},
actionGrant: ['view'],
fetching: false,
paginationNext: {},
},
emojis: {
ids: [],
entities: {},
actionGrant: ['view'],
fetching: false,
paginationNext: {},
},
},
middleware: (getDefaultMiddleware) => getDefaultMiddleware(),
});

describe('<CommentTree />', () => {
Expand All @@ -43,6 +63,6 @@ describe('<CommentTree />', () => {
const rootElements = wrapper.find('[data-ischild=false]');
const rootElement = rootElements.at(1);
const childTree = rootElement.find('[data-ischild=true]');
expect(childTree.text()).toMatch(comments[2].text);
expect(childTree.text()).toMatch(comments[2].text ?? '');
});
});
11 changes: 6 additions & 5 deletions app/components/LoginForm/LoginForm.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { configureStore } from '@reduxjs/toolkit';
import { mount } from 'enzyme';
import { Field } from 'react-final-form';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import { describe, it, expect } from 'vitest';
import createRootReducer from 'app/store/createRootReducer';
import LoginForm from './LoginForm';

describe('components', () => {
describe('LoginForm', () => {
it('should render correctly', () => {
const login = () => {};
const store = configureStore({
reducer: createRootReducer(),
middleware: (getDefaultMiddleware) => getDefaultMiddleware(),
});

const mockStore = configureStore();
const store = mockStore();
const wrapper = mount(
<Provider
{...{
Expand All @@ -22,7 +24,6 @@ describe('components', () => {
</Provider>,
);
const form = wrapper.find('form');
expect(form.hasClass('LoginForm')).toBe(true);
const username = form.childAt(0);
const password = form.childAt(1);
expect(username.type()).toEqual(Field);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
"prettier": "3.3.3",
"process": "^0.11.10",
"react-refresh": "^0.14.2",
"redux-mock-store": "^1.5.4",
"style-loader": "^4.0.0",
"stylelint": "^15.10.1",
"stylelint-config-standard": "^34.0.0",
Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9571,11 +9571,6 @@ lodash.isequal@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==

lodash.isplainobject@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
integrity sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==

lodash.memoize@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
Expand Down Expand Up @@ -11738,13 +11733,6 @@ redux-logger@^3.0.1:
dependencies:
deep-diff "^0.3.5"

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-sentry-middleware@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/redux-sentry-middleware/-/redux-sentry-middleware-0.2.2.tgz#79140377b4fa6a606797cb2a13cc1b8ab7d68cec"
Expand Down

0 comments on commit a4a1513

Please sign in to comment.