Skip to content

Commit 8bab78b

Browse files
xinpingwangyyx990803
authored andcommitted
test: reactive proto
1 parent 01b7e90 commit 8bab78b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/reactivity/__tests__/reactive.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ describe('reactivity/reactive', () => {
2626
expect(Object.keys(observed)).toEqual(['foo'])
2727
})
2828

29+
test('proto', () => {
30+
const obj = {}
31+
const reactiveObj = reactive(obj)
32+
expect(isReactive(reactiveObj)).toBe(true)
33+
// read prop of reactiveObject will cause reactiveObj[prop] to be reactive
34+
// @ts-ignore
35+
const prototype = reactiveObj['__proto__']
36+
const otherObj = { data: ['a'] }
37+
expect(isReactive(otherObj)).toBe(false)
38+
const reactiveOther = reactive(otherObj)
39+
expect(isReactive(reactiveOther)).toBe(true)
40+
expect(reactiveOther.data[0]).toBe('a')
41+
})
42+
2943
test('nested reactives', () => {
3044
const original = {
3145
nested: {

0 commit comments

Comments
 (0)