From: 唐道海 Date: Thu, 10 Oct 2019 14:12:27 +0000 (+0800) Subject: test(reactivity/effect): add test for lazy option (#179) X-Git-Tag: v3.0.0-alpha.0~522 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b7b89505ebf00fb4e8e29ffdc45b010a4f075022;p=thirdparty%2Fvuejs%2Fcore.git test(reactivity/effect): add test for lazy option (#179) --- diff --git a/packages/reactivity/__tests__/effect.spec.ts b/packages/reactivity/__tests__/effect.spec.ts index 9538e5b896..340bf10931 100644 --- a/packages/reactivity/__tests__/effect.spec.ts +++ b/packages/reactivity/__tests__/effect.spec.ts @@ -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 => {