Skip to content

Commit

Permalink
test(reactive): add test case of mutation in original reflecting in o…
Browse files Browse the repository at this point in the history
…bserved value (#2118)
  • Loading branch information
izayl authored Sep 15, 2020
1 parent 05df696 commit 848ccf5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/reactivity/__tests__/reactive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit 848ccf5

Please sign in to comment.