Skip to content

Commit

Permalink
Add failing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
NaridaL committed May 15, 2020
1 parent 4b59640 commit 2170edc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/lazy-observable.js
Expand Up @@ -112,3 +112,19 @@ test("lazy observable pending", (done) => {
done()
}, 150)
})

test("lazy observable pending can be observed", async () => {
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

const lo = utils.lazyObservable((sink) => sleep(100).then(sink))

const pendingValues = []

mobx.autorun(() => pendingValues.push(lo.pending))

lo.current()

await sleep(150)

expect(pendingValues).toEqual([false, true, false])
})

0 comments on commit 2170edc

Please sign in to comment.