Skip to content

Commit 848ccf5

Browse files
authored
test(reactive): add test case of mutation in original reflecting in observed value (#2118)
1 parent 05df696 commit 848ccf5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/reactivity/__tests__/reactive.spec.ts

+13
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@ describe('reactivity/reactive', () => {
113113
expect('foo' in original).toBe(false)
114114
})
115115

116+
test('original value change should reflect in observed value (Object)', () => {
117+
const original: any = { foo: 1 }
118+
const observed = reactive(original)
119+
// set
120+
original.bar = 1
121+
expect(original.bar).toBe(1)
122+
expect(observed.bar).toBe(1)
123+
// delete
124+
delete original.foo
125+
expect('foo' in original).toBe(false)
126+
expect('foo' in observed).toBe(false)
127+
})
128+
116129
test('setting a property with an unobserved value should wrap with reactive', () => {
117130
const observed = reactive<{ foo?: object }>({})
118131
const raw = {}

0 commit comments

Comments
 (0)