mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-05 05:18:12 +08:00
undoable TS typing (#2374)
* type undoable-related TS * style change to type declaration
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { Reducer } from "redux";
|
||||
import undoable from "../../src/reducers/undoable";
|
||||
|
||||
describe("create", () => {
|
||||
test("no keys", () => {
|
||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2-3 arguments, but got 1.
|
||||
expect(() => undoable(() => {})).toThrow();
|
||||
expect(() => undoable(() => {}, null)).toThrow();
|
||||
expect(() =>
|
||||
undoable(() => {}, undefined as unknown as string[])
|
||||
).toThrow();
|
||||
expect(() => undoable(() => {}, null as unknown as string[])).toThrow();
|
||||
expect(() => undoable(() => {}, [])).toThrow();
|
||||
expect(() => undoable(() => {}, [], {})).toThrow();
|
||||
});
|
||||
@@ -24,8 +26,7 @@ describe("create", () => {
|
||||
describe("undo", () => {
|
||||
test("expected state modifications", () => {
|
||||
const initialState = { a: 0, b: 1000 };
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||
const reducer = (state: any) => ({ a: state.a + 1, b: state.b + 1 });
|
||||
const reducer: Reducer = (state) => ({ a: state.a + 1, b: state.b + 1 });
|
||||
const undoableReducer = undoable(reducer, ["a"]);
|
||||
|
||||
const s1 = undoableReducer(initialState, { type: "test" });
|
||||
@@ -43,10 +44,8 @@ describe("undo", () => {
|
||||
|
||||
describe("redo", () => {
|
||||
const initialState = { a: 0, b: 1000 };
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||
const reducer = (state: any) => ({ a: state.a + 1, b: state.b + 1 });
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||
let UR: any;
|
||||
const reducer: Reducer = (state) => ({ a: state.a + 1, b: state.b + 1 });
|
||||
let UR: Reducer;
|
||||
|
||||
beforeEach(() => {
|
||||
UR = undoable(reducer, ["a"]);
|
||||
|
||||
Reference in New Issue
Block a user