Spaces:
Paused
Paused
File size: 793 Bytes
9ada4bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import { it, expect } from 'vitest'
import { findPropertySource } from './findPropertySource'
it('returns the source for objects without prototypes', () => {
const obj = Object.create(null)
obj.test = undefined
const source = findPropertySource(obj, 'test')
expect(source).toBe(obj)
})
it('returns the source for objects with prototypes', () => {
const prototype = Object.create(null)
prototype.test = undefined
const obj = Object.create(prototype)
const source = findPropertySource(obj, 'test')
expect(source).toBe(prototype)
})
it('returns null if the prototype chain does not contain the property', () => {
const prototype = Object.create(null)
const obj = Object.create(prototype)
const source = findPropertySource(obj, 'test')
expect(source).toBeNull()
})
|