@@ -26,6 +26,22 @@ describe('reactivity/collections', () => {
|
||||
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())
|
||||
|
||||
@@ -22,6 +22,19 @@ describe('reactivity/collections', () => {
|
||||
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>)
|
||||
|
||||
@@ -27,6 +27,22 @@ describe('reactivity/collections', () => {
|
||||
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())
|
||||
|
||||
@@ -23,6 +23,19 @@ describe('reactivity/collections', () => {
|
||||
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())
|
||||
|
||||
Reference in New Issue
Block a user