test: add test for observer lazy getter invocation

This commit is contained in:
Evan You 2018-03-07 15:00:40 -05:00
parent 7392dfcc1d
commit aeebf0de90

View File

@ -355,4 +355,18 @@ describe('Observer', () => {
expect(obj.__ob__ instanceof Observer).toBe(true)
})
})
it('should lazy invoke existing getters', () => {
const obj = {}
let called = false
Object.defineProperty(obj, 'getterProp', {
enumerable: true,
get: () => {
called = true
return 'some value'
}
})
observe(obj)
expect(called).toBe(false)
})
})