Skip to content

Commit b7b8950

Browse files
tangdaohaiyyx990803
authored andcommitted
test(reactivity/effect): add test for lazy option (vuejs#179)
1 parent 211f5b7 commit b7b8950

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/reactivity/__tests__/effect.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,18 @@ describe('reactivity/effect', () => {
505505
expect(dummy).toBe(1)
506506
})
507507

508+
it('lazy', () => {
509+
const obj = reactive({ foo: 1 })
510+
let dummy
511+
const runner = effect(() => (dummy = obj.foo), { lazy: true })
512+
expect(dummy).toBe(undefined)
513+
514+
expect(runner()).toBe(1)
515+
expect(dummy).toBe(1)
516+
obj.foo = 2
517+
expect(dummy).toBe(2)
518+
})
519+
508520
it('scheduler', () => {
509521
let runner: any, dummy
510522
const scheduler = jest.fn(_runner => {

0 commit comments

Comments
 (0)