Skip to content

Commit

Permalink
feat(redux): redux 5 compatible (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
JAdshead committed Feb 1, 2024
1 parent 0f6b849 commit e23b819
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 12 deletions.
17 changes: 17 additions & 0 deletions __tests__/__snapshots__/immutable.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ Immutable.Map {

exports[`vitruviusImmutable should handle no reducers having buildInitialState method 1`] = `Immutable.Map {}`;

exports[`vitruviusImmutable should return an initialState that is acceptable to redux toolkit's configureStore 1`] = `
Immutable.Map {
"stuff": Immutable.Map {
"foo": "bar",
},
"things": Immutable.Map {
"bar": "baz",
},
"other": Immutable.Map {
"baz": "foo",
},
"static": Immutable.Map {
"static": true,
},
}
`;

exports[`vitruviusImmutable should return an initialState that is acceptable to redux's createStore 1`] = `
Immutable.Map {
"stuff": Immutable.Map {
Expand Down
17 changes: 17 additions & 0 deletions __tests__/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ exports[`vitruvius should handle all reducers having buildInitialState method 1`

exports[`vitruvius should handle no reducers having buildInitialState method 1`] = `{}`;

exports[`vitruvius should return an initialState that is acceptable to redux toolkit's configureStore 1`] = `
{
"other": Immutable.Map {
"baz": "foo",
},
"static": Immutable.Map {
"static": true,
},
"stuff": Immutable.Map {
"foo": "bar",
},
"things": Immutable.Map {
"bar": "baz",
},
}
`;

exports[`vitruvius should return an initialState that is acceptable to redux's createStore 1`] = `
{
"other": Immutable.Map {
Expand Down
15 changes: 14 additions & 1 deletion __tests__/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
/* eslint-disable jest/no-export -- not a test file */
/* eslint-disable default-param-last -- avoiding rewrite */
import { Map } from 'immutable';
import { createStore } from 'redux';
import { legacy_createStore as createStore } from 'redux';
import { configureStore } from '@reduxjs/toolkit';

export const SOME_ACTION = 'SOME_ACTION';

Expand Down Expand Up @@ -135,6 +136,18 @@ export function runVitruviusTests(describeSpec, vitruvius) {
const actual = store.getState();
expect(actual).toMatchSnapshot();
});

it('should return an initialState that is acceptable to redux toolkit\'s configureStore', () => {
const reducer = vitruvius({
stuff: stuffReducer,
things: thingsReducer,
other: otherReducer,
static: staticReducer,
});
const store = configureStore({ reducer }, reducer.buildInitialState(locals));
const actual = store.getState();
expect(actual).toMatchSnapshot();
});
});
}
/* eslint-enable jest/no-export -- not a test file */
Expand Down
65 changes: 56 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@babel/core": "^7.23.9",
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@reduxjs/toolkit": "^2.1.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^11.1.0",
"@semantic-release/git": "^10.0.1",
Expand All @@ -60,14 +61,14 @@
"immutable": "^4.3.5",
"jest": "^29.7.0",
"lockfile-lint": "^4.12.1",
"redux": "^4.2.1",
"redux": "^5.0.1",
"redux-immutable": "^4.0.0",
"rimraf": "^5.0.5",
"semantic-release": "^22.0.12"
},
"peerDependencies": {
"immutable": "^3||^4.0.0-rc",
"redux": "^3||^4",
"redux": "^3||^4||^5",
"redux-immutable": "^4.0.0"
},
"release": {
Expand Down

0 comments on commit e23b819

Please sign in to comment.