mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-19 02:48:30 +08:00
* immutable crossfilter * first cut at reducer refactor with cascade model * add initial redo/undo implementation * small optimization * integrate expression with history * add tests for new reducers and fix a couple of small initialization bugs * treat tiny lasso selections as a clear * better function name for clarity * fix undo for differential expression * remove logging * fix regression due to bad merge * cleanup and comments for clarity * improve undoable configuration for flexibility * fix stale comments * remove debugging code from production build * rename categoricalSelectionState * rename file * improve comments
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import cascadeReducers from "../../src/reducers/cascade";
|
|
|
|
describe("create", () => {
|
|
test("from Array", () => {
|
|
expect(cascadeReducers([["foo", () => 0]])).toBeInstanceOf(Function);
|
|
});
|
|
|
|
test("from Map", () => {
|
|
expect(cascadeReducers(new Map([["foo", () => 0]]))).toBeInstanceOf(
|
|
Function
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("cascade", () => {
|
|
test("expected arguments provided & cascade ordering", () => {
|
|
const topLevelState = {};
|
|
const topLevelAction = { type: "test" };
|
|
|
|
const reducer = cascadeReducers([
|
|
[
|
|
"foo",
|
|
(currentState, action, nextSharedState, prevSharedState) => {
|
|
expect(currentState).toBeUndefined();
|
|
expect(action).toEqual(topLevelAction);
|
|
expect(nextSharedState).toStrictEqual({});
|
|
expect(prevSharedState).toBe(topLevelState);
|
|
return 0;
|
|
}
|
|
],
|
|
[
|
|
"bar",
|
|
(currentState, action, nextSharedState, prevSharedState) => {
|
|
expect(currentState).toBeUndefined();
|
|
expect(action).toEqual(topLevelAction);
|
|
expect(nextSharedState).toStrictEqual({ foo: 0 });
|
|
expect(prevSharedState).toBe(topLevelState);
|
|
return 99;
|
|
}
|
|
]
|
|
]);
|
|
|
|
const nextState = reducer(topLevelState, topLevelAction);
|
|
expect(nextState).toStrictEqual({ foo: 0, bar: 99 });
|
|
expect(topLevelState).toStrictEqual({});
|
|
expect(topLevelAction).toStrictEqual({ type: "test" });
|
|
});
|
|
});
|