Skip to content

Commit

Permalink
Fix missing fail import (#2137)
Browse files Browse the repository at this point in the history
* Fix missing fail import

* Add test case for incorrect processor

* Only run test in dev
  • Loading branch information
k-ode authored Feb 6, 2024
1 parent d6823f7 commit 66de140
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions __tests__/core/snapshotProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,4 +843,16 @@ describe("snapshotProcessor", () => {
expect(() => store.setProp("b")).not.toThrow()
expect(store.prop).toBe("b")
})

if (process.env.NODE_ENV !== "production") {
test("it should fail if given incorrect processor", () => {
expect(() => {
types.model({
m: types.snapshotProcessor(types.number, {
postProcessor: {} as any
})
})
}).toThrowError("[mobx-state-tree] postSnapshotProcessor must be a function")
})
}
})
3 changes: 2 additions & 1 deletion src/types/utility-types/snapshotProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
typeCheckFailure,
isUnionType,
Instance,
ObjectNode
ObjectNode,
fail
} from "../../internal"

/** @hidden */
Expand Down

0 comments on commit 66de140

Please sign in to comment.