Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Commit beb32ff

Browse files
committed
Test agaist MST v1.3.1 and v2.0.1
1 parent 091074b commit beb32ff

File tree

5 files changed

+103
-1
lines changed

5 files changed

+103
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import sinon from "sinon"
2+
import createMiddleware from "../../../src/middleware"
3+
import track from "../../../src/track"
4+
import { addMiddleware, flow, types } from "./node_modules/mobx-state-tree"
5+
6+
const trueFn = () => true
7+
8+
let sandbox = sinon.createSandbox()
9+
10+
describe("middleware.js", () => {
11+
afterEach(() => sandbox.restore())
12+
13+
describe("on MST 1.3.1", () => {
14+
describe("when renderLimit is reached", () => {
15+
it("fails with `false` value", async () => {
16+
const delay = sandbox.stub().resolves(true)
17+
const Store = track(
18+
types.model("Store").actions(() => ({
19+
exampleFlow: flow(function*() {
20+
yield delay()
21+
return 2
22+
})
23+
})),
24+
{ exampleFlow: track.async() }
25+
)
26+
27+
const store = Store.create()
28+
29+
const tracker = {
30+
add: sandbox.spy(),
31+
has: trueFn,
32+
remove: sandbox.spy(),
33+
renderLimitReached: trueFn
34+
}
35+
36+
const middleware = createMiddleware(tracker, console)
37+
38+
addMiddleware(store, middleware)
39+
40+
const foo = await store.exampleFlow()
41+
expect(foo).toBe(null)
42+
})
43+
})
44+
})
45+
})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"devDependencies": {
3+
"mobx-state-tree": "1.3.1",
4+
"mobx": "^3.1.15"
5+
}
6+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import sinon from "sinon"
2+
import createMiddleware from "../../../src/middleware"
3+
import track from "../../../src/track"
4+
import { addMiddleware, flow, types } from "./node_modules/mobx-state-tree"
5+
6+
const trueFn = () => true
7+
8+
let sandbox = sinon.createSandbox()
9+
10+
describe("middleware.js", () => {
11+
afterEach(() => sandbox.restore())
12+
13+
describe("on MST 2.0.1", () => {
14+
describe("when renderLimit is reached", () => {
15+
it("fails using MST `abort` function", async () => {
16+
const delay = sandbox.stub().resolves(true)
17+
const Store = track(
18+
types.model("Store").actions(() => ({
19+
exampleFlow: flow(function*() {
20+
yield delay()
21+
return 2
22+
})
23+
})),
24+
{ exampleFlow: track.async() }
25+
)
26+
27+
const store = Store.create()
28+
29+
const tracker = {
30+
add: sandbox.spy(),
31+
has: trueFn,
32+
remove: sandbox.spy(),
33+
renderLimitReached: trueFn
34+
}
35+
36+
const middleware = createMiddleware(tracker, console)
37+
38+
addMiddleware(store, middleware)
39+
40+
const foo = await store.exampleFlow()
41+
expect(foo).toBe(null)
42+
})
43+
})
44+
})
45+
})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"devDependencies": {
3+
"mobx-state-tree": "2.0.1",
4+
"mobx": "^4.1.0"
5+
}
6+
}

jest.setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const execSync = require("child_process").execSync
2-
const mstVersions = ["1.2.1", "1.4.0"]
2+
const mstVersions = ["1.2.1", "1.3.1", "1.4.0", "2.0.1"]
33

44
mstVersions.forEach(function(version) {
55
execSync(

0 commit comments

Comments
 (0)