mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-28 09:18:11 +08:00
* Disabled @blueprintjs/classes-constants. #2288. * thuang-eslint-bp-off (#2344) * Disabled @blueprintjs/classes-constants on webpack dev and shared. #2288. * Added TS recommended, suppress lint errors codemod. * Added per-error/warning ignore for tests. * Added per-error/warning ignore for configuration. * Added per-error/warning ignore for src. Removed suppress package. * Minor linting. Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
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",
|
|
(
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
currentState: any,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
action: any,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
nextSharedState: any,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
prevSharedState: any
|
|
) => {
|
|
expect(currentState).toBeUndefined();
|
|
expect(action).toEqual(topLevelAction);
|
|
expect(nextSharedState).toStrictEqual({});
|
|
expect(prevSharedState).toBe(topLevelState);
|
|
return 0;
|
|
},
|
|
],
|
|
[
|
|
"bar",
|
|
(
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
currentState: any,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
action: any,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
nextSharedState: any,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
prevSharedState: any
|
|
) => {
|
|
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" });
|
|
});
|
|
});
|