@@ -10,8 +10,7 @@ import {
|
||||
inject,
|
||||
Ref,
|
||||
watch,
|
||||
SetupContext,
|
||||
computed
|
||||
SetupContext
|
||||
} from '@vue/runtime-test'
|
||||
|
||||
describe('renderer: component', () => {
|
||||
@@ -325,36 +324,4 @@ describe('renderer: component', () => {
|
||||
expect(serializeInner(root)).toBe(``)
|
||||
expect(ids).toEqual([ids[0], ids[0] + 1, ids[0] + 2])
|
||||
})
|
||||
|
||||
test('computed that did not change should not trigger re-render', async () => {
|
||||
const src = ref(0)
|
||||
const c = computed(() => src.value % 2)
|
||||
const spy = jest.fn()
|
||||
const App = {
|
||||
render() {
|
||||
spy()
|
||||
return c.value
|
||||
}
|
||||
}
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
render(h(App), root)
|
||||
expect(serializeInner(root)).toBe(`0`)
|
||||
expect(spy).toHaveBeenCalledTimes(1)
|
||||
|
||||
// verify it updates
|
||||
src.value = 1
|
||||
src.value = 2
|
||||
src.value = 3
|
||||
await nextTick()
|
||||
expect(serializeInner(root)).toBe(`1`)
|
||||
expect(spy).toHaveBeenCalledTimes(2) // should only update once
|
||||
|
||||
// verify it updates
|
||||
src.value = 4
|
||||
src.value = 5
|
||||
await nextTick()
|
||||
expect(serializeInner(root)).toBe(`1`)
|
||||
expect(spy).toHaveBeenCalledTimes(2) // should not need to update
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,10 +2,6 @@ import { ErrorCodes, callWithErrorHandling } from './errorHandling'
|
||||
import { isArray } from '@vue/shared'
|
||||
import { ComponentInternalInstance, getComponentName } from './component'
|
||||
import { warn } from './warning'
|
||||
import { setComputedScheduler } from '@vue/reactivity'
|
||||
|
||||
// set scheduler for computed
|
||||
setComputedScheduler(queueJob)
|
||||
|
||||
export interface SchedulerJob extends Function {
|
||||
id?: number
|
||||
|
||||
Reference in New Issue
Block a user