test(reactivity/effect): add test for lazy option (#179)

This commit is contained in:
唐道海 2019-10-10 22:12:27 +08:00 committed by Evan You
parent 211f5b7a45
commit b7b89505eb

View File

@ -505,6 +505,18 @@ describe('reactivity/effect', () => {
expect(dummy).toBe(1)
})
it('lazy', () => {
const obj = reactive({ foo: 1 })
let dummy
const runner = effect(() => (dummy = obj.foo), { lazy: true })
expect(dummy).toBe(undefined)
expect(runner()).toBe(1)
expect(dummy).toBe(1)
obj.foo = 2
expect(dummy).toBe(2)
})
it('scheduler', () => {
let runner: any, dummy
const scheduler = jest.fn(_runner => {