fix(reactivity): account for NaN in value change checks (#361)
This commit is contained in:
@@ -311,5 +311,13 @@ describe('reactivity/collections', () => {
|
||||
map.get(key)!.foo++
|
||||
expect(dummy).toBe(2)
|
||||
})
|
||||
|
||||
it('should not be trigger when the value and the old value both are NaN', () => {
|
||||
const map = reactive(new Map([['foo', NaN]]))
|
||||
const mapSpy = jest.fn(() => map.get('foo'))
|
||||
effect(mapSpy)
|
||||
map.set('foo', NaN)
|
||||
expect(mapSpy).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -107,5 +107,15 @@ describe('reactivity/collections', () => {
|
||||
observed.get(key).a = 2
|
||||
expect(dummy).toBe(2)
|
||||
})
|
||||
|
||||
it('should not be trigger when the value and the old value both are NaN', () => {
|
||||
const map = new WeakMap()
|
||||
const key = {}
|
||||
map.set(key, NaN)
|
||||
const mapSpy = jest.fn(() => map.get(key))
|
||||
effect(mapSpy)
|
||||
map.set(key, NaN)
|
||||
expect(mapSpy).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -691,4 +691,14 @@ describe('reactivity/effect', () => {
|
||||
obj.foo = { prop: 1 }
|
||||
expect(dummy).toBe(1)
|
||||
})
|
||||
|
||||
it('should not be trigger when the value and the old value both are NaN', () => {
|
||||
const obj = reactive({
|
||||
foo: NaN
|
||||
})
|
||||
const fnSpy = jest.fn(() => obj.foo)
|
||||
effect(fnSpy)
|
||||
obj.foo = NaN
|
||||
expect(fnSpy).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user