refactor: redux refactor to use redux toolkit (#182)

* add redux-toolkit

* update actions to use redux toolkit action creators

* add StrictDict

* ready for testing

* update testing for reducers

* update unit testing for reducers

* export reducers from initial state

* update unit test

* reorder the test reducer's handler

* remove unnecessary testing data

update

* update actions to use redux toolkit action creators

* testing

* thunkActions tests

* component thunkAction reference updates

* linting

* a little bit of doc and syntax cleanup

* fix tests

* assignment type actions tests

* actions testing and cleanup

* selectors cleanup

* fix store action reference

* update package-lock.json

* add a bit of test coverage

* strict selector export

* docstrings for test utils

* docstrings

* fix assignment filtering

* some cleanup

* update version to 1.4.29

Co-authored-by: Leangseu Kim <lkim@edx.org>
This commit is contained in:
Ben Warzeski
2021-05-25 15:08:36 -04:00
committed by GitHub
parent 3bc2511cc1
commit 189152f51b
92 changed files with 4398 additions and 2796 deletions

39
src/utils/StrictDict.js Normal file
View File

@@ -0,0 +1,39 @@
/* eslint-disable no-console */
import util from 'util';
const staticReturnOptions = [
'dict',
'inspect',
Symbol.toStringTag,
util.inspect.custom,
Symbol.for('nodejs.util.inspect.custom'),
];
const strictGet = (target, name) => {
if (name === Symbol.toStringTag) {
return target;
}
if (name === 'length') {
return target.length;
}
if (staticReturnOptions.indexOf(name) >= 0) {
return target;
}
if (name === Symbol.iterator) {
return { ...target };
}
if (name in target || name === '_reactFragment') {
return target[name];
}
console.log(name.toString());
console.error({ target, name });
const e = Error(`invalid property "${name.toString()}"`);
console.error(e.stack);
return undefined;
};
const StrictDict = (dict) => new Proxy(dict, { get: strictGet });
export default StrictDict;

2
src/utils/index.js Normal file
View File

@@ -0,0 +1,2 @@
/* eslint-disable import/prefer-default-export */
export { default as StrictDict } from './StrictDict';