Skip to content

Commit 66de140

Browse files
authored
Fix missing fail import (#2137)
* Fix missing fail import * Add test case for incorrect processor * Only run test in dev
1 parent d6823f7 commit 66de140

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

__tests__/core/snapshotProcessor.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -843,4 +843,16 @@ describe("snapshotProcessor", () => {
843843
expect(() => store.setProp("b")).not.toThrow()
844844
expect(store.prop).toBe("b")
845845
})
846+
847+
if (process.env.NODE_ENV !== "production") {
848+
test("it should fail if given incorrect processor", () => {
849+
expect(() => {
850+
types.model({
851+
m: types.snapshotProcessor(types.number, {
852+
postProcessor: {} as any
853+
})
854+
})
855+
}).toThrowError("[mobx-state-tree] postSnapshotProcessor must be a function")
856+
})
857+
}
846858
})

src/types/utility-types/snapshotProcessor.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
typeCheckFailure,
1717
isUnionType,
1818
Instance,
19-
ObjectNode
19+
ObjectNode,
20+
fail
2021
} from "../../internal"
2122

2223
/** @hidden */

0 commit comments

Comments
 (0)