expect(dummy).toBe(undefined)
})
+ it('should observe mutations with observed value as key', () => {
+ let dummy
+ const key = reactive({})
+ const value = reactive({})
+ const map = reactive(new Map())
+ effect(() => {
+ dummy = map.get(key)
+ })
+
+ expect(dummy).toBe(undefined)
+ map.set(key, value)
+ expect(dummy).toBe(value)
+ map.delete(key)
+ expect(dummy).toBe(undefined)
+ })
+
it('should observe size mutations', () => {
let dummy
const map = reactive(new Map())
expect(dummy).toBe(false)
})
+ it('should observe mutations with observed value', () => {
+ let dummy
+ const value = reactive({})
+ const set = reactive(new Set())
+ effect(() => (dummy = set.has(value)))
+
+ expect(dummy).toBe(false)
+ set.add(value)
+ expect(dummy).toBe(true)
+ set.delete(value)
+ expect(dummy).toBe(false)
+ })
+
it('should observe for of iteration', () => {
let dummy
const set = reactive(new Set() as Set<number>)
expect(dummy).toBe(undefined)
})
+ it('should observe mutations with observed value as key', () => {
+ let dummy
+ const key = reactive({})
+ const value = reactive({})
+ const map = reactive(new WeakMap())
+ effect(() => {
+ dummy = map.get(key)
+ })
+
+ expect(dummy).toBe(undefined)
+ map.set(key, value)
+ expect(dummy).toBe(value)
+ map.delete(key)
+ expect(dummy).toBe(undefined)
+ })
+
it('should not observe custom property mutations', () => {
let dummy
const map: any = reactive(new WeakMap())
expect(dummy).toBe(false)
})
+ it('should observe mutations with observed value', () => {
+ let dummy
+ const value = reactive({})
+ const set = reactive(new WeakSet())
+ effect(() => (dummy = set.has(value)))
+
+ expect(dummy).toBe(false)
+ set.add(value)
+ expect(dummy).toBe(true)
+ set.delete(value)
+ expect(dummy).toBe(false)
+ })
+
it('should not observe custom property mutations', () => {
let dummy
const set: any = reactive(new WeakSet())
function set(this: MapTypes, key: unknown, value: unknown) {
value = toRaw(value)
+ key = toRaw(key)
const target = toRaw(this)
const proto = getProto(target)
const hadKey = proto.has.call(target, key)
}
function deleteEntry(this: CollectionTypes, key: unknown) {
+ key = toRaw(key)
const target = toRaw(this)
const proto = getProto(target)
const hadKey = proto.has.call(target, key)