mirror of https://github.com/vuejs/core.git
test(reactivity): use vitest fn instead of counting manually (#8476)
This commit is contained in:
parent
701fa735fc
commit
7c2e44ff5f
|
@ -28,19 +28,18 @@ describe('reactivity/ref', () => {
|
||||||
it('should be reactive', () => {
|
it('should be reactive', () => {
|
||||||
const a = ref(1)
|
const a = ref(1)
|
||||||
let dummy
|
let dummy
|
||||||
let calls = 0
|
const fn = vi.fn(() => {
|
||||||
effect(() => {
|
|
||||||
calls++
|
|
||||||
dummy = a.value
|
dummy = a.value
|
||||||
})
|
})
|
||||||
expect(calls).toBe(1)
|
effect(fn)
|
||||||
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
expect(dummy).toBe(1)
|
expect(dummy).toBe(1)
|
||||||
a.value = 2
|
a.value = 2
|
||||||
expect(calls).toBe(2)
|
expect(fn).toHaveBeenCalledTimes(2)
|
||||||
expect(dummy).toBe(2)
|
expect(dummy).toBe(2)
|
||||||
// same value should not trigger
|
// same value should not trigger
|
||||||
a.value = 2
|
a.value = 2
|
||||||
expect(calls).toBe(2)
|
expect(fn).toHaveBeenCalledTimes(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should make nested properties reactive', () => {
|
it('should make nested properties reactive', () => {
|
||||||
|
|
Loading…
Reference in New Issue