Skip to content

Commit

Permalink
test: reactive proto
Browse files Browse the repository at this point in the history
  • Loading branch information
xinpingwang authored and yyx990803 committed May 3, 2020
1 parent 01b7e90 commit 8bab78b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/reactivity/__tests__/reactive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ describe('reactivity/reactive', () => {
expect(Object.keys(observed)).toEqual(['foo'])
})

test('proto', () => {
const obj = {}
const reactiveObj = reactive(obj)
expect(isReactive(reactiveObj)).toBe(true)
// read prop of reactiveObject will cause reactiveObj[prop] to be reactive
// @ts-ignore
const prototype = reactiveObj['__proto__']
const otherObj = { data: ['a'] }
expect(isReactive(otherObj)).toBe(false)
const reactiveOther = reactive(otherObj)
expect(isReactive(reactiveOther)).toBe(true)
expect(reactiveOther.data[0]).toBe('a')
})

test('nested reactives', () => {
const original = {
nested: {
Expand Down

0 comments on commit 8bab78b

Please sign in to comment.