test(reactive): add test case of mutation in original reflecting in observed value (#2118)

This commit is contained in:
izayl 2020-09-15 22:49:59 +08:00 committed by GitHub
parent 05df696a2b
commit 848ccf56fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,6 +113,19 @@ describe('reactivity/reactive', () => {
expect('foo' in original).toBe(false)
})
test('original value change should reflect in observed value (Object)', () => {
const original: any = { foo: 1 }
const observed = reactive(original)
// set
original.bar = 1
expect(original.bar).toBe(1)
expect(observed.bar).toBe(1)
// delete
delete original.foo
expect('foo' in original).toBe(false)
expect('foo' in observed).toBe(false)
})
test('setting a property with an unobserved value should wrap with reactive', () => {
const observed = reactive<{ foo?: object }>({})
const raw = {}