types(reactivity): Simplify the SymbolExtract (#4162)
This commit is contained in:
@@ -152,16 +152,44 @@ describe('reactivity/ref', () => {
|
||||
it('should keep symbols', () => {
|
||||
const customSymbol = Symbol()
|
||||
const obj = {
|
||||
[Symbol.asyncIterator]: { a: 1 },
|
||||
[Symbol.unscopables]: { b: '1' },
|
||||
[customSymbol]: { c: [1, 2, 3] }
|
||||
[Symbol.asyncIterator]: ref(1),
|
||||
[Symbol.hasInstance]: { a: ref('a') },
|
||||
[Symbol.isConcatSpreadable]: { b: ref(true) },
|
||||
[Symbol.iterator]: [ref(1)],
|
||||
[Symbol.match]: new Set<Ref<number>>(),
|
||||
[Symbol.matchAll]: new Map<number, Ref<string>>(),
|
||||
[Symbol.replace]: { arr: [ref('a')] },
|
||||
[Symbol.search]: { set: new Set<Ref<number>>() },
|
||||
[Symbol.species]: { map: new Map<number, Ref<string>>() },
|
||||
[Symbol.split]: new WeakSet<Ref<boolean>>(),
|
||||
[Symbol.toPrimitive]: new WeakMap<Ref<boolean>, string>(),
|
||||
[Symbol.toStringTag]: { weakSet: new WeakSet<Ref<boolean>>() },
|
||||
[Symbol.unscopables]: { weakMap: new WeakMap<Ref<boolean>, string>() },
|
||||
[customSymbol]: { arr: [ref(1)] }
|
||||
}
|
||||
|
||||
const objRef = ref(obj)
|
||||
|
||||
expect(objRef.value[Symbol.asyncIterator]).toBe(obj[Symbol.asyncIterator])
|
||||
expect(objRef.value[Symbol.unscopables]).toBe(obj[Symbol.unscopables])
|
||||
expect(objRef.value[customSymbol]).toStrictEqual(obj[customSymbol])
|
||||
const keys: (keyof typeof obj)[] = [
|
||||
Symbol.asyncIterator,
|
||||
Symbol.hasInstance,
|
||||
Symbol.isConcatSpreadable,
|
||||
Symbol.iterator,
|
||||
Symbol.match,
|
||||
Symbol.matchAll,
|
||||
Symbol.replace,
|
||||
Symbol.search,
|
||||
Symbol.species,
|
||||
Symbol.split,
|
||||
Symbol.toPrimitive,
|
||||
Symbol.toStringTag,
|
||||
Symbol.unscopables,
|
||||
customSymbol
|
||||
]
|
||||
|
||||
keys.forEach(key => {
|
||||
expect(objRef.value[key]).toStrictEqual(obj[key])
|
||||
})
|
||||
})
|
||||
|
||||
test('unref', () => {
|
||||
|
||||
Reference in New Issue
Block a user