mirror of https://github.com/vuejs/core.git
wip(vitest-migration): reactivity tests passing
This commit is contained in:
parent
ab45f6f8a2
commit
8867bb259a
|
@ -102,6 +102,7 @@
|
||||||
"tslib": "^2.4.0",
|
"tslib": "^2.4.0",
|
||||||
"typescript": "^4.8.0",
|
"typescript": "^4.8.0",
|
||||||
"vite": "^4.0.4",
|
"vite": "^4.0.4",
|
||||||
|
"vitest": "^0.28.2",
|
||||||
"vue": "workspace:*"
|
"vue": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { ParserOptions } from '../src/options'
|
import { ParserOptions } from '../src/options'
|
||||||
import { baseParse, TextModes } from '../src/parse'
|
import { baseParse, TextModes } from '../src/parse'
|
||||||
import { ErrorCodes } from '../src/errors'
|
import { ErrorCodes } from '../src/errors'
|
||||||
|
@ -31,7 +32,7 @@ describe('compiler: parse', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('simple text with invalid end tag', () => {
|
test('simple text with invalid end tag', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const ast = baseParse('some text</div>', {
|
const ast = baseParse('some text</div>', {
|
||||||
onError
|
onError
|
||||||
})
|
})
|
||||||
|
@ -1844,7 +1845,7 @@ describe('compiler: parse', () => {
|
||||||
baseParse(`<div>\n<span>\n</div>\n</span>`)
|
baseParse(`<div>\n<span>\n</div>\n</span>`)
|
||||||
}).toThrow('Element is missing end tag.')
|
}).toThrow('Element is missing end tag.')
|
||||||
|
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const ast = baseParse(`<div>\n<span>\n</div>\n</span>`, {
|
const ast = baseParse(`<div>\n<span>\n</div>\n</span>`, {
|
||||||
onError: spy
|
onError: spy
|
||||||
})
|
})
|
||||||
|
@ -3034,7 +3035,7 @@ foo
|
||||||
c => `\\x0${c.codePointAt(0)!.toString(16)};`
|
c => `\\x0${c.codePointAt(0)!.toString(16)};`
|
||||||
),
|
),
|
||||||
() => {
|
() => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const ast = baseParse(code, {
|
const ast = baseParse(code, {
|
||||||
getNamespace: (tag, parent) => {
|
getNamespace: (tag, parent) => {
|
||||||
const ns = parent ? parent.ns : Namespaces.HTML
|
const ns = parent ? parent.ns : Namespaces.HTML
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { baseParse } from '../src/parse'
|
import { baseParse } from '../src/parse'
|
||||||
import { transform, NodeTransform } from '../src/transform'
|
import { transform, NodeTransform } from '../src/transform'
|
||||||
import {
|
import {
|
||||||
|
@ -88,7 +89,7 @@ describe('compiler: transform', () => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const spy = jest.fn(plugin)
|
const spy = vi.fn(plugin)
|
||||||
transform(ast, {
|
transform(ast, {
|
||||||
nodeTransforms: [spy]
|
nodeTransforms: [spy]
|
||||||
})
|
})
|
||||||
|
@ -113,7 +114,7 @@ describe('compiler: transform', () => {
|
||||||
context.removeNode()
|
context.removeNode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const spy = jest.fn(plugin)
|
const spy = vi.fn(plugin)
|
||||||
transform(ast, {
|
transform(ast, {
|
||||||
nodeTransforms: [spy]
|
nodeTransforms: [spy]
|
||||||
})
|
})
|
||||||
|
@ -141,7 +142,7 @@ describe('compiler: transform', () => {
|
||||||
context.removeNode(context.parent!.children[0])
|
context.removeNode(context.parent!.children[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const spy = jest.fn(plugin)
|
const spy = vi.fn(plugin)
|
||||||
transform(ast, {
|
transform(ast, {
|
||||||
nodeTransforms: [spy]
|
nodeTransforms: [spy]
|
||||||
})
|
})
|
||||||
|
@ -168,7 +169,7 @@ describe('compiler: transform', () => {
|
||||||
context.removeNode(context.parent!.children[1])
|
context.removeNode(context.parent!.children[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const spy = jest.fn(plugin)
|
const spy = vi.fn(plugin)
|
||||||
transform(ast, {
|
transform(ast, {
|
||||||
nodeTransforms: [spy]
|
nodeTransforms: [spy]
|
||||||
})
|
})
|
||||||
|
@ -209,7 +210,7 @@ describe('compiler: transform', () => {
|
||||||
createCompilerError(ErrorCodes.X_INVALID_END_TAG, node.loc)
|
createCompilerError(ErrorCodes.X_INVALID_END_TAG, node.loc)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
transform(ast, {
|
transform(ast, {
|
||||||
nodeTransforms: [plugin],
|
nodeTransforms: [plugin],
|
||||||
onError: spy
|
onError: spy
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
CompilerOptions,
|
CompilerOptions,
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
|
@ -531,7 +532,7 @@ describe('compiler: element transform', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('error on v-bind with no argument', () => {
|
test('error on v-bind with no argument', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithElementTransform(`<div v-bind/>`, { onError })
|
parseWithElementTransform(`<div v-bind/>`, { onError })
|
||||||
expect(onError.mock.calls[0]).toMatchObject([
|
expect(onError.mock.calls[0]).toMatchObject([
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
transform,
|
transform,
|
||||||
|
@ -395,7 +396,7 @@ describe('compiler: expression transform', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should handle parse error', () => {
|
test('should handle parse error', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithExpressionTransform(`{{ a( }}`, { onError })
|
parseWithExpressionTransform(`{{ a( }}`, { onError })
|
||||||
expect(onError.mock.calls[0][0].message).toMatch(
|
expect(onError.mock.calls[0][0].message).toMatch(
|
||||||
`Error parsing JavaScript expression: Unexpected token`
|
`Error parsing JavaScript expression: Unexpected token`
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
CompilerOptions,
|
CompilerOptions,
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
|
@ -369,7 +370,7 @@ describe('compiler: transform <slot> outlets', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test(`error on unexpected custom directive on <slot>`, () => {
|
test(`error on unexpected custom directive on <slot>`, () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const source = `<slot v-foo />`
|
const source = `<slot v-foo />`
|
||||||
parseWithSlots(source, { onError })
|
parseWithSlots(source, { onError })
|
||||||
const index = source.indexOf('v-foo')
|
const index = source.indexOf('v-foo')
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
transform,
|
transform,
|
||||||
|
@ -99,7 +100,7 @@ describe('compiler: transform v-bind', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should error if no expression', () => {
|
test('should error if no expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const node = parseWithVBind(`<div v-bind:arg />`, { onError })
|
const node = parseWithVBind(`<div v-bind:arg />`, { onError })
|
||||||
const props = (node.codegenNode as VNodeCall).props as ObjectExpression
|
const props = (node.codegenNode as VNodeCall).props as ObjectExpression
|
||||||
expect(onError.mock.calls[0][0]).toMatchObject({
|
expect(onError.mock.calls[0][0]).toMatchObject({
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { baseParse as parse } from '../../src/parse'
|
import { baseParse as parse } from '../../src/parse'
|
||||||
import { transform } from '../../src/transform'
|
import { transform } from '../../src/transform'
|
||||||
import { transformIf } from '../../src/transforms/vIf'
|
import { transformIf } from '../../src/transforms/vIf'
|
||||||
|
@ -206,7 +207,7 @@ describe('compiler: v-for', () => {
|
||||||
|
|
||||||
describe('errors', () => {
|
describe('errors', () => {
|
||||||
test('missing expression', () => {
|
test('missing expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithForTransform('<span v-for />', { onError })
|
parseWithForTransform('<span v-for />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -218,7 +219,7 @@ describe('compiler: v-for', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('empty expression', () => {
|
test('empty expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithForTransform('<span v-for="" />', { onError })
|
parseWithForTransform('<span v-for="" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -230,7 +231,7 @@ describe('compiler: v-for', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('invalid expression', () => {
|
test('invalid expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithForTransform('<span v-for="items" />', { onError })
|
parseWithForTransform('<span v-for="items" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -242,7 +243,7 @@ describe('compiler: v-for', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('missing source', () => {
|
test('missing source', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithForTransform('<span v-for="item in" />', { onError })
|
parseWithForTransform('<span v-for="item in" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -254,7 +255,7 @@ describe('compiler: v-for', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('missing value', () => {
|
test('missing value', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithForTransform('<span v-for="in items" />', { onError })
|
parseWithForTransform('<span v-for="in items" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -266,7 +267,7 @@ describe('compiler: v-for', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('<template v-for> key placement', () => {
|
test('<template v-for> key placement', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithForTransform(
|
parseWithForTransform(
|
||||||
`
|
`
|
||||||
<template v-for="item in items">
|
<template v-for="item in items">
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { baseParse as parse } from '../../src/parse'
|
import { baseParse as parse } from '../../src/parse'
|
||||||
import { transform } from '../../src/transform'
|
import { transform } from '../../src/transform'
|
||||||
import { transformIf } from '../../src/transforms/vIf'
|
import { transformIf } from '../../src/transforms/vIf'
|
||||||
|
@ -213,7 +214,7 @@ describe('compiler: v-if', () => {
|
||||||
|
|
||||||
describe('errors', () => {
|
describe('errors', () => {
|
||||||
test('error on v-else missing adjacent v-if', () => {
|
test('error on v-else missing adjacent v-if', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
|
|
||||||
const { node: node1 } = parseWithIfTransform(`<div v-else/>`, { onError })
|
const { node: node1 } = parseWithIfTransform(`<div v-else/>`, { onError })
|
||||||
expect(onError.mock.calls[0]).toMatchObject([
|
expect(onError.mock.calls[0]).toMatchObject([
|
||||||
|
@ -249,7 +250,7 @@ describe('compiler: v-if', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('error on v-else-if missing adjacent v-if or v-else-if', () => {
|
test('error on v-else-if missing adjacent v-if or v-else-if', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
|
|
||||||
const { node: node1 } = parseWithIfTransform(`<div v-else-if="foo"/>`, {
|
const { node: node1 } = parseWithIfTransform(`<div v-else-if="foo"/>`, {
|
||||||
onError
|
onError
|
||||||
|
@ -302,7 +303,7 @@ describe('compiler: v-if', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('error on user key', () => {
|
test('error on user key', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
// dynamic
|
// dynamic
|
||||||
parseWithIfTransform(
|
parseWithIfTransform(
|
||||||
`<div v-if="ok" :key="a + 1" /><div v-else :key="a + 1" />`,
|
`<div v-if="ok" :key="a + 1" /><div v-else :key="a + 1" />`,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
transform,
|
transform,
|
||||||
|
@ -506,7 +507,7 @@ describe('compiler: transform v-model', () => {
|
||||||
|
|
||||||
describe('errors', () => {
|
describe('errors', () => {
|
||||||
test('missing expression', () => {
|
test('missing expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithVModel('<span v-model />', { onError })
|
parseWithVModel('<span v-model />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -518,7 +519,7 @@ describe('compiler: transform v-model', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('empty expression', () => {
|
test('empty expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithVModel('<span v-model="" />', { onError })
|
parseWithVModel('<span v-model="" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -530,7 +531,7 @@ describe('compiler: transform v-model', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('mal-formed expression', () => {
|
test('mal-formed expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithVModel('<span v-model="a + b" />', { onError })
|
parseWithVModel('<span v-model="a + b" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -542,14 +543,14 @@ describe('compiler: transform v-model', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('allow unicode', () => {
|
test('allow unicode', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithVModel('<span v-model="变.量" />', { onError })
|
parseWithVModel('<span v-model="变.量" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(0)
|
expect(onError).toHaveBeenCalledTimes(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('used on scope variable', () => {
|
test('used on scope variable', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithVModel('<span v-for="i in list" v-model="i" />', {
|
parseWithVModel('<span v-for="i in list" v-model="i" />', {
|
||||||
onError,
|
onError,
|
||||||
prefixIdentifiers: true
|
prefixIdentifiers: true
|
||||||
|
@ -564,7 +565,7 @@ describe('compiler: transform v-model', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('used on props', () => {
|
test('used on props', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithVModel('<div v-model="p" />', {
|
parseWithVModel('<div v-model="p" />', {
|
||||||
onError,
|
onError,
|
||||||
bindingMetadata: {
|
bindingMetadata: {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
CompilerOptions,
|
CompilerOptions,
|
||||||
|
@ -398,7 +399,7 @@ describe('compiler: transform v-on', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should error if no expression AND no modifier', () => {
|
test('should error if no expression AND no modifier', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithVOn(`<div v-on:click />`, { onError })
|
parseWithVOn(`<div v-on:click />`, { onError })
|
||||||
expect(onError.mock.calls[0][0]).toMatchObject({
|
expect(onError.mock.calls[0][0]).toMatchObject({
|
||||||
code: ErrorCodes.X_V_ON_NO_EXPRESSION,
|
code: ErrorCodes.X_V_ON_NO_EXPRESSION,
|
||||||
|
@ -416,7 +417,7 @@ describe('compiler: transform v-on', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should NOT error if no expression but has modifier', () => {
|
test('should NOT error if no expression but has modifier', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
parseWithVOn(`<div v-on:click.prevent />`, { onError })
|
parseWithVOn(`<div v-on:click.prevent />`, { onError })
|
||||||
expect(onError).not.toHaveBeenCalled()
|
expect(onError).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
CompilerOptions,
|
CompilerOptions,
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
|
@ -843,7 +844,7 @@ describe('compiler: transform component slots', () => {
|
||||||
|
|
||||||
describe('errors', () => {
|
describe('errors', () => {
|
||||||
test('error on extraneous children w/ named default slot', () => {
|
test('error on extraneous children w/ named default slot', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const source = `<Comp><template #default>foo</template>bar</Comp>`
|
const source = `<Comp><template #default>foo</template>bar</Comp>`
|
||||||
parseWithSlots(source, { onError })
|
parseWithSlots(source, { onError })
|
||||||
const index = source.indexOf('bar')
|
const index = source.indexOf('bar')
|
||||||
|
@ -866,7 +867,7 @@ describe('compiler: transform component slots', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('error on duplicated slot names', () => {
|
test('error on duplicated slot names', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const source = `<Comp><template #foo></template><template #foo></template></Comp>`
|
const source = `<Comp><template #foo></template><template #foo></template></Comp>`
|
||||||
parseWithSlots(source, { onError })
|
parseWithSlots(source, { onError })
|
||||||
const index = source.lastIndexOf('#foo')
|
const index = source.lastIndexOf('#foo')
|
||||||
|
@ -889,7 +890,7 @@ describe('compiler: transform component slots', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('error on invalid mixed slot usage', () => {
|
test('error on invalid mixed slot usage', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const source = `<Comp v-slot="foo"><template #foo></template></Comp>`
|
const source = `<Comp v-slot="foo"><template #foo></template></Comp>`
|
||||||
parseWithSlots(source, { onError })
|
parseWithSlots(source, { onError })
|
||||||
const index = source.lastIndexOf('#foo')
|
const index = source.lastIndexOf('#foo')
|
||||||
|
@ -912,7 +913,7 @@ describe('compiler: transform component slots', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('error on v-slot usage on plain elements', () => {
|
test('error on v-slot usage on plain elements', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const source = `<div v-slot/>`
|
const source = `<div v-slot/>`
|
||||||
parseWithSlots(source, { onError })
|
parseWithSlots(source, { onError })
|
||||||
const index = source.indexOf('v-slot')
|
const index = source.indexOf('v-slot')
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { compile } from '../../src'
|
import { compile } from '../../src'
|
||||||
|
|
||||||
describe('Transition multi children warnings', () => {
|
describe('Transition multi children warnings', () => {
|
||||||
|
@ -6,7 +7,7 @@ describe('Transition multi children warnings', () => {
|
||||||
shouldWarn: boolean,
|
shouldWarn: boolean,
|
||||||
message = `<Transition> expects exactly one child element or component.`
|
message = `<Transition> expects exactly one child element or component.`
|
||||||
) {
|
) {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
compile(template.trim(), {
|
compile(template.trim(), {
|
||||||
hoistStatic: true,
|
hoistStatic: true,
|
||||||
transformHoist: null,
|
transformHoist: null,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
transform,
|
transform,
|
||||||
|
@ -40,7 +41,7 @@ describe('compiler: v-html transform', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should raise error and ignore children when v-html is present', () => {
|
it('should raise error and ignore children when v-html is present', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const ast = transformWithVHtml(`<div v-html="test">hello</div>`, {
|
const ast = transformWithVHtml(`<div v-html="test">hello</div>`, {
|
||||||
onError
|
onError
|
||||||
})
|
})
|
||||||
|
@ -59,7 +60,7 @@ describe('compiler: v-html transform', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should raise error if has no expression', () => {
|
it('should raise error if has no expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
transformWithVHtml(`<div v-html></div>`, {
|
transformWithVHtml(`<div v-html></div>`, {
|
||||||
onError
|
onError
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
transform,
|
transform,
|
||||||
|
@ -92,7 +93,7 @@ describe('compiler: transform v-model', () => {
|
||||||
|
|
||||||
describe('errors', () => {
|
describe('errors', () => {
|
||||||
test('plain elements with argument', () => {
|
test('plain elements with argument', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
transformWithModel('<input v-model:value="model" />', { onError })
|
transformWithModel('<input v-model:value="model" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -104,7 +105,7 @@ describe('compiler: transform v-model', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('invalid element', () => {
|
test('invalid element', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
transformWithModel('<span v-model="model" />', { onError })
|
transformWithModel('<span v-model="model" />', { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
@ -116,7 +117,7 @@ describe('compiler: transform v-model', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should allow usage on custom element', () => {
|
test('should allow usage on custom element', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const root = transformWithModel('<my-input v-model="model" />', {
|
const root = transformWithModel('<my-input v-model="model" />', {
|
||||||
onError,
|
onError,
|
||||||
isCustomElement: tag => tag.startsWith('my-')
|
isCustomElement: tag => tag.startsWith('my-')
|
||||||
|
@ -127,7 +128,7 @@ describe('compiler: transform v-model', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should raise error if used file input element', () => {
|
test('should raise error if used file input element', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
transformWithModel(`<input type="file" v-model="test"/>`, {
|
transformWithModel(`<input type="file" v-model="test"/>`, {
|
||||||
onError
|
onError
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
transform,
|
transform,
|
||||||
|
@ -28,7 +29,7 @@ describe('compiler: v-show transform', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should raise error if has no expression', () => {
|
test('should raise error if has no expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
transformWithShow(`<div v-show/>`, { onError })
|
transformWithShow(`<div v-show/>`, { onError })
|
||||||
|
|
||||||
expect(onError).toHaveBeenCalledTimes(1)
|
expect(onError).toHaveBeenCalledTimes(1)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
baseParse as parse,
|
baseParse as parse,
|
||||||
transform,
|
transform,
|
||||||
|
@ -42,7 +43,7 @@ describe('compiler: v-text transform', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should raise error and ignore children when v-text is present', () => {
|
it('should raise error and ignore children when v-text is present', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
const ast = transformWithVText(`<div v-text="test">hello</div>`, {
|
const ast = transformWithVText(`<div v-text="test">hello</div>`, {
|
||||||
onError
|
onError
|
||||||
})
|
})
|
||||||
|
@ -63,7 +64,7 @@ describe('compiler: v-text transform', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should raise error if has no expression', () => {
|
it('should raise error if has no expression', () => {
|
||||||
const onError = jest.fn()
|
const onError = vi.fn()
|
||||||
transformWithVText(`<div v-text></div>`, {
|
transformWithVText(`<div v-text></div>`, {
|
||||||
onError
|
onError
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Vitest Snapshot v1
|
||||||
|
|
||||||
exports[`$ unwrapping 1`] = `
|
exports[`$ unwrapping 1`] = `
|
||||||
"
|
"
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { reactive, effect, toRaw, isReactive } from '../../src'
|
import { reactive, effect, toRaw, isReactive } from '../../src'
|
||||||
|
|
||||||
describe('reactivity/collections', () => {
|
describe('reactivity/collections', () => {
|
||||||
function coverCollectionFn(collection: Map<any, any>, fnName: string) {
|
function coverCollectionFn(collection: Map<any, any>, fnName: string) {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
let proxy = reactive(collection)
|
let proxy = reactive(collection)
|
||||||
;(collection as any)[fnName] = spy
|
;(collection as any)[fnName] = spy
|
||||||
return [proxy as any, spy]
|
return [proxy as any, spy]
|
||||||
|
@ -216,7 +217,7 @@ describe('reactivity/collections', () => {
|
||||||
it('should not observe non value changing mutations', () => {
|
it('should not observe non value changing mutations', () => {
|
||||||
let dummy
|
let dummy
|
||||||
const map = reactive(new Map())
|
const map = reactive(new Map())
|
||||||
const mapSpy = jest.fn(() => (dummy = map.get('key')))
|
const mapSpy = vi.fn(() => (dummy = map.get('key')))
|
||||||
effect(mapSpy)
|
effect(mapSpy)
|
||||||
|
|
||||||
expect(dummy).toBe(undefined)
|
expect(dummy).toBe(undefined)
|
||||||
|
@ -350,7 +351,7 @@ describe('reactivity/collections', () => {
|
||||||
|
|
||||||
it('should not be trigger when the value and the old value both are NaN', () => {
|
it('should not be trigger when the value and the old value both are NaN', () => {
|
||||||
const map = reactive(new Map([['foo', NaN]]))
|
const map = reactive(new Map([['foo', NaN]]))
|
||||||
const mapSpy = jest.fn(() => map.get('foo'))
|
const mapSpy = vi.fn(() => map.get('foo'))
|
||||||
effect(mapSpy)
|
effect(mapSpy)
|
||||||
map.set('foo', NaN)
|
map.set('foo', NaN)
|
||||||
expect(mapSpy).toHaveBeenCalledTimes(1)
|
expect(mapSpy).toHaveBeenCalledTimes(1)
|
||||||
|
@ -418,7 +419,7 @@ describe('reactivity/collections', () => {
|
||||||
// #877
|
// #877
|
||||||
it('should not trigger key iteration when setting existing keys', () => {
|
it('should not trigger key iteration when setting existing keys', () => {
|
||||||
const map = reactive(new Map())
|
const map = reactive(new Map())
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
effect(() => {
|
effect(() => {
|
||||||
const keys = []
|
const keys = []
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { reactive, effect, isReactive, toRaw } from '../../src'
|
import { reactive, effect, isReactive, toRaw } from '../../src'
|
||||||
|
|
||||||
describe('reactivity/collections', () => {
|
describe('reactivity/collections', () => {
|
||||||
function coverCollectionFn(collection: Set<any>, fnName: string) {
|
function coverCollectionFn(collection: Set<any>, fnName: string) {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
let proxy = reactive(collection)
|
let proxy = reactive(collection)
|
||||||
;(collection as any)[fnName] = spy
|
;(collection as any)[fnName] = spy
|
||||||
return [proxy as any, spy]
|
return [proxy as any, spy]
|
||||||
|
@ -182,7 +183,7 @@ describe('reactivity/collections', () => {
|
||||||
it('should not observe non value changing mutations', () => {
|
it('should not observe non value changing mutations', () => {
|
||||||
let dummy
|
let dummy
|
||||||
const set = reactive(new Set())
|
const set = reactive(new Set())
|
||||||
const setSpy = jest.fn(() => (dummy = set.has('value')))
|
const setSpy = vi.fn(() => (dummy = set.has('value')))
|
||||||
effect(setSpy)
|
effect(setSpy)
|
||||||
|
|
||||||
expect(dummy).toBe(false)
|
expect(dummy).toBe(false)
|
||||||
|
@ -283,7 +284,7 @@ describe('reactivity/collections', () => {
|
||||||
let dummy
|
let dummy
|
||||||
const key = {}
|
const key = {}
|
||||||
const set = reactive(new Set())
|
const set = reactive(new Set())
|
||||||
const setSpy = jest.fn(() => (dummy = set.has(key)))
|
const setSpy = vi.fn(() => (dummy = set.has(key)))
|
||||||
effect(setSpy)
|
effect(setSpy)
|
||||||
|
|
||||||
expect(dummy).toBe(false)
|
expect(dummy).toBe(false)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { reactive, effect, toRaw, isReactive } from '../../src'
|
import { reactive, effect, toRaw, isReactive } from '../../src'
|
||||||
|
|
||||||
describe('reactivity/collections', () => {
|
describe('reactivity/collections', () => {
|
||||||
|
@ -57,7 +58,7 @@ describe('reactivity/collections', () => {
|
||||||
let dummy
|
let dummy
|
||||||
const key = {}
|
const key = {}
|
||||||
const map = reactive(new WeakMap())
|
const map = reactive(new WeakMap())
|
||||||
const mapSpy = jest.fn(() => (dummy = map.get(key)))
|
const mapSpy = vi.fn(() => (dummy = map.get(key)))
|
||||||
effect(mapSpy)
|
effect(mapSpy)
|
||||||
|
|
||||||
expect(dummy).toBe(undefined)
|
expect(dummy).toBe(undefined)
|
||||||
|
@ -128,7 +129,7 @@ describe('reactivity/collections', () => {
|
||||||
const map = new WeakMap()
|
const map = new WeakMap()
|
||||||
const key = {}
|
const key = {}
|
||||||
map.set(key, NaN)
|
map.set(key, NaN)
|
||||||
const mapSpy = jest.fn(() => map.get(key))
|
const mapSpy = vi.fn(() => map.get(key))
|
||||||
effect(mapSpy)
|
effect(mapSpy)
|
||||||
map.set(key, NaN)
|
map.set(key, NaN)
|
||||||
expect(mapSpy).toHaveBeenCalledTimes(1)
|
expect(mapSpy).toHaveBeenCalledTimes(1)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { reactive, isReactive, effect, toRaw } from '../../src'
|
import { reactive, isReactive, effect, toRaw } from '../../src'
|
||||||
|
|
||||||
describe('reactivity/collections', () => {
|
describe('reactivity/collections', () => {
|
||||||
|
@ -50,7 +51,7 @@ describe('reactivity/collections', () => {
|
||||||
let dummy
|
let dummy
|
||||||
const value = {}
|
const value = {}
|
||||||
const set = reactive(new WeakSet())
|
const set = reactive(new WeakSet())
|
||||||
const setSpy = jest.fn(() => (dummy = set.has(value)))
|
const setSpy = vi.fn(() => (dummy = set.has(value)))
|
||||||
effect(setSpy)
|
effect(setSpy)
|
||||||
|
|
||||||
expect(dummy).toBe(false)
|
expect(dummy).toBe(false)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
reactive,
|
reactive,
|
||||||
|
@ -23,7 +24,7 @@ describe('reactivity/computed', () => {
|
||||||
|
|
||||||
it('should compute lazily', () => {
|
it('should compute lazily', () => {
|
||||||
const value = reactive<{ foo?: number }>({})
|
const value = reactive<{ foo?: number }>({})
|
||||||
const getter = jest.fn(() => value.foo)
|
const getter = vi.fn(() => value.foo)
|
||||||
const cValue = computed(getter)
|
const cValue = computed(getter)
|
||||||
|
|
||||||
// lazy
|
// lazy
|
||||||
|
@ -74,8 +75,8 @@ describe('reactivity/computed', () => {
|
||||||
|
|
||||||
it('should trigger effect when chained', () => {
|
it('should trigger effect when chained', () => {
|
||||||
const value = reactive({ foo: 0 })
|
const value = reactive({ foo: 0 })
|
||||||
const getter1 = jest.fn(() => value.foo)
|
const getter1 = vi.fn(() => value.foo)
|
||||||
const getter2 = jest.fn(() => {
|
const getter2 = vi.fn(() => {
|
||||||
return c1.value + 1
|
return c1.value + 1
|
||||||
})
|
})
|
||||||
const c1 = computed(getter1)
|
const c1 = computed(getter1)
|
||||||
|
@ -97,8 +98,8 @@ describe('reactivity/computed', () => {
|
||||||
|
|
||||||
it('should trigger effect when chained (mixed invocations)', () => {
|
it('should trigger effect when chained (mixed invocations)', () => {
|
||||||
const value = reactive({ foo: 0 })
|
const value = reactive({ foo: 0 })
|
||||||
const getter1 = jest.fn(() => value.foo)
|
const getter1 = vi.fn(() => value.foo)
|
||||||
const getter2 = jest.fn(() => {
|
const getter2 = vi.fn(() => {
|
||||||
return c1.value + 1
|
return c1.value + 1
|
||||||
})
|
})
|
||||||
const c1 = computed(getter1)
|
const c1 = computed(getter1)
|
||||||
|
@ -223,7 +224,7 @@ describe('reactivity/computed', () => {
|
||||||
|
|
||||||
it('debug: onTrack', () => {
|
it('debug: onTrack', () => {
|
||||||
let events: DebuggerEvent[] = []
|
let events: DebuggerEvent[] = []
|
||||||
const onTrack = jest.fn((e: DebuggerEvent) => {
|
const onTrack = vi.fn((e: DebuggerEvent) => {
|
||||||
events.push(e)
|
events.push(e)
|
||||||
})
|
})
|
||||||
const obj = reactive({ foo: 1, bar: 2 })
|
const obj = reactive({ foo: 1, bar: 2 })
|
||||||
|
@ -256,7 +257,7 @@ describe('reactivity/computed', () => {
|
||||||
|
|
||||||
it('debug: onTrigger', () => {
|
it('debug: onTrigger', () => {
|
||||||
let events: DebuggerEvent[] = []
|
let events: DebuggerEvent[] = []
|
||||||
const onTrigger = jest.fn((e: DebuggerEvent) => {
|
const onTrigger = vi.fn((e: DebuggerEvent) => {
|
||||||
events.push(e)
|
events.push(e)
|
||||||
})
|
})
|
||||||
const obj = reactive({ foo: 1 })
|
const obj = reactive({ foo: 1 })
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { computed, deferredComputed, effect, ref } from '../src'
|
import { computed, deferredComputed, effect, ref } from '../src'
|
||||||
|
|
||||||
describe('deferred computed', () => {
|
describe('deferred computed', () => {
|
||||||
|
@ -6,7 +7,7 @@ describe('deferred computed', () => {
|
||||||
test('should only trigger once on multiple mutations', async () => {
|
test('should only trigger once on multiple mutations', async () => {
|
||||||
const src = ref(0)
|
const src = ref(0)
|
||||||
const c = deferredComputed(() => src.value)
|
const c = deferredComputed(() => src.value)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
effect(() => {
|
effect(() => {
|
||||||
spy(c.value)
|
spy(c.value)
|
||||||
})
|
})
|
||||||
|
@ -25,7 +26,7 @@ describe('deferred computed', () => {
|
||||||
test('should not trigger if value did not change', async () => {
|
test('should not trigger if value did not change', async () => {
|
||||||
const src = ref(0)
|
const src = ref(0)
|
||||||
const c = deferredComputed(() => src.value % 2)
|
const c = deferredComputed(() => src.value % 2)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
effect(() => {
|
effect(() => {
|
||||||
spy(c.value)
|
spy(c.value)
|
||||||
})
|
})
|
||||||
|
@ -46,9 +47,9 @@ describe('deferred computed', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('chained computed trigger', async () => {
|
test('chained computed trigger', async () => {
|
||||||
const effectSpy = jest.fn()
|
const effectSpy = vi.fn()
|
||||||
const c1Spy = jest.fn()
|
const c1Spy = vi.fn()
|
||||||
const c2Spy = jest.fn()
|
const c2Spy = vi.fn()
|
||||||
|
|
||||||
const src = ref(0)
|
const src = ref(0)
|
||||||
const c1 = deferredComputed(() => {
|
const c1 = deferredComputed(() => {
|
||||||
|
@ -76,9 +77,9 @@ describe('deferred computed', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('chained computed avoid re-compute', async () => {
|
test('chained computed avoid re-compute', async () => {
|
||||||
const effectSpy = jest.fn()
|
const effectSpy = vi.fn()
|
||||||
const c1Spy = jest.fn()
|
const c1Spy = vi.fn()
|
||||||
const c2Spy = jest.fn()
|
const c2Spy = vi.fn()
|
||||||
|
|
||||||
const src = ref(0)
|
const src = ref(0)
|
||||||
const c1 = deferredComputed(() => {
|
const c1 = deferredComputed(() => {
|
||||||
|
@ -108,9 +109,9 @@ describe('deferred computed', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('chained computed value invalidation', async () => {
|
test('chained computed value invalidation', async () => {
|
||||||
const effectSpy = jest.fn()
|
const effectSpy = vi.fn()
|
||||||
const c1Spy = jest.fn()
|
const c1Spy = vi.fn()
|
||||||
const c2Spy = jest.fn()
|
const c2Spy = vi.fn()
|
||||||
|
|
||||||
const src = ref(0)
|
const src = ref(0)
|
||||||
const c1 = deferredComputed(() => {
|
const c1 = deferredComputed(() => {
|
||||||
|
@ -140,9 +141,9 @@ describe('deferred computed', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('sync access of invalidated chained computed should not prevent final effect from running', async () => {
|
test('sync access of invalidated chained computed should not prevent final effect from running', async () => {
|
||||||
const effectSpy = jest.fn()
|
const effectSpy = vi.fn()
|
||||||
const c1Spy = jest.fn()
|
const c1Spy = vi.fn()
|
||||||
const c2Spy = jest.fn()
|
const c2Spy = vi.fn()
|
||||||
|
|
||||||
const src = ref(0)
|
const src = ref(0)
|
||||||
const c1 = deferredComputed(() => {
|
const c1 = deferredComputed(() => {
|
||||||
|
@ -167,7 +168,7 @@ describe('deferred computed', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should not compute if deactivated before scheduler is called', async () => {
|
test('should not compute if deactivated before scheduler is called', async () => {
|
||||||
const c1Spy = jest.fn()
|
const c1Spy = vi.fn()
|
||||||
const src = ref(0)
|
const src = ref(0)
|
||||||
const c1 = deferredComputed(() => {
|
const c1 = deferredComputed(() => {
|
||||||
c1Spy()
|
c1Spy()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
reactive,
|
reactive,
|
||||||
|
@ -16,7 +17,7 @@ import { ITERATE_KEY } from '../src/effect'
|
||||||
|
|
||||||
describe('reactivity/effect', () => {
|
describe('reactivity/effect', () => {
|
||||||
it('should run the passed function once (wrapped by a effect)', () => {
|
it('should run the passed function once (wrapped by a effect)', () => {
|
||||||
const fnSpy = jest.fn(() => {})
|
const fnSpy = vi.fn(() => {})
|
||||||
effect(fnSpy)
|
effect(fnSpy)
|
||||||
expect(fnSpy).toHaveBeenCalledTimes(1)
|
expect(fnSpy).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
@ -290,8 +291,8 @@ describe('reactivity/effect', () => {
|
||||||
let hasDummy, getDummy
|
let hasDummy, getDummy
|
||||||
const obj = reactive({ prop: 'value' })
|
const obj = reactive({ prop: 'value' })
|
||||||
|
|
||||||
const getSpy = jest.fn(() => (getDummy = obj.prop))
|
const getSpy = vi.fn(() => (getDummy = obj.prop))
|
||||||
const hasSpy = jest.fn(() => (hasDummy = 'prop' in obj))
|
const hasSpy = vi.fn(() => (hasDummy = 'prop' in obj))
|
||||||
effect(getSpy)
|
effect(getSpy)
|
||||||
effect(hasSpy)
|
effect(hasSpy)
|
||||||
|
|
||||||
|
@ -349,7 +350,7 @@ describe('reactivity/effect', () => {
|
||||||
it('should avoid implicit infinite recursive loops with itself', () => {
|
it('should avoid implicit infinite recursive loops with itself', () => {
|
||||||
const counter = reactive({ num: 0 })
|
const counter = reactive({ num: 0 })
|
||||||
|
|
||||||
const counterSpy = jest.fn(() => counter.num++)
|
const counterSpy = vi.fn(() => counter.num++)
|
||||||
effect(counterSpy)
|
effect(counterSpy)
|
||||||
expect(counter.num).toBe(1)
|
expect(counter.num).toBe(1)
|
||||||
expect(counterSpy).toHaveBeenCalledTimes(1)
|
expect(counterSpy).toHaveBeenCalledTimes(1)
|
||||||
|
@ -361,8 +362,8 @@ describe('reactivity/effect', () => {
|
||||||
it('should avoid infinite recursive loops when use Array.prototype.push/unshift/pop/shift', () => {
|
it('should avoid infinite recursive loops when use Array.prototype.push/unshift/pop/shift', () => {
|
||||||
;(['push', 'unshift'] as const).forEach(key => {
|
;(['push', 'unshift'] as const).forEach(key => {
|
||||||
const arr = reactive<number[]>([])
|
const arr = reactive<number[]>([])
|
||||||
const counterSpy1 = jest.fn(() => (arr[key] as any)(1))
|
const counterSpy1 = vi.fn(() => (arr[key] as any)(1))
|
||||||
const counterSpy2 = jest.fn(() => (arr[key] as any)(2))
|
const counterSpy2 = vi.fn(() => (arr[key] as any)(2))
|
||||||
effect(counterSpy1)
|
effect(counterSpy1)
|
||||||
effect(counterSpy2)
|
effect(counterSpy2)
|
||||||
expect(arr.length).toBe(2)
|
expect(arr.length).toBe(2)
|
||||||
|
@ -371,8 +372,8 @@ describe('reactivity/effect', () => {
|
||||||
})
|
})
|
||||||
;(['pop', 'shift'] as const).forEach(key => {
|
;(['pop', 'shift'] as const).forEach(key => {
|
||||||
const arr = reactive<number[]>([1, 2, 3, 4])
|
const arr = reactive<number[]>([1, 2, 3, 4])
|
||||||
const counterSpy1 = jest.fn(() => (arr[key] as any)())
|
const counterSpy1 = vi.fn(() => (arr[key] as any)())
|
||||||
const counterSpy2 = jest.fn(() => (arr[key] as any)())
|
const counterSpy2 = vi.fn(() => (arr[key] as any)())
|
||||||
effect(counterSpy1)
|
effect(counterSpy1)
|
||||||
effect(counterSpy2)
|
effect(counterSpy2)
|
||||||
expect(arr.length).toBe(2)
|
expect(arr.length).toBe(2)
|
||||||
|
@ -383,7 +384,7 @@ describe('reactivity/effect', () => {
|
||||||
|
|
||||||
it('should allow explicitly recursive raw function loops', () => {
|
it('should allow explicitly recursive raw function loops', () => {
|
||||||
const counter = reactive({ num: 0 })
|
const counter = reactive({ num: 0 })
|
||||||
const numSpy = jest.fn(() => {
|
const numSpy = vi.fn(() => {
|
||||||
counter.num++
|
counter.num++
|
||||||
if (counter.num < 10) {
|
if (counter.num < 10) {
|
||||||
numSpy()
|
numSpy()
|
||||||
|
@ -397,8 +398,8 @@ describe('reactivity/effect', () => {
|
||||||
it('should avoid infinite loops with other effects', () => {
|
it('should avoid infinite loops with other effects', () => {
|
||||||
const nums = reactive({ num1: 0, num2: 1 })
|
const nums = reactive({ num1: 0, num2: 1 })
|
||||||
|
|
||||||
const spy1 = jest.fn(() => (nums.num1 = nums.num2))
|
const spy1 = vi.fn(() => (nums.num1 = nums.num2))
|
||||||
const spy2 = jest.fn(() => (nums.num2 = nums.num1))
|
const spy2 = vi.fn(() => (nums.num2 = nums.num1))
|
||||||
effect(spy1)
|
effect(spy1)
|
||||||
effect(spy2)
|
effect(spy2)
|
||||||
expect(nums.num1).toBe(1)
|
expect(nums.num1).toBe(1)
|
||||||
|
@ -433,7 +434,7 @@ describe('reactivity/effect', () => {
|
||||||
let dummy
|
let dummy
|
||||||
const obj = reactive({ prop: 'value', run: false })
|
const obj = reactive({ prop: 'value', run: false })
|
||||||
|
|
||||||
const conditionalSpy = jest.fn(() => {
|
const conditionalSpy = vi.fn(() => {
|
||||||
dummy = obj.run ? obj.prop : 'other'
|
dummy = obj.run ? obj.prop : 'other'
|
||||||
})
|
})
|
||||||
effect(conditionalSpy)
|
effect(conditionalSpy)
|
||||||
|
@ -473,7 +474,7 @@ describe('reactivity/effect', () => {
|
||||||
let dummy
|
let dummy
|
||||||
const obj = reactive({ prop: 'value', run: true })
|
const obj = reactive({ prop: 'value', run: true })
|
||||||
|
|
||||||
const conditionalSpy = jest.fn(() => {
|
const conditionalSpy = vi.fn(() => {
|
||||||
dummy = obj.run ? obj.prop : 'other'
|
dummy = obj.run ? obj.prop : 'other'
|
||||||
})
|
})
|
||||||
effect(conditionalSpy)
|
effect(conditionalSpy)
|
||||||
|
@ -509,7 +510,7 @@ describe('reactivity/effect', () => {
|
||||||
const input = reactive({ a: 1, b: 2, c: 0 })
|
const input = reactive({ a: 1, b: 2, c: 0 })
|
||||||
const output = reactive({ fx1: 0, fx2: 0 })
|
const output = reactive({ fx1: 0, fx2: 0 })
|
||||||
|
|
||||||
const fx1Spy = jest.fn(() => {
|
const fx1Spy = vi.fn(() => {
|
||||||
let result = 0
|
let result = 0
|
||||||
if (input.c < 2) result += input.a
|
if (input.c < 2) result += input.a
|
||||||
if (input.c > 1) result += input.b
|
if (input.c > 1) result += input.b
|
||||||
|
@ -518,7 +519,7 @@ describe('reactivity/effect', () => {
|
||||||
|
|
||||||
const fx1 = effect(fx1Spy)
|
const fx1 = effect(fx1Spy)
|
||||||
|
|
||||||
const fx2Spy = jest.fn(() => {
|
const fx2Spy = vi.fn(() => {
|
||||||
let result = 0
|
let result = 0
|
||||||
if (input.c > 1) result += input.a
|
if (input.c > 1) result += input.a
|
||||||
if (input.c < 3) result += input.b
|
if (input.c < 3) result += input.b
|
||||||
|
@ -588,7 +589,7 @@ describe('reactivity/effect', () => {
|
||||||
it('should not run multiple times for a single mutation', () => {
|
it('should not run multiple times for a single mutation', () => {
|
||||||
let dummy
|
let dummy
|
||||||
const obj = reactive<Record<string, number>>({})
|
const obj = reactive<Record<string, number>>({})
|
||||||
const fnSpy = jest.fn(() => {
|
const fnSpy = vi.fn(() => {
|
||||||
for (const key in obj) {
|
for (const key in obj) {
|
||||||
dummy = obj[key]
|
dummy = obj[key]
|
||||||
}
|
}
|
||||||
|
@ -606,9 +607,9 @@ describe('reactivity/effect', () => {
|
||||||
const nums = reactive({ num1: 0, num2: 1, num3: 2 })
|
const nums = reactive({ num1: 0, num2: 1, num3: 2 })
|
||||||
const dummy: any = {}
|
const dummy: any = {}
|
||||||
|
|
||||||
const childSpy = jest.fn(() => (dummy.num1 = nums.num1))
|
const childSpy = vi.fn(() => (dummy.num1 = nums.num1))
|
||||||
const childeffect = effect(childSpy)
|
const childeffect = effect(childSpy)
|
||||||
const parentSpy = jest.fn(() => {
|
const parentSpy = vi.fn(() => {
|
||||||
dummy.num2 = nums.num2
|
dummy.num2 = nums.num2
|
||||||
childeffect()
|
childeffect()
|
||||||
dummy.num3 = nums.num3
|
dummy.num3 = nums.num3
|
||||||
|
@ -680,7 +681,7 @@ describe('reactivity/effect', () => {
|
||||||
it('scheduler', () => {
|
it('scheduler', () => {
|
||||||
let dummy
|
let dummy
|
||||||
let run: any
|
let run: any
|
||||||
const scheduler = jest.fn(() => {
|
const scheduler = vi.fn(() => {
|
||||||
run = runner
|
run = runner
|
||||||
})
|
})
|
||||||
const obj = reactive({ foo: 1 })
|
const obj = reactive({ foo: 1 })
|
||||||
|
@ -706,7 +707,7 @@ describe('reactivity/effect', () => {
|
||||||
it('events: onTrack', () => {
|
it('events: onTrack', () => {
|
||||||
let events: DebuggerEvent[] = []
|
let events: DebuggerEvent[] = []
|
||||||
let dummy
|
let dummy
|
||||||
const onTrack = jest.fn((e: DebuggerEvent) => {
|
const onTrack = vi.fn((e: DebuggerEvent) => {
|
||||||
events.push(e)
|
events.push(e)
|
||||||
})
|
})
|
||||||
const obj = reactive({ foo: 1, bar: 2 })
|
const obj = reactive({ foo: 1, bar: 2 })
|
||||||
|
@ -745,7 +746,7 @@ describe('reactivity/effect', () => {
|
||||||
it('events: onTrigger', () => {
|
it('events: onTrigger', () => {
|
||||||
let events: DebuggerEvent[] = []
|
let events: DebuggerEvent[] = []
|
||||||
let dummy
|
let dummy
|
||||||
const onTrigger = jest.fn((e: DebuggerEvent) => {
|
const onTrigger = vi.fn((e: DebuggerEvent) => {
|
||||||
events.push(e)
|
events.push(e)
|
||||||
})
|
})
|
||||||
const obj = reactive<{ foo?: number }>({ foo: 1 })
|
const obj = reactive<{ foo?: number }>({ foo: 1 })
|
||||||
|
@ -818,7 +819,7 @@ describe('reactivity/effect', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('events: onStop', () => {
|
it('events: onStop', () => {
|
||||||
const onStop = jest.fn()
|
const onStop = vi.fn()
|
||||||
const runner = effect(() => {}, {
|
const runner = effect(() => {}, {
|
||||||
onStop
|
onStop
|
||||||
})
|
})
|
||||||
|
@ -870,7 +871,7 @@ describe('reactivity/effect', () => {
|
||||||
const obj = reactive({
|
const obj = reactive({
|
||||||
foo: NaN
|
foo: NaN
|
||||||
})
|
})
|
||||||
const fnSpy = jest.fn(() => obj.foo)
|
const fnSpy = vi.fn(() => obj.foo)
|
||||||
effect(fnSpy)
|
effect(fnSpy)
|
||||||
obj.foo = NaN
|
obj.foo = NaN
|
||||||
expect(fnSpy).toHaveBeenCalledTimes(1)
|
expect(fnSpy).toHaveBeenCalledTimes(1)
|
||||||
|
@ -903,7 +904,7 @@ describe('reactivity/effect', () => {
|
||||||
it('should not be triggered when set with the same proxy', () => {
|
it('should not be triggered when set with the same proxy', () => {
|
||||||
const obj = reactive({ foo: 1 })
|
const obj = reactive({ foo: 1 })
|
||||||
const observed: any = reactive({ obj })
|
const observed: any = reactive({ obj })
|
||||||
const fnSpy = jest.fn(() => observed.obj)
|
const fnSpy = vi.fn(() => observed.obj)
|
||||||
|
|
||||||
effect(fnSpy)
|
effect(fnSpy)
|
||||||
|
|
||||||
|
@ -913,7 +914,7 @@ describe('reactivity/effect', () => {
|
||||||
|
|
||||||
const obj2 = reactive({ foo: 1 })
|
const obj2 = reactive({ foo: 1 })
|
||||||
const observed2: any = shallowReactive({ obj2 })
|
const observed2: any = shallowReactive({ obj2 })
|
||||||
const fnSpy2 = jest.fn(() => observed2.obj2)
|
const fnSpy2 = vi.fn(() => observed2.obj2)
|
||||||
|
|
||||||
effect(fnSpy2)
|
effect(fnSpy2)
|
||||||
|
|
||||||
|
@ -942,7 +943,7 @@ describe('reactivity/effect', () => {
|
||||||
test('should work with readonly(reactive(Map))', () => {
|
test('should work with readonly(reactive(Map))', () => {
|
||||||
const m = reactive(new Map())
|
const m = reactive(new Map())
|
||||||
const roM = readonly(m)
|
const roM = readonly(m)
|
||||||
const fnSpy = jest.fn(() => roM.get(1))
|
const fnSpy = vi.fn(() => roM.get(1))
|
||||||
|
|
||||||
effect(fnSpy)
|
effect(fnSpy)
|
||||||
expect(fnSpy).toHaveBeenCalledTimes(1)
|
expect(fnSpy).toHaveBeenCalledTimes(1)
|
||||||
|
@ -955,7 +956,7 @@ describe('reactivity/effect', () => {
|
||||||
const m = reactive(new Map())
|
const m = reactive(new Map())
|
||||||
m.set(key, 1)
|
m.set(key, 1)
|
||||||
const roM = readonly(m)
|
const roM = readonly(m)
|
||||||
const fnSpy = jest.fn(() => roM.get(key))
|
const fnSpy = vi.fn(() => roM.get(key))
|
||||||
|
|
||||||
effect(fnSpy)
|
effect(fnSpy)
|
||||||
expect(fnSpy).toHaveBeenCalledTimes(1)
|
expect(fnSpy).toHaveBeenCalledTimes(1)
|
||||||
|
@ -968,7 +969,7 @@ describe('reactivity/effect', () => {
|
||||||
test('should track hasOwnProperty', () => {
|
test('should track hasOwnProperty', () => {
|
||||||
const obj: any = reactive({})
|
const obj: any = reactive({})
|
||||||
let has = false
|
let has = false
|
||||||
const fnSpy = jest.fn()
|
const fnSpy = vi.fn()
|
||||||
|
|
||||||
effect(() => {
|
effect(() => {
|
||||||
fnSpy()
|
fnSpy()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { nextTick, watch, watchEffect } from '@vue/runtime-core'
|
import { nextTick, watch, watchEffect } from '@vue/runtime-core'
|
||||||
import {
|
import {
|
||||||
reactive,
|
reactive,
|
||||||
|
@ -12,7 +13,7 @@ import {
|
||||||
|
|
||||||
describe('reactivity/effect/scope', () => {
|
describe('reactivity/effect/scope', () => {
|
||||||
it('should run', () => {
|
it('should run', () => {
|
||||||
const fnSpy = jest.fn(() => {})
|
const fnSpy = vi.fn(() => {})
|
||||||
new EffectScope().run(fnSpy)
|
new EffectScope().run(fnSpy)
|
||||||
expect(fnSpy).toHaveBeenCalledTimes(1)
|
expect(fnSpy).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
@ -202,7 +203,7 @@ describe('reactivity/effect/scope', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should warn onScopeDispose() is called when there is no active effect scope', () => {
|
it('should warn onScopeDispose() is called when there is no active effect scope', () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const scope = new EffectScope()
|
const scope = new EffectScope()
|
||||||
scope.run(() => {
|
scope.run(() => {
|
||||||
onScopeDispose(spy)
|
onScopeDispose(spy)
|
||||||
|
@ -231,9 +232,9 @@ describe('reactivity/effect/scope', () => {
|
||||||
it('test with higher level APIs', async () => {
|
it('test with higher level APIs', async () => {
|
||||||
const r = ref(1)
|
const r = ref(1)
|
||||||
|
|
||||||
const computedSpy = jest.fn()
|
const computedSpy = vi.fn()
|
||||||
const watchSpy = jest.fn()
|
const watchSpy = vi.fn()
|
||||||
const watchEffectSpy = jest.fn()
|
const watchEffectSpy = vi.fn()
|
||||||
|
|
||||||
let c: ComputedRef
|
let c: ComputedRef
|
||||||
const scope = new EffectScope()
|
const scope = new EffectScope()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { reactive, isReactive, toRaw } from '../src/reactive'
|
import { reactive, isReactive, toRaw } from '../src/reactive'
|
||||||
import { ref, isRef } from '../src/ref'
|
import { ref, isRef } from '../src/ref'
|
||||||
import { effect } from '../src/effect'
|
import { effect } from '../src/effect'
|
||||||
|
@ -90,7 +91,7 @@ describe('reactivity/reactive/Array', () => {
|
||||||
|
|
||||||
test('delete on Array should not trigger length dependency', () => {
|
test('delete on Array should not trigger length dependency', () => {
|
||||||
const arr = reactive([1, 2, 3])
|
const arr = reactive([1, 2, 3])
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
effect(() => {
|
effect(() => {
|
||||||
fn(arr.length)
|
fn(arr.length)
|
||||||
})
|
})
|
||||||
|
@ -102,7 +103,7 @@ describe('reactivity/reactive/Array', () => {
|
||||||
test('add existing index on Array should not trigger length dependency', () => {
|
test('add existing index on Array should not trigger length dependency', () => {
|
||||||
const array = new Array(3)
|
const array = new Array(3)
|
||||||
const observed = reactive(array)
|
const observed = reactive(array)
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
effect(() => {
|
effect(() => {
|
||||||
fn(observed.length)
|
fn(observed.length)
|
||||||
})
|
})
|
||||||
|
@ -114,7 +115,7 @@ describe('reactivity/reactive/Array', () => {
|
||||||
test('add non-integer prop on Array should not trigger length dependency', () => {
|
test('add non-integer prop on Array should not trigger length dependency', () => {
|
||||||
const array: any[] & { x?: string } = new Array(3)
|
const array: any[] & { x?: string } = new Array(3)
|
||||||
const observed = reactive(array)
|
const observed = reactive(array)
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
effect(() => {
|
effect(() => {
|
||||||
fn(observed.length)
|
fn(observed.length)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
effect,
|
effect,
|
||||||
|
@ -385,7 +386,7 @@ describe('reactivity/ref', () => {
|
||||||
const obj = reactive({ count: 0 })
|
const obj = reactive({ count: 0 })
|
||||||
|
|
||||||
const a = ref(obj)
|
const a = ref(obj)
|
||||||
const spy1 = jest.fn(() => a.value)
|
const spy1 = vi.fn(() => a.value)
|
||||||
|
|
||||||
effect(spy1)
|
effect(spy1)
|
||||||
|
|
||||||
|
@ -393,7 +394,7 @@ describe('reactivity/ref', () => {
|
||||||
expect(spy1).toBeCalledTimes(1)
|
expect(spy1).toBeCalledTimes(1)
|
||||||
|
|
||||||
const b = shallowRef(obj)
|
const b = shallowRef(obj)
|
||||||
const spy2 = jest.fn(() => b.value)
|
const spy2 = vi.fn(() => b.value)
|
||||||
|
|
||||||
effect(spy2)
|
effect(spy2)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
isReactive,
|
isReactive,
|
||||||
isShallow,
|
isShallow,
|
||||||
|
@ -125,7 +126,7 @@ describe('shallowReactive', () => {
|
||||||
|
|
||||||
// #1210
|
// #1210
|
||||||
test('onTrack on called on objectSpread', () => {
|
test('onTrack on called on objectSpread', () => {
|
||||||
const onTrackFn = jest.fn()
|
const onTrackFn = vi.fn()
|
||||||
const shallowSet = shallowReactive(new Set())
|
const shallowSet = shallowReactive(new Set())
|
||||||
let a
|
let a
|
||||||
effect(
|
effect(
|
||||||
|
@ -170,7 +171,7 @@ describe('shallowReactive', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('onTrack on called on objectSpread', () => {
|
test('onTrack on called on objectSpread', () => {
|
||||||
const onTrackFn = jest.fn()
|
const onTrackFn = vi.fn()
|
||||||
const shallowArray = shallowReactive([])
|
const shallowArray = shallowReactive([])
|
||||||
let a
|
let a
|
||||||
effect(
|
effect(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
defineAsyncComponent,
|
defineAsyncComponent,
|
||||||
h,
|
h,
|
||||||
|
@ -137,7 +138,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
render: () => (toggle.value ? h(Foo) : null)
|
render: () => (toggle.value ? h(Foo) : null)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
|
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
|
@ -182,7 +183,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
render: () => (toggle.value ? h(Foo) : null)
|
render: () => (toggle.value ? h(Foo) : null)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
|
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
|
@ -273,7 +274,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
render: () => (toggle.value ? h(Foo) : null)
|
render: () => (toggle.value ? h(Foo) : null)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
|
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
|
|
||||||
|
@ -324,7 +325,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
render: () => h(Foo)
|
render: () => h(Foo)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
|
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
|
@ -358,7 +359,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
render: () => h(Foo)
|
render: () => h(Foo)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
|
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
|
@ -390,7 +391,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
render: () => h(Foo)
|
render: () => h(Foo)
|
||||||
})
|
})
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
await timeout(1)
|
await timeout(1)
|
||||||
|
@ -421,7 +422,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
render: () => h(Foo)
|
render: () => h(Foo)
|
||||||
})
|
})
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
await timeout(1)
|
await timeout(1)
|
||||||
|
@ -512,7 +513,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('loading')
|
expect(serializeInner(root)).toBe('loading')
|
||||||
|
|
||||||
|
@ -549,7 +550,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
render: () => h(Foo)
|
render: () => h(Foo)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
expect(loaderCallCount).toBe(1)
|
expect(loaderCallCount).toBe(1)
|
||||||
|
@ -593,7 +594,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
render: () => h(Foo)
|
render: () => h(Foo)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
expect(loaderCallCount).toBe(1)
|
expect(loaderCallCount).toBe(1)
|
||||||
|
@ -633,7 +634,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
render: () => h(Foo)
|
render: () => h(Foo)
|
||||||
})
|
})
|
||||||
|
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
app.mount(root)
|
app.mount(root)
|
||||||
expect(serializeInner(root)).toBe('<!---->')
|
expect(serializeInner(root)).toBe('<!---->')
|
||||||
expect(loaderCallCount).toBe(1)
|
expect(loaderCallCount).toBe(1)
|
||||||
|
@ -758,12 +759,12 @@ describe('api: defineAsyncComponent', () => {
|
||||||
const updater = ref(0)
|
const updater = ref(0)
|
||||||
|
|
||||||
const vnodeHooks = {
|
const vnodeHooks = {
|
||||||
onVnodeBeforeMount: jest.fn(),
|
onVnodeBeforeMount: vi.fn(),
|
||||||
onVnodeMounted: jest.fn(),
|
onVnodeMounted: vi.fn(),
|
||||||
onVnodeBeforeUpdate: jest.fn(),
|
onVnodeBeforeUpdate: vi.fn(),
|
||||||
onVnodeUpdated: jest.fn(),
|
onVnodeUpdated: vi.fn(),
|
||||||
onVnodeBeforeUnmount: jest.fn(),
|
onVnodeBeforeUnmount: vi.fn(),
|
||||||
onVnodeUnmounted: jest.fn()
|
onVnodeUnmounted: vi.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
|
@ -803,7 +804,7 @@ describe('api: defineAsyncComponent', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('with KeepAlive', async () => {
|
test('with KeepAlive', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
let resolve: (comp: Component) => void
|
let resolve: (comp: Component) => void
|
||||||
|
|
||||||
const Foo = defineAsyncComponent(
|
const Foo = defineAsyncComponent(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
createApp,
|
createApp,
|
||||||
h,
|
h,
|
||||||
|
@ -145,9 +146,9 @@ describe('api: createApp', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('directive', () => {
|
test('directive', () => {
|
||||||
const spy1 = jest.fn()
|
const spy1 = vi.fn()
|
||||||
const spy2 = jest.fn()
|
const spy2 = vi.fn()
|
||||||
const spy3 = jest.fn()
|
const spy3 = vi.fn()
|
||||||
|
|
||||||
const Root = {
|
const Root = {
|
||||||
// local override
|
// local override
|
||||||
|
@ -322,7 +323,7 @@ describe('api: createApp', () => {
|
||||||
const error = new Error()
|
const error = new Error()
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
|
|
||||||
const handler = jest.fn((err, instance, info) => {
|
const handler = vi.fn((err, instance, info) => {
|
||||||
expect(err).toBe(error)
|
expect(err).toBe(error)
|
||||||
expect((instance as any).count).toBe(count.value)
|
expect((instance as any).count).toBe(count.value)
|
||||||
expect(info).toBe(`render function`)
|
expect(info).toBe(`render function`)
|
||||||
|
@ -348,7 +349,7 @@ describe('api: createApp', () => {
|
||||||
|
|
||||||
test('config.warnHandler', () => {
|
test('config.warnHandler', () => {
|
||||||
let ctx: any
|
let ctx: any
|
||||||
const handler = jest.fn((msg, instance, trace) => {
|
const handler = vi.fn((msg, instance, trace) => {
|
||||||
expect(msg).toMatch(`Component is missing template or render function`)
|
expect(msg).toMatch(`Component is missing template or render function`)
|
||||||
expect(instance).toBe(ctx.proxy)
|
expect(instance).toBe(ctx.proxy)
|
||||||
expect(trace).toMatch(`Hello`)
|
expect(trace).toMatch(`Hello`)
|
||||||
|
@ -368,7 +369,7 @@ describe('api: createApp', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('config.isNativeTag', () => {
|
describe('config.isNativeTag', () => {
|
||||||
const isNativeTag = jest.fn(tag => tag === 'div')
|
const isNativeTag = vi.fn(tag => tag === 'div')
|
||||||
|
|
||||||
test('Component.name', () => {
|
test('Component.name', () => {
|
||||||
const Root = {
|
const Root = {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
onBeforeMount,
|
onBeforeMount,
|
||||||
h,
|
h,
|
||||||
|
@ -23,7 +24,7 @@ import { ITERATE_KEY, DebuggerEvent, TriggerOpTypes } from '@vue/reactivity'
|
||||||
describe('api: lifecycle hooks', () => {
|
describe('api: lifecycle hooks', () => {
|
||||||
it('onBeforeMount', () => {
|
it('onBeforeMount', () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn(() => {
|
const fn = vi.fn(() => {
|
||||||
// should be called before inner div is rendered
|
// should be called before inner div is rendered
|
||||||
expect(serializeInner(root)).toBe(``)
|
expect(serializeInner(root)).toBe(``)
|
||||||
})
|
})
|
||||||
|
@ -40,7 +41,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
|
|
||||||
it('onMounted', () => {
|
it('onMounted', () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn(() => {
|
const fn = vi.fn(() => {
|
||||||
// should be called after inner div is rendered
|
// should be called after inner div is rendered
|
||||||
expect(serializeInner(root)).toBe(`<div></div>`)
|
expect(serializeInner(root)).toBe(`<div></div>`)
|
||||||
})
|
})
|
||||||
|
@ -58,7 +59,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
it('onBeforeUpdate', async () => {
|
it('onBeforeUpdate', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn(() => {
|
const fn = vi.fn(() => {
|
||||||
// should be called before inner div is updated
|
// should be called before inner div is updated
|
||||||
expect(serializeInner(root)).toBe(`<div>0</div>`)
|
expect(serializeInner(root)).toBe(`<div>0</div>`)
|
||||||
})
|
})
|
||||||
|
@ -80,12 +81,12 @@ describe('api: lifecycle hooks', () => {
|
||||||
it('state mutation in onBeforeUpdate', async () => {
|
it('state mutation in onBeforeUpdate', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn(() => {
|
const fn = vi.fn(() => {
|
||||||
// should be called before inner div is updated
|
// should be called before inner div is updated
|
||||||
expect(serializeInner(root)).toBe(`<div>0</div>`)
|
expect(serializeInner(root)).toBe(`<div>0</div>`)
|
||||||
count.value++
|
count.value++
|
||||||
})
|
})
|
||||||
const renderSpy = jest.fn()
|
const renderSpy = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -109,7 +110,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
it('onUpdated', async () => {
|
it('onUpdated', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn(() => {
|
const fn = vi.fn(() => {
|
||||||
// should be called after inner div is updated
|
// should be called after inner div is updated
|
||||||
expect(serializeInner(root)).toBe(`<div>1</div>`)
|
expect(serializeInner(root)).toBe(`<div>1</div>`)
|
||||||
})
|
})
|
||||||
|
@ -130,7 +131,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
it('onBeforeUnmount', async () => {
|
it('onBeforeUnmount', async () => {
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn(() => {
|
const fn = vi.fn(() => {
|
||||||
// should be called before inner div is removed
|
// should be called before inner div is removed
|
||||||
expect(serializeInner(root)).toBe(`<div></div>`)
|
expect(serializeInner(root)).toBe(`<div></div>`)
|
||||||
})
|
})
|
||||||
|
@ -158,7 +159,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
it('onUnmounted', async () => {
|
it('onUnmounted', async () => {
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn(() => {
|
const fn = vi.fn(() => {
|
||||||
// should be called after inner div is removed
|
// should be called after inner div is removed
|
||||||
expect(serializeInner(root)).toBe(`<!---->`)
|
expect(serializeInner(root)).toBe(`<!---->`)
|
||||||
})
|
})
|
||||||
|
@ -186,7 +187,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
it('onBeforeUnmount in onMounted', async () => {
|
it('onBeforeUnmount in onMounted', async () => {
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn(() => {
|
const fn = vi.fn(() => {
|
||||||
// should be called before inner div is removed
|
// should be called before inner div is removed
|
||||||
expect(serializeInner(root)).toBe(`<div></div>`)
|
expect(serializeInner(root)).toBe(`<div></div>`)
|
||||||
})
|
})
|
||||||
|
@ -297,7 +298,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
|
|
||||||
it('onRenderTracked', () => {
|
it('onRenderTracked', () => {
|
||||||
const events: DebuggerEvent[] = []
|
const events: DebuggerEvent[] = []
|
||||||
const onTrack = jest.fn((e: DebuggerEvent) => {
|
const onTrack = vi.fn((e: DebuggerEvent) => {
|
||||||
events.push(e)
|
events.push(e)
|
||||||
})
|
})
|
||||||
const obj = reactive({ foo: 1, bar: 2 })
|
const obj = reactive({ foo: 1, bar: 2 })
|
||||||
|
@ -333,7 +334,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
|
|
||||||
it('onRenderTriggered', async () => {
|
it('onRenderTriggered', async () => {
|
||||||
const events: DebuggerEvent[] = []
|
const events: DebuggerEvent[] = []
|
||||||
const onTrigger = jest.fn((e: DebuggerEvent) => {
|
const onTrigger = vi.fn((e: DebuggerEvent) => {
|
||||||
events.push(e)
|
events.push(e)
|
||||||
})
|
})
|
||||||
const obj = reactive<{
|
const obj = reactive<{
|
||||||
|
@ -380,7 +381,7 @@ describe('api: lifecycle hooks', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('runs shared hook fn for each instance', async () => {
|
it('runs shared hook fn for each instance', async () => {
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
nodeOps,
|
nodeOps,
|
||||||
|
@ -140,11 +141,11 @@ describe('api: options', () => {
|
||||||
function returnThis(this: any) {
|
function returnThis(this: any) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
const spyA = jest.fn(returnThis)
|
const spyA = vi.fn(returnThis)
|
||||||
const spyB = jest.fn(returnThis)
|
const spyB = vi.fn(returnThis)
|
||||||
const spyC = jest.fn(returnThis)
|
const spyC = vi.fn(returnThis)
|
||||||
const spyD = jest.fn(returnThis)
|
const spyD = vi.fn(returnThis)
|
||||||
const spyE = jest.fn(returnThis)
|
const spyE = vi.fn(returnThis)
|
||||||
|
|
||||||
let ctx: any
|
let ctx: any
|
||||||
const Comp = {
|
const Comp = {
|
||||||
|
@ -186,7 +187,7 @@ describe('api: options', () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
render(h(Comp), root)
|
render(h(Comp), root)
|
||||||
|
|
||||||
function assertCall(spy: jest.Mock, callIndex: number, args: any[]) {
|
function assertCall(spy: vi.Mock, callIndex: number, args: any[]) {
|
||||||
expect(spy.mock.calls[callIndex].slice(0, 2)).toMatchObject(args)
|
expect(spy.mock.calls[callIndex].slice(0, 2)).toMatchObject(args)
|
||||||
expect(spy).toHaveReturnedWith(ctx)
|
expect(spy).toHaveReturnedWith(ctx)
|
||||||
}
|
}
|
||||||
|
@ -222,9 +223,9 @@ describe('api: options', () => {
|
||||||
function returnThis(this: any) {
|
function returnThis(this: any) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
const spyA = jest.fn(returnThis)
|
const spyA = vi.fn(returnThis)
|
||||||
const spyB = jest.fn(returnThis)
|
const spyB = vi.fn(returnThis)
|
||||||
const spyC = jest.fn(returnThis)
|
const spyC = vi.fn(returnThis)
|
||||||
|
|
||||||
let ctx: any
|
let ctx: any
|
||||||
const Comp = {
|
const Comp = {
|
||||||
|
@ -259,7 +260,7 @@ describe('api: options', () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
render(h(Comp), root)
|
render(h(Comp), root)
|
||||||
|
|
||||||
function assertCall(spy: jest.Mock, callIndex: number, args: any[]) {
|
function assertCall(spy: vi.Mock, callIndex: number, args: any[]) {
|
||||||
expect(spy.mock.calls[callIndex].slice(0, 2)).toMatchObject(args)
|
expect(spy.mock.calls[callIndex].slice(0, 2)).toMatchObject(args)
|
||||||
expect(spy).toHaveReturnedWith(ctx)
|
expect(spy).toHaveReturnedWith(ctx)
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1121,7 @@ describe('api: options', () => {
|
||||||
methods: {}
|
methods: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const watchSpy = jest.fn()
|
const watchSpy = vi.fn()
|
||||||
const mixin2 = {
|
const mixin2 = {
|
||||||
watch: {
|
watch: {
|
||||||
mixin3Data: watchSpy
|
mixin3Data: watchSpy
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { ref, reactive } from '@vue/reactivity'
|
import { ref, reactive } from '@vue/reactivity'
|
||||||
import {
|
import {
|
||||||
renderToString,
|
renderToString,
|
||||||
|
@ -169,7 +170,7 @@ describe('api: setup context', () => {
|
||||||
|
|
||||||
it('context.emit', async () => {
|
it('context.emit', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
const Parent = {
|
const Parent = {
|
||||||
render: () =>
|
render: () =>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
ComponentInternalInstance,
|
ComponentInternalInstance,
|
||||||
createApp,
|
createApp,
|
||||||
|
@ -149,7 +150,7 @@ describe('SFC <script setup> helpers', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('basic', async () => {
|
test('basic', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
let beforeInstance: ComponentInternalInstance | null = null
|
let beforeInstance: ComponentInternalInstance | null = null
|
||||||
let afterInstance: ComponentInternalInstance | null = null
|
let afterInstance: ComponentInternalInstance | null = null
|
||||||
|
@ -197,7 +198,7 @@ describe('SFC <script setup> helpers', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('error handling', async () => {
|
test('error handling', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
let beforeInstance: ComponentInternalInstance | null = null
|
let beforeInstance: ComponentInternalInstance | null = null
|
||||||
let afterInstance: ComponentInternalInstance | null = null
|
let afterInstance: ComponentInternalInstance | null = null
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
watch,
|
watch,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
|
@ -85,7 +86,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
it('watching single source: array', async () => {
|
it('watching single source: array', async () => {
|
||||||
const array = reactive([] as number[])
|
const array = reactive([] as number[])
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
watch(array, spy)
|
watch(array, spy)
|
||||||
array.push(1)
|
array.push(1)
|
||||||
await nextTick()
|
await nextTick()
|
||||||
|
@ -94,7 +95,7 @@ describe('api: watch', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire if watched getter result did not change', async () => {
|
it('should not fire if watched getter result did not change', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const n = ref(0)
|
const n = ref(0)
|
||||||
watch(() => n.value % 2, spy)
|
watch(() => n.value % 2, spy)
|
||||||
|
|
||||||
|
@ -279,7 +280,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
it('cleanup registration (effect)', async () => {
|
it('cleanup registration (effect)', async () => {
|
||||||
const state = reactive({ count: 0 })
|
const state = reactive({ count: 0 })
|
||||||
const cleanup = jest.fn()
|
const cleanup = vi.fn()
|
||||||
let dummy
|
let dummy
|
||||||
const stop = watchEffect(onCleanup => {
|
const stop = watchEffect(onCleanup => {
|
||||||
onCleanup(cleanup)
|
onCleanup(cleanup)
|
||||||
|
@ -298,7 +299,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
it('cleanup registration (with source)', async () => {
|
it('cleanup registration (with source)', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const cleanup = jest.fn()
|
const cleanup = vi.fn()
|
||||||
let dummy
|
let dummy
|
||||||
const stop = watch(count, (count, prevCount, onCleanup) => {
|
const stop = watch(count, (count, prevCount, onCleanup) => {
|
||||||
onCleanup(cleanup)
|
onCleanup(cleanup)
|
||||||
|
@ -326,7 +327,7 @@ describe('api: watch', () => {
|
||||||
let callCount = 0
|
let callCount = 0
|
||||||
let result1
|
let result1
|
||||||
let result2
|
let result2
|
||||||
const assertion = jest.fn((count, count2Value) => {
|
const assertion = vi.fn((count, count2Value) => {
|
||||||
callCount++
|
callCount++
|
||||||
// on mount, the watcher callback should be called before DOM render
|
// on mount, the watcher callback should be called before DOM render
|
||||||
// on update, should be called before the count is updated
|
// on update, should be called before the count is updated
|
||||||
|
@ -364,7 +365,7 @@ describe('api: watch', () => {
|
||||||
it('flush timing: post', async () => {
|
it('flush timing: post', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
let result
|
let result
|
||||||
const assertion = jest.fn(count => {
|
const assertion = vi.fn(count => {
|
||||||
result = serializeInner(root) === `${count}`
|
result = serializeInner(root) === `${count}`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -393,7 +394,7 @@ describe('api: watch', () => {
|
||||||
it('watchPostEffect', async () => {
|
it('watchPostEffect', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
let result
|
let result
|
||||||
const assertion = jest.fn(count => {
|
const assertion = vi.fn(count => {
|
||||||
result = serializeInner(root) === `${count}`
|
result = serializeInner(root) === `${count}`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -423,7 +424,7 @@ describe('api: watch', () => {
|
||||||
let callCount = 0
|
let callCount = 0
|
||||||
let result1
|
let result1
|
||||||
let result2
|
let result2
|
||||||
const assertion = jest.fn(count => {
|
const assertion = vi.fn(count => {
|
||||||
callCount++
|
callCount++
|
||||||
// on mount, the watcher callback should be called before DOM render
|
// on mount, the watcher callback should be called before DOM render
|
||||||
// on update, should be called before the count is updated
|
// on update, should be called before the count is updated
|
||||||
|
@ -470,7 +471,7 @@ describe('api: watch', () => {
|
||||||
let callCount = 0
|
let callCount = 0
|
||||||
let result1
|
let result1
|
||||||
let result2
|
let result2
|
||||||
const assertion = jest.fn(count => {
|
const assertion = vi.fn(count => {
|
||||||
callCount++
|
callCount++
|
||||||
// on mount, the watcher callback should be called before DOM render
|
// on mount, the watcher callback should be called before DOM render
|
||||||
// on update, should be called before the count is updated
|
// on update, should be called before the count is updated
|
||||||
|
@ -507,7 +508,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
it('should not fire on component unmount w/ flush: post', async () => {
|
it('should not fire on component unmount w/ flush: post', async () => {
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const cb = jest.fn()
|
const cb = vi.fn()
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
watch(toggle, cb, { flush: 'post' })
|
watch(toggle, cb, { flush: 'post' })
|
||||||
|
@ -529,7 +530,7 @@ describe('api: watch', () => {
|
||||||
// #2291
|
// #2291
|
||||||
it('should not fire on component unmount w/ flush: pre', async () => {
|
it('should not fire on component unmount w/ flush: pre', async () => {
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const cb = jest.fn()
|
const cb = vi.fn()
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
watch(toggle, cb, { flush: 'pre' })
|
watch(toggle, cb, { flush: 'pre' })
|
||||||
|
@ -726,7 +727,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
it('immediate', async () => {
|
it('immediate', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const cb = jest.fn()
|
const cb = vi.fn()
|
||||||
watch(count, cb, { immediate: true })
|
watch(count, cb, { immediate: true })
|
||||||
expect(cb).toHaveBeenCalledTimes(1)
|
expect(cb).toHaveBeenCalledTimes(1)
|
||||||
count.value++
|
count.value++
|
||||||
|
@ -736,14 +737,14 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
it('immediate: triggers when initial value is null', async () => {
|
it('immediate: triggers when initial value is null', async () => {
|
||||||
const state = ref(null)
|
const state = ref(null)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
watch(() => state.value, spy, { immediate: true })
|
watch(() => state.value, spy, { immediate: true })
|
||||||
expect(spy).toHaveBeenCalled()
|
expect(spy).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('immediate: triggers when initial value is undefined', async () => {
|
it('immediate: triggers when initial value is undefined', async () => {
|
||||||
const state = ref()
|
const state = ref()
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
watch(() => state.value, spy, { immediate: true })
|
watch(() => state.value, spy, { immediate: true })
|
||||||
expect(spy).toHaveBeenCalledWith(undefined, undefined, expect.any(Function))
|
expect(spy).toHaveBeenCalledWith(undefined, undefined, expect.any(Function))
|
||||||
state.value = 3
|
state.value = 3
|
||||||
|
@ -779,7 +780,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
it('warn and not respect deep option when using effect', async () => {
|
it('warn and not respect deep option when using effect', async () => {
|
||||||
const arr = ref([1, [2]])
|
const arr = ref([1, [2]])
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
watchEffect(
|
watchEffect(
|
||||||
() => {
|
() => {
|
||||||
spy()
|
spy()
|
||||||
|
@ -798,7 +799,7 @@ describe('api: watch', () => {
|
||||||
it('onTrack', async () => {
|
it('onTrack', async () => {
|
||||||
const events: DebuggerEvent[] = []
|
const events: DebuggerEvent[] = []
|
||||||
let dummy
|
let dummy
|
||||||
const onTrack = jest.fn((e: DebuggerEvent) => {
|
const onTrack = vi.fn((e: DebuggerEvent) => {
|
||||||
events.push(e)
|
events.push(e)
|
||||||
})
|
})
|
||||||
const obj = reactive({ foo: 1, bar: 2 })
|
const obj = reactive({ foo: 1, bar: 2 })
|
||||||
|
@ -833,7 +834,7 @@ describe('api: watch', () => {
|
||||||
it('onTrigger', async () => {
|
it('onTrigger', async () => {
|
||||||
const events: DebuggerEvent[] = []
|
const events: DebuggerEvent[] = []
|
||||||
let dummy
|
let dummy
|
||||||
const onTrigger = jest.fn((e: DebuggerEvent) => {
|
const onTrigger = vi.fn((e: DebuggerEvent) => {
|
||||||
events.push(e)
|
events.push(e)
|
||||||
})
|
})
|
||||||
const obj = reactive<{ foo?: number }>({ foo: 1 })
|
const obj = reactive<{ foo?: number }>({ foo: 1 })
|
||||||
|
@ -912,7 +913,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
test('should force trigger on triggerRef when watching multiple sources: shallow ref array', async () => {
|
test('should force trigger on triggerRef when watching multiple sources: shallow ref array', async () => {
|
||||||
const v = shallowRef([] as any)
|
const v = shallowRef([] as any)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
watch([v], () => {
|
watch([v], () => {
|
||||||
spy()
|
spy()
|
||||||
})
|
})
|
||||||
|
@ -927,7 +928,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
// #2125
|
// #2125
|
||||||
test('watchEffect should not recursively trigger itself', async () => {
|
test('watchEffect should not recursively trigger itself', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const price = ref(10)
|
const price = ref(10)
|
||||||
const history = ref<number[]>([])
|
const history = ref<number[]>([])
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
|
@ -940,7 +941,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
// #2231
|
// #2231
|
||||||
test('computed refs should not trigger watch if value has no change', async () => {
|
test('computed refs should not trigger watch if value has no change', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const source = ref(0)
|
const source = ref(0)
|
||||||
const price = computed(() => source.value === 0)
|
const price = computed(() => source.value === 0)
|
||||||
watch(price, spy)
|
watch(price, spy)
|
||||||
|
@ -1005,7 +1006,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
test('this.$watch should pass `this.proxy` to watch source as the first argument ', () => {
|
test('this.$watch should pass `this.proxy` to watch source as the first argument ', () => {
|
||||||
let instance: any
|
let instance: any
|
||||||
const source = jest.fn()
|
const source = vi.fn()
|
||||||
|
|
||||||
const Comp = defineComponent({
|
const Comp = defineComponent({
|
||||||
render() {},
|
render() {},
|
||||||
|
@ -1023,7 +1024,7 @@ describe('api: watch', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should not leak `this.proxy` to setup()', () => {
|
test('should not leak `this.proxy` to setup()', () => {
|
||||||
const source = jest.fn()
|
const source = vi.fn()
|
||||||
|
|
||||||
const Comp = defineComponent({
|
const Comp = defineComponent({
|
||||||
render() {},
|
render() {},
|
||||||
|
@ -1042,7 +1043,7 @@ describe('api: watch', () => {
|
||||||
test('pre watcher callbacks should not track dependencies', async () => {
|
test('pre watcher callbacks should not track dependencies', async () => {
|
||||||
const a = ref(0)
|
const a = ref(0)
|
||||||
const b = ref(0)
|
const b = ref(0)
|
||||||
const updated = jest.fn()
|
const updated = vi.fn()
|
||||||
|
|
||||||
const Child = defineComponent({
|
const Child = defineComponent({
|
||||||
props: ['a'],
|
props: ['a'],
|
||||||
|
@ -1077,7 +1078,7 @@ describe('api: watch', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('watching keypath', async () => {
|
test('watching keypath', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const Comp = defineComponent({
|
const Comp = defineComponent({
|
||||||
render() {},
|
render() {},
|
||||||
data() {
|
data() {
|
||||||
|
@ -1107,7 +1108,7 @@ describe('api: watch', () => {
|
||||||
|
|
||||||
it('watching sources: ref<any[]>', async () => {
|
it('watching sources: ref<any[]>', async () => {
|
||||||
const foo = ref([1])
|
const foo = ref([1])
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
watch(foo, () => {
|
watch(foo, () => {
|
||||||
spy()
|
spy()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Note: emits and listener fallthrough is tested in
|
// Note: emits and listener fallthrough is tested in
|
||||||
// ./rendererAttrsFallthrough.spec.ts.
|
// ./rendererAttrsFallthrough.spec.ts.
|
||||||
|
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
render,
|
render,
|
||||||
defineComponent,
|
defineComponent,
|
||||||
|
@ -23,9 +24,9 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onfoo = jest.fn()
|
const onfoo = vi.fn()
|
||||||
const onBar = jest.fn()
|
const onBar = vi.fn()
|
||||||
const onBaz = jest.fn()
|
const onBaz = vi.fn()
|
||||||
const Comp = () => h(Foo, { onfoo, onBar, ['on!baz']: onBaz })
|
const Comp = () => h(Foo, { onfoo, onBar, ['on!baz']: onBaz })
|
||||||
render(h(Comp), nodeOps.createElement('div'))
|
render(h(Comp), nodeOps.createElement('div'))
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fooSpy = jest.fn()
|
const fooSpy = vi.fn()
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
onTestEvent: fooSpy
|
onTestEvent: fooSpy
|
||||||
|
@ -61,7 +62,7 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fooSpy = jest.fn()
|
const fooSpy = vi.fn()
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
'onTest-event': fooSpy
|
'onTest-event': fooSpy
|
||||||
|
@ -81,8 +82,8 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fooSpy = jest.fn()
|
const fooSpy = vi.fn()
|
||||||
const barSpy = jest.fn()
|
const barSpy = vi.fn()
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
// simulate v-on="obj" usage
|
// simulate v-on="obj" usage
|
||||||
h(
|
h(
|
||||||
|
@ -108,8 +109,8 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fooSpy = jest.fn()
|
const fooSpy = vi.fn()
|
||||||
const barSpy = jest.fn()
|
const barSpy = vi.fn()
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
'onUpdate:fooProp': fooSpy,
|
'onUpdate:fooProp': fooSpy,
|
||||||
|
@ -129,8 +130,8 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
|
|
||||||
const App = {
|
const App = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -256,8 +257,8 @@ describe('component: emit', () => {
|
||||||
this.$emit('bar')
|
this.$emit('bar')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const barFn = jest.fn()
|
const barFn = vi.fn()
|
||||||
render(
|
render(
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
onFooOnce: fn,
|
onFooOnce: fn,
|
||||||
|
@ -280,8 +281,8 @@ describe('component: emit', () => {
|
||||||
this.$emit('foo')
|
this.$emit('foo')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const onFoo = jest.fn()
|
const onFoo = vi.fn()
|
||||||
const onFooOnce = jest.fn()
|
const onFooOnce = vi.fn()
|
||||||
render(
|
render(
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
onFoo,
|
onFoo,
|
||||||
|
@ -302,8 +303,8 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
|
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
|
@ -333,8 +334,8 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
|
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
|
@ -364,8 +365,8 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
|
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
|
@ -394,7 +395,7 @@ describe('component: emit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
h(Foo, {
|
h(Foo, {
|
||||||
modelValue: null,
|
modelValue: null,
|
||||||
|
@ -430,7 +431,7 @@ describe('component: emit', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('does not emit after unmount', async () => {
|
test('does not emit after unmount', async () => {
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const Foo = defineComponent({
|
const Foo = defineComponent({
|
||||||
emits: ['closing'],
|
emits: ['closing'],
|
||||||
async beforeUnmount() {
|
async beforeUnmount() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
ComponentInternalInstance,
|
ComponentInternalInstance,
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
|
@ -163,8 +164,8 @@ describe('component props', () => {
|
||||||
|
|
||||||
test('default value', () => {
|
test('default value', () => {
|
||||||
let proxy: any
|
let proxy: any
|
||||||
const defaultFn = jest.fn(() => ({ a: 1 }))
|
const defaultFn = vi.fn(() => ({ a: 1 }))
|
||||||
const defaultBaz = jest.fn(() => ({ b: 1 }))
|
const defaultBaz = vi.fn(() => ({ b: 1 }))
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
props: {
|
props: {
|
||||||
|
@ -536,7 +537,7 @@ describe('component props', () => {
|
||||||
// #3288
|
// #3288
|
||||||
test('declared prop key should be present even if not passed', async () => {
|
test('declared prop key should be present even if not passed', async () => {
|
||||||
let initialKeys: string[] = []
|
let initialKeys: string[] = []
|
||||||
const changeSpy = jest.fn()
|
const changeSpy = vi.fn()
|
||||||
const passFoo = ref(false)
|
const passFoo = ref(false)
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
render,
|
render,
|
||||||
|
@ -306,7 +307,7 @@ describe('component: proxy', () => {
|
||||||
|
|
||||||
// attaching jest spy, triggers the getter once, cache it and override the property.
|
// attaching jest spy, triggers the getter once, cache it and override the property.
|
||||||
// also uses Object.defineProperty
|
// also uses Object.defineProperty
|
||||||
const spy = jest.spyOn(instanceProxy, 'toggle')
|
const spy = vi.spyOn(instanceProxy, 'toggle')
|
||||||
expect(getCalledTimes).toEqual(3)
|
expect(getCalledTimes).toEqual(3)
|
||||||
|
|
||||||
// expect getter to not evaluate the jest spy caches its value
|
// expect getter to not evaluate the jest spy caches its value
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
render,
|
render,
|
||||||
|
@ -200,7 +201,7 @@ describe('component: slots', () => {
|
||||||
test('should respect $stable flag', async () => {
|
test('should respect $stable flag', async () => {
|
||||||
const flag1 = ref(1)
|
const flag1 = ref(1)
|
||||||
const flag2 = ref(2)
|
const flag2 = ref(2)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
const Child = () => {
|
const Child = () => {
|
||||||
spy()
|
spy()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
nodeOps,
|
nodeOps,
|
||||||
render,
|
render,
|
||||||
|
@ -44,28 +45,28 @@ function mockProps(extra: BaseTransitionProps = {}, withKeepAlive = false) {
|
||||||
doneLeave: {}
|
doneLeave: {}
|
||||||
}
|
}
|
||||||
const props: BaseTransitionProps = {
|
const props: BaseTransitionProps = {
|
||||||
onBeforeEnter: jest.fn(el => {
|
onBeforeEnter: vi.fn(el => {
|
||||||
if (!extra.persisted && !withKeepAlive) {
|
if (!extra.persisted && !withKeepAlive) {
|
||||||
expect(el.parentNode).toBeNull()
|
expect(el.parentNode).toBeNull()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
onEnter: jest.fn((el, done) => {
|
onEnter: vi.fn((el, done) => {
|
||||||
cbs.doneEnter[serialize(el as TestElement)] = done
|
cbs.doneEnter[serialize(el as TestElement)] = done
|
||||||
}),
|
}),
|
||||||
onAfterEnter: jest.fn(),
|
onAfterEnter: vi.fn(),
|
||||||
onEnterCancelled: jest.fn(),
|
onEnterCancelled: vi.fn(),
|
||||||
onBeforeLeave: jest.fn(),
|
onBeforeLeave: vi.fn(),
|
||||||
onLeave: jest.fn((el, done) => {
|
onLeave: vi.fn((el, done) => {
|
||||||
cbs.doneLeave[serialize(el as TestElement)] = done
|
cbs.doneLeave[serialize(el as TestElement)] = done
|
||||||
}),
|
}),
|
||||||
onAfterLeave: jest.fn(),
|
onAfterLeave: vi.fn(),
|
||||||
onLeaveCancelled: jest.fn(),
|
onLeaveCancelled: vi.fn(),
|
||||||
onBeforeAppear: jest.fn(),
|
onBeforeAppear: vi.fn(),
|
||||||
onAppear: jest.fn((el, done) => {
|
onAppear: vi.fn((el, done) => {
|
||||||
cbs.doneEnter[serialize(el as TestElement)] = done
|
cbs.doneEnter[serialize(el as TestElement)] = done
|
||||||
}),
|
}),
|
||||||
onAfterAppear: jest.fn(),
|
onAfterAppear: vi.fn(),
|
||||||
onAppearCancelled: jest.fn(),
|
onAppearCancelled: vi.fn(),
|
||||||
...extra
|
...extra
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -86,7 +87,7 @@ function assertCalls(
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertCalledWithEl(fn: any, expected: string, callIndex = 0) {
|
function assertCalledWithEl(fn: any, expected: string, callIndex = 0) {
|
||||||
expect(serialize((fn as jest.Mock).mock.calls[callIndex][0])).toBe(expected)
|
expect(serialize((fn as vi.Mock).mock.calls[callIndex][0])).toBe(expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ToggleOptions {
|
interface ToggleOptions {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
TestElement,
|
TestElement,
|
||||||
|
@ -43,11 +44,11 @@ describe('KeepAlive', () => {
|
||||||
render(this: any) {
|
render(this: any) {
|
||||||
return h('div', this.msg)
|
return h('div', this.msg)
|
||||||
},
|
},
|
||||||
created: jest.fn(),
|
created: vi.fn(),
|
||||||
mounted: jest.fn(),
|
mounted: vi.fn(),
|
||||||
activated: jest.fn(),
|
activated: vi.fn(),
|
||||||
deactivated: jest.fn(),
|
deactivated: vi.fn(),
|
||||||
unmounted: jest.fn()
|
unmounted: vi.fn()
|
||||||
}
|
}
|
||||||
two = {
|
two = {
|
||||||
name: 'two',
|
name: 'two',
|
||||||
|
@ -55,11 +56,11 @@ describe('KeepAlive', () => {
|
||||||
render(this: any) {
|
render(this: any) {
|
||||||
return h('div', this.msg)
|
return h('div', this.msg)
|
||||||
},
|
},
|
||||||
created: jest.fn(),
|
created: vi.fn(),
|
||||||
mounted: jest.fn(),
|
mounted: vi.fn(),
|
||||||
activated: jest.fn(),
|
activated: vi.fn(),
|
||||||
deactivated: jest.fn(),
|
deactivated: vi.fn(),
|
||||||
unmounted: jest.fn()
|
unmounted: vi.fn()
|
||||||
}
|
}
|
||||||
views = {
|
views = {
|
||||||
one,
|
one,
|
||||||
|
@ -225,7 +226,7 @@ describe('KeepAlive', () => {
|
||||||
render(this: any) {
|
render(this: any) {
|
||||||
return h('div', this.msg)
|
return h('div', this.msg)
|
||||||
},
|
},
|
||||||
activated: jest.fn()
|
activated: vi.fn()
|
||||||
}
|
}
|
||||||
const one = {
|
const one = {
|
||||||
name: 'one',
|
name: 'one',
|
||||||
|
@ -399,18 +400,18 @@ describe('KeepAlive', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('max', async () => {
|
test('max', async () => {
|
||||||
const spyAC = jest.fn()
|
const spyAC = vi.fn()
|
||||||
const spyBC = jest.fn()
|
const spyBC = vi.fn()
|
||||||
const spyCC = jest.fn()
|
const spyCC = vi.fn()
|
||||||
const spyAA = jest.fn()
|
const spyAA = vi.fn()
|
||||||
const spyBA = jest.fn()
|
const spyBA = vi.fn()
|
||||||
const spyCA = jest.fn()
|
const spyCA = vi.fn()
|
||||||
const spyADA = jest.fn()
|
const spyADA = vi.fn()
|
||||||
const spyBDA = jest.fn()
|
const spyBDA = vi.fn()
|
||||||
const spyCDA = jest.fn()
|
const spyCDA = vi.fn()
|
||||||
const spyAUM = jest.fn()
|
const spyAUM = vi.fn()
|
||||||
const spyBUM = jest.fn()
|
const spyBUM = vi.fn()
|
||||||
const spyCUM = jest.fn()
|
const spyCUM = vi.fn()
|
||||||
|
|
||||||
function assertCount(calls: number[]) {
|
function assertCount(calls: number[]) {
|
||||||
expect([
|
expect([
|
||||||
|
@ -609,13 +610,13 @@ describe('KeepAlive', () => {
|
||||||
async function assertAnonymous(include: boolean) {
|
async function assertAnonymous(include: boolean) {
|
||||||
const one = {
|
const one = {
|
||||||
name: 'one',
|
name: 'one',
|
||||||
created: jest.fn(),
|
created: vi.fn(),
|
||||||
render: () => 'one'
|
render: () => 'one'
|
||||||
}
|
}
|
||||||
|
|
||||||
const two = {
|
const two = {
|
||||||
// anonymous
|
// anonymous
|
||||||
created: jest.fn(),
|
created: vi.fn(),
|
||||||
render: () => 'two'
|
render: () => 'two'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,7 +671,7 @@ describe('KeepAlive', () => {
|
||||||
test('should not destroy active instance when pruning cache', async () => {
|
test('should not destroy active instance when pruning cache', async () => {
|
||||||
const Foo = {
|
const Foo = {
|
||||||
render: () => 'foo',
|
render: () => 'foo',
|
||||||
unmounted: jest.fn()
|
unmounted: vi.fn()
|
||||||
}
|
}
|
||||||
const includeRef = ref(['foo'])
|
const includeRef = ref(['foo'])
|
||||||
const App = {
|
const App = {
|
||||||
|
@ -735,8 +736,8 @@ describe('KeepAlive', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const spyMounted = jest.fn()
|
const spyMounted = vi.fn()
|
||||||
const spyUnmounted = jest.fn()
|
const spyUnmounted = vi.fn()
|
||||||
|
|
||||||
const RouterView = defineComponent({
|
const RouterView = defineComponent({
|
||||||
setup(_, { slots }) {
|
setup(_, { slots }) {
|
||||||
|
@ -885,7 +886,7 @@ describe('KeepAlive', () => {
|
||||||
// #4976
|
// #4976
|
||||||
test('handle error in async onActivated', async () => {
|
test('handle error in async onActivated', async () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const handler = jest.fn()
|
const handler = vi.fn()
|
||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -911,12 +912,12 @@ describe('KeepAlive', () => {
|
||||||
|
|
||||||
// #3648
|
// #3648
|
||||||
test('should avoid unmount later included components', async () => {
|
test('should avoid unmount later included components', async () => {
|
||||||
const unmountedA = jest.fn()
|
const unmountedA = vi.fn()
|
||||||
const mountedA = jest.fn()
|
const mountedA = vi.fn()
|
||||||
const activatedA = jest.fn()
|
const activatedA = vi.fn()
|
||||||
const deactivatedA = jest.fn()
|
const deactivatedA = vi.fn()
|
||||||
const unmountedB = jest.fn()
|
const unmountedB = vi.fn()
|
||||||
const mountedB = jest.fn()
|
const mountedB = vi.fn()
|
||||||
|
|
||||||
const A = {
|
const A = {
|
||||||
name: 'A',
|
name: 'A',
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
ref,
|
ref,
|
||||||
|
@ -76,9 +77,9 @@ describe('Suspense', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onFallback = jest.fn()
|
const onFallback = vi.fn()
|
||||||
const onResolve = jest.fn()
|
const onResolve = vi.fn()
|
||||||
const onPending = jest.fn()
|
const onPending = vi.fn()
|
||||||
|
|
||||||
const show = ref(true)
|
const show = ref(true)
|
||||||
const Comp = {
|
const Comp = {
|
||||||
|
@ -190,7 +191,7 @@ describe('Suspense', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onResolve = jest.fn()
|
const onResolve = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -451,7 +452,7 @@ describe('Suspense', () => {
|
||||||
|
|
||||||
test('unmount suspense after resolve', async () => {
|
test('unmount suspense after resolve', async () => {
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const unmounted = jest.fn()
|
const unmounted = vi.fn()
|
||||||
|
|
||||||
const Async = defineAsyncComponent({
|
const Async = defineAsyncComponent({
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -489,8 +490,8 @@ describe('Suspense', () => {
|
||||||
|
|
||||||
test('unmount suspense before resolve', async () => {
|
test('unmount suspense before resolve', async () => {
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const mounted = jest.fn()
|
const mounted = vi.fn()
|
||||||
const unmounted = jest.fn()
|
const unmounted = vi.fn()
|
||||||
|
|
||||||
const Async = defineAsyncComponent({
|
const Async = defineAsyncComponent({
|
||||||
setup() {
|
setup() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
nodeOps,
|
nodeOps,
|
||||||
serializeInner,
|
serializeInner,
|
||||||
|
@ -440,8 +441,8 @@ describe('renderer: teleport', () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const dir = {
|
const dir = {
|
||||||
mounted: jest.fn(),
|
mounted: vi.fn(),
|
||||||
unmounted: jest.fn()
|
unmounted: vi.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
withDirectives,
|
withDirectives,
|
||||||
|
@ -23,7 +24,7 @@ describe('directives', () => {
|
||||||
expect(binding.modifiers && binding.modifiers.ok).toBe(true)
|
expect(binding.modifiers && binding.modifiers.ok).toBe(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const beforeMount = jest.fn(((el, binding, vnode, prevVNode) => {
|
const beforeMount = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
// should not be inserted yet
|
// should not be inserted yet
|
||||||
expect(el.parentNode).toBe(null)
|
expect(el.parentNode).toBe(null)
|
||||||
|
@ -35,7 +36,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode).toBe(null)
|
expect(prevVNode).toBe(null)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const mounted = jest.fn(((el, binding, vnode, prevVNode) => {
|
const mounted = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
// should be inserted now
|
// should be inserted now
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
|
@ -47,7 +48,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode).toBe(null)
|
expect(prevVNode).toBe(null)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const beforeUpdate = jest.fn(((el, binding, vnode, prevVNode) => {
|
const beforeUpdate = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
expect(root.children[0]).toBe(el)
|
expect(root.children[0]).toBe(el)
|
||||||
|
@ -61,7 +62,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode).toBe(_prevVnode)
|
expect(prevVNode).toBe(_prevVnode)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const updated = jest.fn(((el, binding, vnode, prevVNode) => {
|
const updated = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
expect(root.children[0]).toBe(el)
|
expect(root.children[0]).toBe(el)
|
||||||
|
@ -75,7 +76,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode).toBe(_prevVnode)
|
expect(prevVNode).toBe(_prevVnode)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const beforeUnmount = jest.fn(((el, binding, vnode, prevVNode) => {
|
const beforeUnmount = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
// should be removed now
|
// should be removed now
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
|
@ -87,7 +88,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode).toBe(null)
|
expect(prevVNode).toBe(null)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const unmounted = jest.fn(((el, binding, vnode, prevVNode) => {
|
const unmounted = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
// should have been removed
|
// should have been removed
|
||||||
expect(el.parentNode).toBe(null)
|
expect(el.parentNode).toBe(null)
|
||||||
|
@ -158,7 +159,7 @@ describe('directives', () => {
|
||||||
expect(binding.modifiers && binding.modifiers.ok).toBe(true)
|
expect(binding.modifiers && binding.modifiers.ok).toBe(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn = jest.fn(((el, binding, vnode, prevVNode) => {
|
const fn = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ describe('directives', () => {
|
||||||
expect(binding.modifiers && binding.modifiers.ok).toBe(true)
|
expect(binding.modifiers && binding.modifiers.ok).toBe(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const beforeMount = jest.fn(((el, binding, vnode, prevVNode) => {
|
const beforeMount = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
// should not be inserted yet
|
// should not be inserted yet
|
||||||
expect(el.parentNode).toBe(null)
|
expect(el.parentNode).toBe(null)
|
||||||
|
@ -224,7 +225,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode).toBe(null)
|
expect(prevVNode).toBe(null)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const mounted = jest.fn(((el, binding, vnode, prevVNode) => {
|
const mounted = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
// should be inserted now
|
// should be inserted now
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
|
@ -236,7 +237,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode).toBe(null)
|
expect(prevVNode).toBe(null)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const beforeUpdate = jest.fn(((el, binding, vnode, prevVNode) => {
|
const beforeUpdate = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
expect(root.children[0]).toBe(el)
|
expect(root.children[0]).toBe(el)
|
||||||
|
@ -250,7 +251,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode!.type).toBe(_prevVnode!.type)
|
expect(prevVNode!.type).toBe(_prevVnode!.type)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const updated = jest.fn(((el, binding, vnode, prevVNode) => {
|
const updated = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
expect(root.children[0]).toBe(el)
|
expect(root.children[0]).toBe(el)
|
||||||
|
@ -264,7 +265,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode!.type).toBe(_prevVnode!.type)
|
expect(prevVNode!.type).toBe(_prevVnode!.type)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const beforeUnmount = jest.fn(((el, binding, vnode, prevVNode) => {
|
const beforeUnmount = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
// should be removed now
|
// should be removed now
|
||||||
expect(el.parentNode).toBe(root)
|
expect(el.parentNode).toBe(root)
|
||||||
|
@ -276,7 +277,7 @@ describe('directives', () => {
|
||||||
expect(prevVNode).toBe(null)
|
expect(prevVNode).toBe(null)
|
||||||
}) as DirectiveHook)
|
}) as DirectiveHook)
|
||||||
|
|
||||||
const unmounted = jest.fn(((el, binding, vnode, prevVNode) => {
|
const unmounted = vi.fn(((el, binding, vnode, prevVNode) => {
|
||||||
expect(el.tag).toBe('div')
|
expect(el.tag).toBe('div')
|
||||||
// should have been removed
|
// should have been removed
|
||||||
expect(el.parentNode).toBe(null)
|
expect(el.parentNode).toBe(null)
|
||||||
|
@ -345,10 +346,10 @@ describe('directives', () => {
|
||||||
// #2298
|
// #2298
|
||||||
it('directive merging on component root', () => {
|
it('directive merging on component root', () => {
|
||||||
const d1 = {
|
const d1 = {
|
||||||
mounted: jest.fn()
|
mounted: vi.fn()
|
||||||
}
|
}
|
||||||
const d2 = {
|
const d2 = {
|
||||||
mounted: jest.fn()
|
mounted: vi.fn()
|
||||||
}
|
}
|
||||||
const Comp = {
|
const Comp = {
|
||||||
render() {
|
render() {
|
||||||
|
@ -372,7 +373,7 @@ describe('directives', () => {
|
||||||
test('should disable tracking inside directive lifecycle hooks', async () => {
|
test('should disable tracking inside directive lifecycle hooks', async () => {
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const text = ref('')
|
const text = ref('')
|
||||||
const beforeUpdate = jest.fn(() => count.value++)
|
const beforeUpdate = vi.fn(() => count.value++)
|
||||||
|
|
||||||
const App = {
|
const App = {
|
||||||
render() {
|
render() {
|
||||||
|
@ -424,7 +425,7 @@ describe('directives', () => {
|
||||||
|
|
||||||
test('should not throw with unknown directive', async () => {
|
test('should not throw with unknown directive', async () => {
|
||||||
const d1 = {
|
const d1 = {
|
||||||
mounted: jest.fn()
|
mounted: vi.fn()
|
||||||
}
|
}
|
||||||
const App = {
|
const App = {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
onMounted,
|
onMounted,
|
||||||
onErrorCaptured,
|
onErrorCaptured,
|
||||||
|
@ -15,7 +16,7 @@ import {
|
||||||
describe('error handling', () => {
|
describe('error handling', () => {
|
||||||
test('propagation', () => {
|
test('propagation', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -53,7 +54,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('propagation stoppage', () => {
|
test('propagation stoppage', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -91,7 +92,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('async error handling', async () => {
|
test('async error handling', async () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -121,7 +122,7 @@ describe('error handling', () => {
|
||||||
test('error thrown in onErrorCaptured', () => {
|
test('error thrown in onErrorCaptured', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const err2 = new Error('bar')
|
const err2 = new Error('bar')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -159,7 +160,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('setup function', () => {
|
test('setup function', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -186,7 +187,7 @@ describe('error handling', () => {
|
||||||
// the options API initialization process instead of by the renderer.
|
// the options API initialization process instead of by the renderer.
|
||||||
test('in created/beforeCreate hook', () => {
|
test('in created/beforeCreate hook', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -219,7 +220,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('in render function', () => {
|
test('in render function', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -248,7 +249,7 @@ describe('error handling', () => {
|
||||||
const ref = () => {
|
const ref = () => {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -268,7 +269,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('in effect', () => {
|
test('in effect', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -295,7 +296,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('in watch getter', () => {
|
test('in watch getter', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -325,7 +326,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('in watch callback', async () => {
|
test('in watch callback', async () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -360,7 +361,7 @@ describe('error handling', () => {
|
||||||
test('in effect cleanup', async () => {
|
test('in effect cleanup', async () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -393,7 +394,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('in component event handler via emit', () => {
|
test('in component event handler via emit', () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -423,7 +424,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('in component event handler via emit (async)', async () => {
|
test('in component event handler via emit (async)', async () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -455,7 +456,7 @@ describe('error handling', () => {
|
||||||
|
|
||||||
test('in component event handler via emit (async + array)', async () => {
|
test('in component event handler via emit (async + array)', async () => {
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const res: Promise<any>[] = []
|
const res: Promise<any>[] = []
|
||||||
const createAsyncHandler = (p: Promise<any>) => () => {
|
const createAsyncHandler = (p: Promise<any>) => () => {
|
||||||
|
@ -497,13 +498,13 @@ describe('error handling', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should warn unhandled', () => {
|
it('should warn unhandled', () => {
|
||||||
const groupCollapsed = jest.spyOn(console, 'groupCollapsed')
|
const groupCollapsed = vi.spyOn(console, 'groupCollapsed')
|
||||||
groupCollapsed.mockImplementation(() => {})
|
groupCollapsed.mockImplementation(() => {})
|
||||||
const log = jest.spyOn(console, 'log')
|
const log = vi.spyOn(console, 'log')
|
||||||
log.mockImplementation(() => {})
|
log.mockImplementation(() => {})
|
||||||
|
|
||||||
const err = new Error('foo')
|
const err = new Error('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -543,7 +544,7 @@ describe('error handling', () => {
|
||||||
const error2 = new Error('error2')
|
const error2 = new Error('error2')
|
||||||
const error3 = new Error('error3')
|
const error3 = new Error('error3')
|
||||||
const error4 = new Error('error4')
|
const error4 = new Error('error4')
|
||||||
const handler = jest.fn()
|
const handler = vi.fn()
|
||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
setup() {
|
setup() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { HMRRuntime } from '../src/hmr'
|
import { HMRRuntime } from '../src/hmr'
|
||||||
import '../src/hmr'
|
import '../src/hmr'
|
||||||
import { ComponentOptions, InternalRenderFunction } from '../src/component'
|
import { ComponentOptions, InternalRenderFunction } from '../src/component'
|
||||||
|
@ -117,8 +118,8 @@ describe('hot module replacement', () => {
|
||||||
test('reload', async () => {
|
test('reload', async () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const childId = 'test3-child'
|
const childId = 'test3-child'
|
||||||
const unmountSpy = jest.fn()
|
const unmountSpy = vi.fn()
|
||||||
const mountSpy = jest.fn()
|
const mountSpy = vi.fn()
|
||||||
|
|
||||||
const Child: ComponentOptions = {
|
const Child: ComponentOptions = {
|
||||||
__hmrId: childId,
|
__hmrId: childId,
|
||||||
|
@ -155,10 +156,10 @@ describe('hot module replacement', () => {
|
||||||
test('reload KeepAlive slot', async () => {
|
test('reload KeepAlive slot', async () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const childId = 'test-child-keep-alive'
|
const childId = 'test-child-keep-alive'
|
||||||
const unmountSpy = jest.fn()
|
const unmountSpy = vi.fn()
|
||||||
const mountSpy = jest.fn()
|
const mountSpy = vi.fn()
|
||||||
const activeSpy = jest.fn()
|
const activeSpy = vi.fn()
|
||||||
const deactiveSpy = jest.fn()
|
const deactiveSpy = vi.fn()
|
||||||
|
|
||||||
const Child: ComponentOptions = {
|
const Child: ComponentOptions = {
|
||||||
__hmrId: childId,
|
__hmrId: childId,
|
||||||
|
@ -221,8 +222,8 @@ describe('hot module replacement', () => {
|
||||||
test('reload class component', async () => {
|
test('reload class component', async () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const childId = 'test4-child'
|
const childId = 'test4-child'
|
||||||
const unmountSpy = jest.fn()
|
const unmountSpy = vi.fn()
|
||||||
const mountSpy = jest.fn()
|
const mountSpy = vi.fn()
|
||||||
|
|
||||||
class Child {
|
class Child {
|
||||||
static __vccOpts: ComponentOptions = {
|
static __vccOpts: ComponentOptions = {
|
||||||
|
@ -467,8 +468,8 @@ describe('hot module replacement', () => {
|
||||||
// #4174
|
// #4174
|
||||||
test('with global mixins', async () => {
|
test('with global mixins', async () => {
|
||||||
const childId = 'hmr-global-mixin'
|
const childId = 'hmr-global-mixin'
|
||||||
const createSpy1 = jest.fn()
|
const createSpy1 = vi.fn()
|
||||||
const createSpy2 = jest.fn()
|
const createSpy2 = vi.fn()
|
||||||
|
|
||||||
const Child: ComponentOptions = {
|
const Child: ComponentOptions = {
|
||||||
__hmrId: childId,
|
__hmrId: childId,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
createSSRApp,
|
createSSRApp,
|
||||||
h,
|
h,
|
||||||
|
@ -134,7 +135,7 @@ describe('SSR hydration', () => {
|
||||||
|
|
||||||
test('element with elements children', async () => {
|
test('element with elements children', async () => {
|
||||||
const msg = ref('foo')
|
const msg = ref('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const { vnode, container } = mountWithHydration(
|
const { vnode, container } = mountWithHydration(
|
||||||
'<div><span>foo</span><span class="foo"></span></div>',
|
'<div><span>foo</span><span class="foo"></span></div>',
|
||||||
() =>
|
() =>
|
||||||
|
@ -171,7 +172,7 @@ describe('SSR hydration', () => {
|
||||||
|
|
||||||
test('Fragment', async () => {
|
test('Fragment', async () => {
|
||||||
const msg = ref('foo')
|
const msg = ref('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const { vnode, container } = mountWithHydration(
|
const { vnode, container } = mountWithHydration(
|
||||||
'<div><!--[--><span>foo</span><!--[--><span class="foo"></span><!--]--><!--]--></div>',
|
'<div><!--[--><span>foo</span><!--[--><span class="foo"></span><!--]--><!--]--></div>',
|
||||||
() =>
|
() =>
|
||||||
|
@ -222,7 +223,7 @@ describe('SSR hydration', () => {
|
||||||
|
|
||||||
test('Teleport', async () => {
|
test('Teleport', async () => {
|
||||||
const msg = ref('foo')
|
const msg = ref('foo')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const teleportContainer = document.createElement('div')
|
const teleportContainer = document.createElement('div')
|
||||||
teleportContainer.id = 'teleport'
|
teleportContainer.id = 'teleport'
|
||||||
teleportContainer.innerHTML = `<span>foo</span><span class="foo"></span><!--teleport anchor-->`
|
teleportContainer.innerHTML = `<span>foo</span><span class="foo"></span><!--teleport anchor-->`
|
||||||
|
@ -262,8 +263,8 @@ describe('SSR hydration', () => {
|
||||||
|
|
||||||
test('Teleport (multiple + integration)', async () => {
|
test('Teleport (multiple + integration)', async () => {
|
||||||
const msg = ref('foo')
|
const msg = ref('foo')
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
|
|
||||||
const Comp = () => [
|
const Comp = () => [
|
||||||
h(Teleport, { to: '#teleport2' }, [
|
h(Teleport, { to: '#teleport2' }, [
|
||||||
|
@ -329,8 +330,8 @@ describe('SSR hydration', () => {
|
||||||
|
|
||||||
test('Teleport (disabled)', async () => {
|
test('Teleport (disabled)', async () => {
|
||||||
const msg = ref('foo')
|
const msg = ref('foo')
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
|
|
||||||
const Comp = () => [
|
const Comp = () => [
|
||||||
h('div', 'foo'),
|
h('div', 'foo'),
|
||||||
|
@ -453,7 +454,7 @@ describe('SSR hydration', () => {
|
||||||
// compile SSR + client render fn from the same template & hydrate
|
// compile SSR + client render fn from the same template & hydrate
|
||||||
test('full compiler integration', async () => {
|
test('full compiler integration', async () => {
|
||||||
const mounted: string[] = []
|
const mounted: string[] = []
|
||||||
const log = jest.fn()
|
const log = vi.fn()
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
|
|
||||||
const Child = {
|
const Child = {
|
||||||
|
@ -564,7 +565,7 @@ describe('SSR hydration', () => {
|
||||||
container.innerHTML = await renderToString(h(App))
|
container.innerHTML = await renderToString(h(App))
|
||||||
// hydrate
|
// hydrate
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
app.mount(container)
|
app.mount(container)
|
||||||
// assert interactions
|
// assert interactions
|
||||||
// parent button click
|
// parent button click
|
||||||
|
@ -591,7 +592,7 @@ describe('SSR hydration', () => {
|
||||||
container.innerHTML = await renderToString(h(App))
|
container.innerHTML = await renderToString(h(App))
|
||||||
// hydrate
|
// hydrate
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
const handler = (app.config.errorHandler = jest.fn())
|
const handler = (app.config.errorHandler = vi.fn())
|
||||||
app.mount(container)
|
app.mount(container)
|
||||||
// assert interactions
|
// assert interactions
|
||||||
// parent blur event
|
// parent blur event
|
||||||
|
@ -653,7 +654,7 @@ describe('SSR hydration', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const done = jest.fn()
|
const done = vi.fn()
|
||||||
const App = {
|
const App = {
|
||||||
template: `
|
template: `
|
||||||
<Suspense @resolve="done">
|
<Suspense @resolve="done">
|
||||||
|
@ -710,7 +711,7 @@ describe('SSR hydration', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('async component', async () => {
|
test('async component', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const Comp = () =>
|
const Comp = () =>
|
||||||
h(
|
h(
|
||||||
'button',
|
'button',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// using DOM renderer because this case is mostly DOM-specific
|
// using DOM renderer because this case is mostly DOM-specific
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
render,
|
render,
|
||||||
|
@ -18,8 +19,8 @@ import { PatchFlags } from '@vue/shared/src'
|
||||||
|
|
||||||
describe('attribute fallthrough', () => {
|
describe('attribute fallthrough', () => {
|
||||||
it('should allow attrs to fallthrough', async () => {
|
it('should allow attrs to fallthrough', async () => {
|
||||||
const click = jest.fn()
|
const click = vi.fn()
|
||||||
const childUpdated = jest.fn()
|
const childUpdated = vi.fn()
|
||||||
|
|
||||||
const Hello = {
|
const Hello = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -83,8 +84,8 @@ describe('attribute fallthrough', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should only allow whitelisted fallthrough on functional component with optional props', async () => {
|
it('should only allow whitelisted fallthrough on functional component with optional props', async () => {
|
||||||
const click = jest.fn()
|
const click = vi.fn()
|
||||||
const childUpdated = jest.fn()
|
const childUpdated = vi.fn()
|
||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
|
|
||||||
|
@ -141,8 +142,8 @@ describe('attribute fallthrough', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should allow all attrs on functional component with declared props', async () => {
|
it('should allow all attrs on functional component with declared props', async () => {
|
||||||
const click = jest.fn()
|
const click = vi.fn()
|
||||||
const childUpdated = jest.fn()
|
const childUpdated = vi.fn()
|
||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
|
|
||||||
|
@ -197,9 +198,9 @@ describe('attribute fallthrough', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should fallthrough for nested components', async () => {
|
it('should fallthrough for nested components', async () => {
|
||||||
const click = jest.fn()
|
const click = vi.fn()
|
||||||
const childUpdated = jest.fn()
|
const childUpdated = vi.fn()
|
||||||
const grandChildUpdated = jest.fn()
|
const grandChildUpdated = vi.fn()
|
||||||
|
|
||||||
const Hello = {
|
const Hello = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -385,7 +386,7 @@ describe('attribute fallthrough', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should dedupe same listeners when $attrs is used during render', () => {
|
it('should dedupe same listeners when $attrs is used during render', () => {
|
||||||
const click = jest.fn()
|
const click = vi.fn()
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
|
|
||||||
function inc() {
|
function inc() {
|
||||||
|
@ -580,7 +581,7 @@ describe('attribute fallthrough', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onClick = jest.fn()
|
const onClick = vi.fn()
|
||||||
const App = {
|
const App = {
|
||||||
render() {
|
render() {
|
||||||
return h(Child, {
|
return h(Child, {
|
||||||
|
@ -611,7 +612,7 @@ describe('attribute fallthrough', () => {
|
||||||
}
|
}
|
||||||
Child.emits = ['click']
|
Child.emits = ['click']
|
||||||
|
|
||||||
const onClick = jest.fn()
|
const onClick = vi.fn()
|
||||||
const App = {
|
const App = {
|
||||||
render() {
|
render() {
|
||||||
return h(Child, {
|
return h(Child, {
|
||||||
|
@ -631,7 +632,7 @@ describe('attribute fallthrough', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support fallthrough for fragments with single element + comments', () => {
|
it('should support fallthrough for fragments with single element + comments', () => {
|
||||||
const click = jest.fn()
|
const click = vi.fn()
|
||||||
|
|
||||||
const Hello = {
|
const Hello = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -673,7 +674,7 @@ describe('attribute fallthrough', () => {
|
||||||
it('should not fallthrough v-model listeners with corresponding declared prop', () => {
|
it('should not fallthrough v-model listeners with corresponding declared prop', () => {
|
||||||
let textFoo = ''
|
let textFoo = ''
|
||||||
let textBar = ''
|
let textBar = ''
|
||||||
const click = jest.fn()
|
const click = vi.fn()
|
||||||
|
|
||||||
const App = defineComponent({
|
const App = defineComponent({
|
||||||
setup() {
|
setup() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
h,
|
h,
|
||||||
|
@ -91,7 +92,7 @@ describe('renderer: component', () => {
|
||||||
it('should not update Component if only changed props are declared emit listeners', () => {
|
it('should not update Component if only changed props are declared emit listeners', () => {
|
||||||
const Comp1 = {
|
const Comp1 = {
|
||||||
emits: ['foo'],
|
emits: ['foo'],
|
||||||
updated: jest.fn(),
|
updated: vi.fn(),
|
||||||
render: () => null
|
render: () => null
|
||||||
}
|
}
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
|
@ -145,8 +146,8 @@ describe('renderer: component', () => {
|
||||||
function returnThis(this: any, _arg: any) {
|
function returnThis(this: any, _arg: any) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
const propWatchSpy = jest.fn(returnThis)
|
const propWatchSpy = vi.fn(returnThis)
|
||||||
const dataWatchSpy = jest.fn(returnThis)
|
const dataWatchSpy = vi.fn(returnThis)
|
||||||
let instance: any
|
let instance: any
|
||||||
const Comp = {
|
const Comp = {
|
||||||
props: {
|
props: {
|
||||||
|
@ -267,7 +268,7 @@ describe('renderer: component', () => {
|
||||||
setup() {
|
setup() {
|
||||||
return () => h(Child)
|
return () => h(Child)
|
||||||
},
|
},
|
||||||
updated: jest.fn()
|
updated: vi.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
|
@ -327,7 +328,7 @@ describe('renderer: component', () => {
|
||||||
|
|
||||||
test('child component props update should not lead to double update', async () => {
|
test('child component props update should not lead to double update', async () => {
|
||||||
const text = ref(0)
|
const text = ref(0)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
const App = {
|
const App = {
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
Fragment,
|
Fragment,
|
||||||
|
@ -343,8 +344,8 @@ describe('renderer: optimized mode', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('PatchFlags: PatchFlags.NEED_PATCH', async () => {
|
test('PatchFlags: PatchFlags.NEED_PATCH', async () => {
|
||||||
const spyMounted = jest.fn()
|
const spyMounted = vi.fn()
|
||||||
const spyUpdated = jest.fn()
|
const spyUpdated = vi.fn()
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const Comp = {
|
const Comp = {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -469,7 +470,7 @@ describe('renderer: optimized mode', () => {
|
||||||
// When unmounting (1), we know we are in optimized mode so no need to further
|
// When unmounting (1), we know we are in optimized mode so no need to further
|
||||||
// traverse unmount its children
|
// traverse unmount its children
|
||||||
test('should not perform unnecessary unmount traversals', () => {
|
test('should not perform unnecessary unmount traversals', () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const Child = {
|
const Child = {
|
||||||
setup() {
|
setup() {
|
||||||
onBeforeUnmount(spy)
|
onBeforeUnmount(spy)
|
||||||
|
@ -490,8 +491,8 @@ describe('renderer: optimized mode', () => {
|
||||||
// #2444
|
// #2444
|
||||||
// `KEYED_FRAGMENT` and `UNKEYED_FRAGMENT` always need to diff its children
|
// `KEYED_FRAGMENT` and `UNKEYED_FRAGMENT` always need to diff its children
|
||||||
test('non-stable Fragment always need to diff its children', () => {
|
test('non-stable Fragment always need to diff its children', () => {
|
||||||
const spyA = jest.fn()
|
const spyA = vi.fn()
|
||||||
const spyB = jest.fn()
|
const spyB = vi.fn()
|
||||||
const ChildA = {
|
const ChildA = {
|
||||||
setup() {
|
setup() {
|
||||||
onBeforeUnmount(spyA)
|
onBeforeUnmount(spyA)
|
||||||
|
@ -830,7 +831,7 @@ describe('renderer: optimized mode', () => {
|
||||||
// #4183
|
// #4183
|
||||||
test('should not take unmount children fast path /w Suspense', async () => {
|
test('should not take unmount children fast path /w Suspense', async () => {
|
||||||
const show = ref(true)
|
const show = ref(true)
|
||||||
const spyUnmounted = jest.fn()
|
const spyUnmounted = vi.fn()
|
||||||
|
|
||||||
const Parent = {
|
const Parent = {
|
||||||
setup(props: any, { slots }: SetupContext) {
|
setup(props: any, { slots }: SetupContext) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
nodeOps,
|
nodeOps,
|
||||||
|
@ -83,7 +84,7 @@ describe('api: template refs', () => {
|
||||||
|
|
||||||
it('function ref mount', () => {
|
it('function ref mount', () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
|
|
||||||
const Comp = defineComponent(() => () => h('div', { ref: fn }))
|
const Comp = defineComponent(() => () => h('div', { ref: fn }))
|
||||||
render(h(Comp), root)
|
render(h(Comp), root)
|
||||||
|
@ -92,8 +93,8 @@ describe('api: template refs', () => {
|
||||||
|
|
||||||
it('function ref update', async () => {
|
it('function ref update', async () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
const fn = ref(fn1)
|
const fn = ref(fn1)
|
||||||
|
|
||||||
const Comp = defineComponent(() => () => h('div', { ref: fn.value }))
|
const Comp = defineComponent(() => () => h('div', { ref: fn.value }))
|
||||||
|
@ -112,7 +113,7 @@ describe('api: template refs', () => {
|
||||||
|
|
||||||
it('function ref unmount', async () => {
|
it('function ref unmount', async () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
|
|
||||||
const Comp = defineComponent(
|
const Comp = defineComponent(
|
||||||
|
@ -181,7 +182,7 @@ describe('api: template refs', () => {
|
||||||
|
|
||||||
test('string ref inside slots', async () => {
|
test('string ref inside slots', async () => {
|
||||||
const root = nodeOps.createElement('div')
|
const root = nodeOps.createElement('div')
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const Child = {
|
const Child = {
|
||||||
render(this: any) {
|
render(this: any) {
|
||||||
return this.$slots.default()
|
return this.$slots.default()
|
||||||
|
@ -273,7 +274,7 @@ describe('api: template refs', () => {
|
||||||
// #1834
|
// #1834
|
||||||
test('exchange refs', async () => {
|
test('exchange refs', async () => {
|
||||||
const refToggle = ref(false)
|
const refToggle = ref(false)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
render(this: any) {
|
render(this: any) {
|
||||||
|
@ -304,7 +305,7 @@ describe('api: template refs', () => {
|
||||||
// #1789
|
// #1789
|
||||||
test('toggle the same ref to different elements', async () => {
|
test('toggle the same ref to different elements', async () => {
|
||||||
const refToggle = ref(false)
|
const refToggle = ref(false)
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
const Comp = {
|
const Comp = {
|
||||||
render(this: any) {
|
render(this: any) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
queueJob,
|
queueJob,
|
||||||
nextTick,
|
nextTick,
|
||||||
|
@ -187,7 +188,7 @@ describe('scheduler', () => {
|
||||||
|
|
||||||
// #3806
|
// #3806
|
||||||
it('queue preFlushCb inside postFlushCb', async () => {
|
it('queue preFlushCb inside postFlushCb', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const cb = () => spy()
|
const cb = () => spy()
|
||||||
cb.pre = true
|
cb.pre = true
|
||||||
queuePostFlushCb(() => {
|
queuePostFlushCb(() => {
|
||||||
|
@ -515,7 +516,7 @@ describe('scheduler', () => {
|
||||||
|
|
||||||
// #910
|
// #910
|
||||||
test('should not run stopped reactive effects', async () => {
|
test('should not run stopped reactive effects', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
|
|
||||||
// simulate parent component that toggles child
|
// simulate parent component that toggles child
|
||||||
const job1 = () => {
|
const job1 = () => {
|
||||||
|
@ -536,7 +537,7 @@ describe('scheduler', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('flushPreFlushCbs inside a pre job', async () => {
|
it('flushPreFlushCbs inside a pre job', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const job = () => {
|
const job = () => {
|
||||||
spy()
|
spy()
|
||||||
flushPreFlushCbs()
|
flushPreFlushCbs()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
createBlock,
|
createBlock,
|
||||||
createVNode,
|
createVNode,
|
||||||
|
@ -120,7 +121,7 @@ describe('vnode', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('children normalization', () => {
|
describe('children normalization', () => {
|
||||||
const nop = jest.fn
|
const nop = vi.fn
|
||||||
|
|
||||||
test('null', () => {
|
test('null', () => {
|
||||||
const vnode = createVNode('p', null, null)
|
const vnode = createVNode('p', null, null)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
render,
|
render,
|
||||||
|
@ -40,22 +41,22 @@ describe('renderer: vnode hooks', () => {
|
||||||
|
|
||||||
test('should work on element', () => {
|
test('should work on element', () => {
|
||||||
const hooks: VNodeProps = {
|
const hooks: VNodeProps = {
|
||||||
onVnodeBeforeMount: jest.fn(),
|
onVnodeBeforeMount: vi.fn(),
|
||||||
onVnodeMounted: jest.fn(),
|
onVnodeMounted: vi.fn(),
|
||||||
onVnodeBeforeUpdate: jest.fn(vnode => {
|
onVnodeBeforeUpdate: vi.fn(vnode => {
|
||||||
expect((vnode.el as TestElement).children[0]).toMatchObject({
|
expect((vnode.el as TestElement).children[0]).toMatchObject({
|
||||||
type: NodeTypes.TEXT,
|
type: NodeTypes.TEXT,
|
||||||
text: 'foo'
|
text: 'foo'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
onVnodeUpdated: jest.fn(vnode => {
|
onVnodeUpdated: vi.fn(vnode => {
|
||||||
expect((vnode.el as TestElement).children[0]).toMatchObject({
|
expect((vnode.el as TestElement).children[0]).toMatchObject({
|
||||||
type: NodeTypes.TEXT,
|
type: NodeTypes.TEXT,
|
||||||
text: 'bar'
|
text: 'bar'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
onVnodeBeforeUnmount: jest.fn(),
|
onVnodeBeforeUnmount: vi.fn(),
|
||||||
onVnodeUnmounted: jest.fn()
|
onVnodeUnmounted: vi.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
assertHooks(hooks, h('div', hooks, 'foo'), h('div', hooks, 'bar'))
|
assertHooks(hooks, h('div', hooks, 'foo'), h('div', hooks, 'bar'))
|
||||||
|
@ -65,22 +66,22 @@ describe('renderer: vnode hooks', () => {
|
||||||
const Comp = (props: { msg: string }) => props.msg
|
const Comp = (props: { msg: string }) => props.msg
|
||||||
|
|
||||||
const hooks: VNodeProps = {
|
const hooks: VNodeProps = {
|
||||||
onVnodeBeforeMount: jest.fn(),
|
onVnodeBeforeMount: vi.fn(),
|
||||||
onVnodeMounted: jest.fn(),
|
onVnodeMounted: vi.fn(),
|
||||||
onVnodeBeforeUpdate: jest.fn(vnode => {
|
onVnodeBeforeUpdate: vi.fn(vnode => {
|
||||||
expect(vnode.el as TestElement).toMatchObject({
|
expect(vnode.el as TestElement).toMatchObject({
|
||||||
type: NodeTypes.TEXT,
|
type: NodeTypes.TEXT,
|
||||||
text: 'foo'
|
text: 'foo'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
onVnodeUpdated: jest.fn(vnode => {
|
onVnodeUpdated: vi.fn(vnode => {
|
||||||
expect(vnode.el as TestElement).toMatchObject({
|
expect(vnode.el as TestElement).toMatchObject({
|
||||||
type: NodeTypes.TEXT,
|
type: NodeTypes.TEXT,
|
||||||
text: 'bar'
|
text: 'bar'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
onVnodeBeforeUnmount: jest.fn(),
|
onVnodeBeforeUnmount: vi.fn(),
|
||||||
onVnodeUnmounted: jest.fn()
|
onVnodeUnmounted: vi.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
assertHooks(
|
assertHooks(
|
||||||
|
|
|
@ -2,7 +2,6 @@ import {
|
||||||
ComponentInternalInstance,
|
ComponentInternalInstance,
|
||||||
currentInstance,
|
currentInstance,
|
||||||
isInSSRComponentSetup,
|
isInSSRComponentSetup,
|
||||||
LifecycleHooks,
|
|
||||||
setCurrentInstance,
|
setCurrentInstance,
|
||||||
unsetCurrentInstance
|
unsetCurrentInstance
|
||||||
} from './component'
|
} from './component'
|
||||||
|
@ -11,6 +10,7 @@ import { callWithAsyncErrorHandling, ErrorTypeStrings } from './errorHandling'
|
||||||
import { warn } from './warning'
|
import { warn } from './warning'
|
||||||
import { toHandlerKey } from '@vue/shared'
|
import { toHandlerKey } from '@vue/shared'
|
||||||
import { DebuggerEvent, pauseTracking, resetTracking } from '@vue/reactivity'
|
import { DebuggerEvent, pauseTracking, resetTracking } from '@vue/reactivity'
|
||||||
|
import { LifecycleHooks } from './enums'
|
||||||
|
|
||||||
export { onActivated, onDeactivated } from './components/KeepAlive'
|
export { onActivated, onDeactivated } from './components/KeepAlive'
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ import {
|
||||||
validateCompatConfig
|
validateCompatConfig
|
||||||
} from './compat/compatConfig'
|
} from './compat/compatConfig'
|
||||||
import { SchedulerJob } from './scheduler'
|
import { SchedulerJob } from './scheduler'
|
||||||
|
import { LifecycleHooks } from './enums'
|
||||||
|
|
||||||
export type Data = Record<string, unknown>
|
export type Data = Record<string, unknown>
|
||||||
|
|
||||||
|
@ -165,23 +166,6 @@ export { ComponentOptions }
|
||||||
|
|
||||||
type LifecycleHook<TFn = Function> = TFn[] | null
|
type LifecycleHook<TFn = Function> = TFn[] | null
|
||||||
|
|
||||||
export const enum LifecycleHooks {
|
|
||||||
BEFORE_CREATE = 'bc',
|
|
||||||
CREATED = 'c',
|
|
||||||
BEFORE_MOUNT = 'bm',
|
|
||||||
MOUNTED = 'm',
|
|
||||||
BEFORE_UPDATE = 'bu',
|
|
||||||
UPDATED = 'u',
|
|
||||||
BEFORE_UNMOUNT = 'bum',
|
|
||||||
UNMOUNTED = 'um',
|
|
||||||
DEACTIVATED = 'da',
|
|
||||||
ACTIVATED = 'a',
|
|
||||||
RENDER_TRIGGERED = 'rtg',
|
|
||||||
RENDER_TRACKED = 'rtc',
|
|
||||||
ERROR_CAPTURED = 'ec',
|
|
||||||
SERVER_PREFETCH = 'sp'
|
|
||||||
}
|
|
||||||
|
|
||||||
// use `E extends any` to force evaluating type to fix #2362
|
// use `E extends any` to force evaluating type to fix #2362
|
||||||
export type SetupContext<E = EmitsOptions> = E extends any
|
export type SetupContext<E = EmitsOptions> = E extends any
|
||||||
? {
|
? {
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
export const enum LifecycleHooks {
|
||||||
|
BEFORE_CREATE = 'bc',
|
||||||
|
CREATED = 'c',
|
||||||
|
BEFORE_MOUNT = 'bm',
|
||||||
|
MOUNTED = 'm',
|
||||||
|
BEFORE_UPDATE = 'bu',
|
||||||
|
UPDATED = 'u',
|
||||||
|
BEFORE_UNMOUNT = 'bum',
|
||||||
|
UNMOUNTED = 'um',
|
||||||
|
DEACTIVATED = 'da',
|
||||||
|
ACTIVATED = 'a',
|
||||||
|
RENDER_TRIGGERED = 'rtg',
|
||||||
|
RENDER_TRACKED = 'rtc',
|
||||||
|
ERROR_CAPTURED = 'ec',
|
||||||
|
SERVER_PREFETCH = 'sp'
|
||||||
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
import { VNode } from './vnode'
|
import { VNode } from './vnode'
|
||||||
import { ComponentInternalInstance, LifecycleHooks } from './component'
|
import { ComponentInternalInstance } from './component'
|
||||||
import { warn, pushWarningContext, popWarningContext } from './warning'
|
import { warn, pushWarningContext, popWarningContext } from './warning'
|
||||||
import { isPromise, isFunction } from '@vue/shared'
|
import { isPromise, isFunction } from '@vue/shared'
|
||||||
|
import { LifecycleHooks } from './enums'
|
||||||
|
|
||||||
// contexts where user provided function may be executed, in addition to
|
// contexts where user provided function may be executed, in addition to
|
||||||
// lifecycle hooks.
|
// lifecycle hooks.
|
||||||
|
@ -23,7 +24,7 @@ export const enum ErrorCodes {
|
||||||
SCHEDULER
|
SCHEDULER
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ErrorTypeStrings: Record<number | string, string> = {
|
export const ErrorTypeStrings: Record<LifecycleHooks | ErrorCodes, string> = {
|
||||||
[LifecycleHooks.SERVER_PREFETCH]: 'serverPrefetch hook',
|
[LifecycleHooks.SERVER_PREFETCH]: 'serverPrefetch hook',
|
||||||
[LifecycleHooks.BEFORE_CREATE]: 'beforeCreate hook',
|
[LifecycleHooks.BEFORE_CREATE]: 'beforeCreate hook',
|
||||||
[LifecycleHooks.CREATED]: 'created hook',
|
[LifecycleHooks.CREATED]: 'created hook',
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { createApp, h } from '../src'
|
import { createApp, h } from '../src'
|
||||||
|
|
||||||
describe('createApp for dom', () => {
|
describe('createApp for dom', () => {
|
||||||
|
@ -23,7 +24,7 @@ describe('createApp for dom', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handler = jest.fn(msg => {
|
const handler = vi.fn(msg => {
|
||||||
expect(msg).toMatch(`Component is missing template or render function`)
|
expect(msg).toMatch(`Component is missing template or render function`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
defineAsyncComponent,
|
defineAsyncComponent,
|
||||||
defineComponent,
|
defineComponent,
|
||||||
|
@ -332,7 +333,7 @@ describe('defineCustomElement', () => {
|
||||||
|
|
||||||
test('emit on connect', () => {
|
test('emit on connect', () => {
|
||||||
const e = new E()
|
const e = new E()
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
e.addEventListener('created', spy)
|
e.addEventListener('created', spy)
|
||||||
container.appendChild(e)
|
container.appendChild(e)
|
||||||
expect(spy).toHaveBeenCalled()
|
expect(spy).toHaveBeenCalled()
|
||||||
|
@ -341,7 +342,7 @@ describe('defineCustomElement', () => {
|
||||||
test('emit on interaction', () => {
|
test('emit on interaction', () => {
|
||||||
container.innerHTML = `<my-el-emits></my-el-emits>`
|
container.innerHTML = `<my-el-emits></my-el-emits>`
|
||||||
const e = container.childNodes[0] as VueElement
|
const e = container.childNodes[0] as VueElement
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
e.addEventListener('my-click', spy)
|
e.addEventListener('my-click', spy)
|
||||||
e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
|
e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
|
||||||
expect(spy).toHaveBeenCalledTimes(1)
|
expect(spy).toHaveBeenCalledTimes(1)
|
||||||
|
@ -354,9 +355,9 @@ describe('defineCustomElement', () => {
|
||||||
test('case transform for camelCase event', () => {
|
test('case transform for camelCase event', () => {
|
||||||
container.innerHTML = `<my-el-emits></my-el-emits>`
|
container.innerHTML = `<my-el-emits></my-el-emits>`
|
||||||
const e = container.childNodes[0] as VueElement
|
const e = container.childNodes[0] as VueElement
|
||||||
const spy1 = jest.fn()
|
const spy1 = vi.fn()
|
||||||
e.addEventListener('myEvent', spy1)
|
e.addEventListener('myEvent', spy1)
|
||||||
const spy2 = jest.fn()
|
const spy2 = vi.fn()
|
||||||
// emitting myEvent, but listening for my-event. This happens when
|
// emitting myEvent, but listening for my-event. This happens when
|
||||||
// using the custom element in a Vue template
|
// using the custom element in a Vue template
|
||||||
e.addEventListener('my-event', spy2)
|
e.addEventListener('my-event', spy2)
|
||||||
|
@ -374,7 +375,7 @@ describe('defineCustomElement', () => {
|
||||||
customElements.define('my-async-el-emits', E)
|
customElements.define('my-async-el-emits', E)
|
||||||
container.innerHTML = `<my-async-el-emits></my-async-el-emits>`
|
container.innerHTML = `<my-async-el-emits></my-async-el-emits>`
|
||||||
const e = container.childNodes[0] as VueElement
|
const e = container.childNodes[0] as VueElement
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
e.addEventListener('my-click', spy)
|
e.addEventListener('my-click', spy)
|
||||||
// this feels brittle but seems necessary to reach the node in the DOM.
|
// this feels brittle but seems necessary to reach the node in the DOM.
|
||||||
await customElements.whenDefined('my-async-el-emits')
|
await customElements.whenDefined('my-async-el-emits')
|
||||||
|
@ -394,7 +395,7 @@ describe('defineCustomElement', () => {
|
||||||
customElements.define('my-async-el-props-emits', E)
|
customElements.define('my-async-el-props-emits', E)
|
||||||
container.innerHTML = `<my-async-el-props-emits id="my_async_el_props_emits"></my-async-el-props-emits>`
|
container.innerHTML = `<my-async-el-props-emits id="my_async_el_props_emits"></my-async-el-props-emits>`
|
||||||
const e = container.childNodes[0] as VueElement
|
const e = container.childNodes[0] as VueElement
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
e.addEventListener('my-click', spy)
|
e.addEventListener('my-click', spy)
|
||||||
await customElements.whenDefined('my-async-el-props-emits')
|
await customElements.whenDefined('my-async-el-props-emits')
|
||||||
e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
|
e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
|
||||||
|
@ -549,7 +550,7 @@ describe('defineCustomElement', () => {
|
||||||
|
|
||||||
describe('async', () => {
|
describe('async', () => {
|
||||||
test('should work', async () => {
|
test('should work', async () => {
|
||||||
const loaderSpy = jest.fn()
|
const loaderSpy = vi.fn()
|
||||||
const E = defineCustomElement(
|
const E = defineCustomElement(
|
||||||
defineAsyncComponent(() => {
|
defineAsyncComponent(() => {
|
||||||
loaderSpy()
|
loaderSpy()
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { render, h } from '@vue/runtime-dom'
|
import { render, h } from '@vue/runtime-dom'
|
||||||
|
|
||||||
describe('customized built-in elements support', () => {
|
describe('customized built-in elements support', () => {
|
||||||
let createElement: jest.SpyInstance
|
let createElement: vi.SpyInstance
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
createElement.mockRestore()
|
createElement.mockRestore()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should created element with is option', () => {
|
test('should created element with is option', () => {
|
||||||
const root = document.createElement('div')
|
const root = document.createElement('div')
|
||||||
createElement = jest.spyOn(document, 'createElement')
|
createElement = vi.spyOn(document, 'createElement')
|
||||||
render(h('button', { is: 'plastic-button' }), root)
|
render(h('button', { is: 'plastic-button' }), root)
|
||||||
expect(createElement.mock.calls[0]).toMatchObject([
|
expect(createElement.mock.calls[0]).toMatchObject([
|
||||||
'button',
|
'button',
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
h,
|
h,
|
||||||
render,
|
render,
|
||||||
|
@ -29,7 +30,7 @@ beforeEach(() => {
|
||||||
|
|
||||||
describe('vModel', () => {
|
describe('vModel', () => {
|
||||||
it('should work with text input', async () => {
|
it('should work with text input', async () => {
|
||||||
const manualListener = jest.fn()
|
const manualListener = vi.fn()
|
||||||
const component = defineComponent({
|
const component = defineComponent({
|
||||||
data() {
|
data() {
|
||||||
return { value: null }
|
return { value: null }
|
||||||
|
@ -102,7 +103,7 @@ describe('vModel', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should work with multiple listeners', async () => {
|
it('should work with multiple listeners', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const component = defineComponent({
|
const component = defineComponent({
|
||||||
data() {
|
data() {
|
||||||
return { value: null }
|
return { value: null }
|
||||||
|
@ -131,8 +132,8 @@ describe('vModel', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should work with updated listeners', async () => {
|
it('should work with updated listeners', async () => {
|
||||||
const spy1 = jest.fn()
|
const spy1 = vi.fn()
|
||||||
const spy2 = jest.fn()
|
const spy2 = vi.fn()
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
|
|
||||||
const component = defineComponent({
|
const component = defineComponent({
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { patchEvent } from '../../src/modules/events'
|
import { patchEvent } from '../../src/modules/events'
|
||||||
import { withModifiers, withKeys } from '@vue/runtime-dom'
|
import { withModifiers, withKeys } from '@vue/runtime-dom'
|
||||||
|
|
||||||
|
@ -21,9 +22,9 @@ describe('runtime-dom: v-on directive', () => {
|
||||||
const parent = document.createElement('div')
|
const parent = document.createElement('div')
|
||||||
const child = document.createElement('input')
|
const child = document.createElement('input')
|
||||||
parent.appendChild(child)
|
parent.appendChild(child)
|
||||||
const childNextValue = withModifiers(jest.fn(), ['prevent', 'stop'])
|
const childNextValue = withModifiers(vi.fn(), ['prevent', 'stop'])
|
||||||
patchEvent(child, 'onClick', null, childNextValue, null)
|
patchEvent(child, 'onClick', null, childNextValue, null)
|
||||||
const parentNextValue = jest.fn()
|
const parentNextValue = vi.fn()
|
||||||
patchEvent(parent, 'onClick', null, parentNextValue, null)
|
patchEvent(parent, 'onClick', null, parentNextValue, null)
|
||||||
expect(triggerEvent(child, 'click').defaultPrevented).toBe(true)
|
expect(triggerEvent(child, 'click').defaultPrevented).toBe(true)
|
||||||
expect(parentNextValue).not.toBeCalled()
|
expect(parentNextValue).not.toBeCalled()
|
||||||
|
@ -33,7 +34,7 @@ describe('runtime-dom: v-on directive', () => {
|
||||||
const parent = document.createElement('div')
|
const parent = document.createElement('div')
|
||||||
const child = document.createElement('input')
|
const child = document.createElement('input')
|
||||||
parent.appendChild(child)
|
parent.appendChild(child)
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const handler = withModifiers(fn, ['self'])
|
const handler = withModifiers(fn, ['self'])
|
||||||
patchEvent(parent, 'onClick', null, handler, null)
|
patchEvent(parent, 'onClick', null, handler, null)
|
||||||
triggerEvent(child, 'click')
|
triggerEvent(child, 'click')
|
||||||
|
@ -45,7 +46,7 @@ describe('runtime-dom: v-on directive', () => {
|
||||||
|
|
||||||
keyNames.forEach(keyName => {
|
keyNames.forEach(keyName => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
// <div @keyup[keyName].esc="test"/>
|
// <div @keyup[keyName].esc="test"/>
|
||||||
const nextValue = withKeys(withModifiers(fn, [keyName]), [
|
const nextValue = withKeys(withModifiers(fn, [keyName]), [
|
||||||
'esc',
|
'esc',
|
||||||
|
@ -79,7 +80,7 @@ describe('runtime-dom: v-on directive', () => {
|
||||||
test('it should support "exact" modifier', () => {
|
test('it should support "exact" modifier', () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
// Case 1: <div @keyup.exact="test"/>
|
// Case 1: <div @keyup.exact="test"/>
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const next1 = withModifiers(fn1, ['exact'])
|
const next1 = withModifiers(fn1, ['exact'])
|
||||||
patchEvent(el, 'onKeyup', null, next1, null)
|
patchEvent(el, 'onKeyup', null, next1, null)
|
||||||
triggerEvent(el, 'keyup')
|
triggerEvent(el, 'keyup')
|
||||||
|
@ -87,7 +88,7 @@ describe('runtime-dom: v-on directive', () => {
|
||||||
triggerEvent(el, 'keyup', e => (e.ctrlKey = true))
|
triggerEvent(el, 'keyup', e => (e.ctrlKey = true))
|
||||||
expect(fn1.mock.calls.length).toBe(1)
|
expect(fn1.mock.calls.length).toBe(1)
|
||||||
// Case 2: <div @keyup.ctrl.a.exact="test"/>
|
// Case 2: <div @keyup.ctrl.a.exact="test"/>
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
const next2 = withKeys(withModifiers(fn2, ['ctrl', 'exact']), ['a'])
|
const next2 = withKeys(withModifiers(fn2, ['ctrl', 'exact']), ['a'])
|
||||||
patchEvent(el, 'onKeyup', null, next2, null)
|
patchEvent(el, 'onKeyup', null, next2, null)
|
||||||
triggerEvent(el, 'keyup', e => (e.key = 'a'))
|
triggerEvent(el, 'keyup', e => (e.key = 'a'))
|
||||||
|
@ -111,7 +112,7 @@ describe('runtime-dom: v-on directive', () => {
|
||||||
const buttonCodes = { left: 0, middle: 1, right: 2 }
|
const buttonCodes = { left: 0, middle: 1, right: 2 }
|
||||||
buttons.forEach(button => {
|
buttons.forEach(button => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const handler = withModifiers(fn, [button])
|
const handler = withModifiers(fn, [button])
|
||||||
patchEvent(el, 'onMousedown', null, handler, null)
|
patchEvent(el, 'onMousedown', null, handler, null)
|
||||||
buttons
|
buttons
|
||||||
|
@ -127,7 +128,7 @@ describe('runtime-dom: v-on directive', () => {
|
||||||
|
|
||||||
it('should handle multiple arguments when using modifiers', () => {
|
it('should handle multiple arguments when using modifiers', () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const handler = withModifiers(fn, ['ctrl'])
|
const handler = withModifiers(fn, ['ctrl'])
|
||||||
const event = triggerEvent(el, 'click', e => (e.ctrlKey = true))
|
const event = triggerEvent(el, 'click', e => (e.ctrlKey = true))
|
||||||
handler(event, 'value', true)
|
handler(event, 'value', true)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { patchProp } from '../src/patchProp'
|
import { patchProp } from '../src/patchProp'
|
||||||
|
|
||||||
const timeout = () => new Promise(r => setTimeout(r))
|
const timeout = () => new Promise(r => setTimeout(r))
|
||||||
|
@ -5,7 +6,7 @@ const timeout = () => new Promise(r => setTimeout(r))
|
||||||
describe(`runtime-dom: events patching`, () => {
|
describe(`runtime-dom: events patching`, () => {
|
||||||
it('should assign event handler', async () => {
|
it('should assign event handler', async () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
patchProp(el, 'onClick', null, fn)
|
patchProp(el, 'onClick', null, fn)
|
||||||
el.dispatchEvent(new Event('click'))
|
el.dispatchEvent(new Event('click'))
|
||||||
await timeout()
|
await timeout()
|
||||||
|
@ -18,8 +19,8 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
|
|
||||||
it('should update event handler', async () => {
|
it('should update event handler', async () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const prevFn = jest.fn()
|
const prevFn = vi.fn()
|
||||||
const nextFn = jest.fn()
|
const nextFn = vi.fn()
|
||||||
patchProp(el, 'onClick', null, prevFn)
|
patchProp(el, 'onClick', null, prevFn)
|
||||||
el.dispatchEvent(new Event('click'))
|
el.dispatchEvent(new Event('click'))
|
||||||
patchProp(el, 'onClick', prevFn, nextFn)
|
patchProp(el, 'onClick', prevFn, nextFn)
|
||||||
|
@ -34,8 +35,8 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
|
|
||||||
it('should support multiple event handlers', async () => {
|
it('should support multiple event handlers', async () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
patchProp(el, 'onClick', null, [fn1, fn2])
|
patchProp(el, 'onClick', null, [fn1, fn2])
|
||||||
el.dispatchEvent(new Event('click'))
|
el.dispatchEvent(new Event('click'))
|
||||||
await timeout()
|
await timeout()
|
||||||
|
@ -45,7 +46,7 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
|
|
||||||
it('should unassign event handler', async () => {
|
it('should unassign event handler', async () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
patchProp(el, 'onClick', null, fn)
|
patchProp(el, 'onClick', null, fn)
|
||||||
patchProp(el, 'onClick', fn, null)
|
patchProp(el, 'onClick', fn, null)
|
||||||
el.dispatchEvent(new Event('click'))
|
el.dispatchEvent(new Event('click'))
|
||||||
|
@ -55,7 +56,7 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
|
|
||||||
it('should support event option modifiers', async () => {
|
it('should support event option modifiers', async () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
patchProp(el, 'onClickOnceCapture', null, fn)
|
patchProp(el, 'onClickOnceCapture', null, fn)
|
||||||
el.dispatchEvent(new Event('click'))
|
el.dispatchEvent(new Event('click'))
|
||||||
await timeout()
|
await timeout()
|
||||||
|
@ -66,7 +67,7 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
|
|
||||||
it('should unassign event handler with options', async () => {
|
it('should unassign event handler with options', async () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
patchProp(el, 'onClickCapture', null, fn)
|
patchProp(el, 'onClickCapture', null, fn)
|
||||||
el.dispatchEvent(new Event('click'))
|
el.dispatchEvent(new Event('click'))
|
||||||
await timeout()
|
await timeout()
|
||||||
|
@ -84,14 +85,14 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
|
|
||||||
// string should be set as attribute
|
// string should be set as attribute
|
||||||
const fn = ((window as any).__globalSpy = jest.fn())
|
const fn = ((window as any).__globalSpy = vi.fn())
|
||||||
patchProp(el, 'onclick', null, '__globalSpy(1)')
|
patchProp(el, 'onclick', null, '__globalSpy(1)')
|
||||||
el.dispatchEvent(new Event('click'))
|
el.dispatchEvent(new Event('click'))
|
||||||
await timeout()
|
await timeout()
|
||||||
delete (window as any).__globalSpy
|
delete (window as any).__globalSpy
|
||||||
expect(fn).toHaveBeenCalledWith(1)
|
expect(fn).toHaveBeenCalledWith(1)
|
||||||
|
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
patchProp(el, 'onclick', '__globalSpy(1)', fn2)
|
patchProp(el, 'onclick', '__globalSpy(1)', fn2)
|
||||||
const event = new Event('click')
|
const event = new Event('click')
|
||||||
el.dispatchEvent(event)
|
el.dispatchEvent(event)
|
||||||
|
@ -102,10 +103,10 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
|
|
||||||
it('should support stopImmediatePropagation on multiple listeners', async () => {
|
it('should support stopImmediatePropagation on multiple listeners', async () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn1 = jest.fn((e: Event) => {
|
const fn1 = vi.fn((e: Event) => {
|
||||||
e.stopImmediatePropagation()
|
e.stopImmediatePropagation()
|
||||||
})
|
})
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
patchProp(el, 'onClick', null, [fn1, fn2])
|
patchProp(el, 'onClick', null, [fn1, fn2])
|
||||||
el.dispatchEvent(new Event('click'))
|
el.dispatchEvent(new Event('click'))
|
||||||
await timeout()
|
await timeout()
|
||||||
|
@ -119,8 +120,8 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
const el2 = document.createElement('div')
|
const el2 = document.createElement('div')
|
||||||
|
|
||||||
// const event = new Event('click')
|
// const event = new Event('click')
|
||||||
const prevFn = jest.fn()
|
const prevFn = vi.fn()
|
||||||
const nextFn = jest.fn()
|
const nextFn = vi.fn()
|
||||||
|
|
||||||
patchProp(el1, 'onClick', null, prevFn)
|
patchProp(el1, 'onClick', null, prevFn)
|
||||||
patchProp(el2, 'onClick', null, prevFn)
|
patchProp(el2, 'onClick', null, prevFn)
|
||||||
|
@ -153,8 +154,8 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
const child = document.createElement('div')
|
const child = document.createElement('div')
|
||||||
el.appendChild(child)
|
el.appendChild(child)
|
||||||
document.body.appendChild(el)
|
document.body.appendChild(el)
|
||||||
const childFn = jest.fn()
|
const childFn = vi.fn()
|
||||||
const parentFn = jest.fn()
|
const parentFn = vi.fn()
|
||||||
|
|
||||||
patchProp(child, 'onClick', null, () => {
|
patchProp(child, 'onClick', null, () => {
|
||||||
childFn()
|
childFn()
|
||||||
|
@ -178,8 +179,8 @@ describe(`runtime-dom: events patching`, () => {
|
||||||
const testElement = document.createElement('test-element', {
|
const testElement = document.createElement('test-element', {
|
||||||
is: 'test-element'
|
is: 'test-element'
|
||||||
})
|
})
|
||||||
const fn1 = jest.fn()
|
const fn1 = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
|
|
||||||
// in webComponents, @foo-bar will patch prop 'onFooBar'
|
// in webComponents, @foo-bar will patch prop 'onFooBar'
|
||||||
// and @foobar will patch prop 'onFoobar'
|
// and @foobar will patch prop 'onFoobar'
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { patchProp } from '../src/patchProp'
|
import { patchProp } from '../src/patchProp'
|
||||||
import { render, h } from '../src'
|
import { render, h } from '../src'
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ describe('runtime-dom: props patching', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('innerHTML unmount prev children', () => {
|
test('innerHTML unmount prev children', () => {
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const comp = {
|
const comp = {
|
||||||
render: () => 'foo',
|
render: () => 'foo',
|
||||||
unmounted: fn
|
unmounted: fn
|
||||||
|
@ -111,7 +112,7 @@ describe('runtime-dom: props patching', () => {
|
||||||
|
|
||||||
// #954
|
// #954
|
||||||
test('(svg) innerHTML unmount prev children', () => {
|
test('(svg) innerHTML unmount prev children', () => {
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const comp = {
|
const comp = {
|
||||||
render: () => 'foo',
|
render: () => 'foo',
|
||||||
unmounted: fn
|
unmounted: fn
|
||||||
|
@ -126,7 +127,7 @@ describe('runtime-dom: props patching', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('textContent unmount prev children', () => {
|
test('textContent unmount prev children', () => {
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const comp = {
|
const comp = {
|
||||||
render: () => 'foo',
|
render: () => 'foo',
|
||||||
unmounted: fn
|
unmounted: fn
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { patchProp } from '../src/patchProp'
|
import { patchProp } from '../src/patchProp'
|
||||||
|
|
||||||
describe(`runtime-dom: style patching`, () => {
|
describe(`runtime-dom: style patching`, () => {
|
||||||
|
@ -10,7 +11,7 @@ describe(`runtime-dom: style patching`, () => {
|
||||||
// #1309
|
// #1309
|
||||||
it('should not patch same string style', () => {
|
it('should not patch same string style', () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const value = (el.style.cssText = 'color:red;')
|
const value = (el.style.cssText = 'color:red;')
|
||||||
Object.defineProperty(el.style, 'cssText', {
|
Object.defineProperty(el.style, 'cssText', {
|
||||||
get(): any {
|
get(): any {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* @jest-environment node
|
* @jest-environment node
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { vi } from 'vitest'
|
||||||
import {
|
import {
|
||||||
createApp,
|
createApp,
|
||||||
h,
|
h,
|
||||||
|
@ -820,8 +821,8 @@ function testRender(type: string, render: typeof renderToString) {
|
||||||
|
|
||||||
// #2763
|
// #2763
|
||||||
test('error handling w/ async setup', async () => {
|
test('error handling w/ async setup', async () => {
|
||||||
const fn = jest.fn()
|
const fn = vi.fn()
|
||||||
const fn2 = jest.fn()
|
const fn2 = vi.fn()
|
||||||
|
|
||||||
const asyncChildren = defineComponent({
|
const asyncChildren = defineComponent({
|
||||||
async setup() {
|
async setup() {
|
||||||
|
@ -948,8 +949,8 @@ function testRender(type: string, render: typeof renderToString) {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('onServerPrefetch are run in parallel', async () => {
|
test('onServerPrefetch are run in parallel', async () => {
|
||||||
const first = jest.fn(() => Promise.resolve())
|
const first = vi.fn(() => Promise.resolve())
|
||||||
const second = jest.fn(() => Promise.resolve())
|
const second = vi.fn(() => Promise.resolve())
|
||||||
let checkOther = [false, false]
|
let checkOther = [false, false]
|
||||||
let done = [false, false]
|
let done = [false, false]
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { createSSRApp, defineComponent, h, computed, reactive } from 'vue'
|
import { createSSRApp, defineComponent, h, computed, reactive } from 'vue'
|
||||||
import { renderToString } from '../src/renderToString'
|
import { renderToString } from '../src/renderToString'
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ test('computed reactivity during SSR', async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getterSpy = jest.fn()
|
const getterSpy = vi.fn()
|
||||||
|
|
||||||
const App = defineComponent(async () => {
|
const App = defineComponent(async () => {
|
||||||
const msg = computed(() => {
|
const msg = computed(() => {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* @jest-environment node
|
* @jest-environment node
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { createApp, h, Suspense } from 'vue'
|
import { createApp, h, Suspense } from 'vue'
|
||||||
import { renderToString } from '../src/renderToString'
|
import { renderToString } from '../src/renderToString'
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ describe('SSR Suspense', () => {
|
||||||
|
|
||||||
test('reject', async () => {
|
test('reject', async () => {
|
||||||
const Comp = {
|
const Comp = {
|
||||||
errorCaptured: jest.fn(() => false),
|
errorCaptured: vi.fn(() => false),
|
||||||
render() {
|
render() {
|
||||||
return h(Suspense, null, {
|
return h(Suspense, null, {
|
||||||
default: h(RejectingAsync),
|
default: h(RejectingAsync),
|
||||||
|
@ -65,7 +66,7 @@ describe('SSR Suspense', () => {
|
||||||
|
|
||||||
test('resolving component + rejecting component', async () => {
|
test('resolving component + rejecting component', async () => {
|
||||||
const Comp = {
|
const Comp = {
|
||||||
errorCaptured: jest.fn(() => false),
|
errorCaptured: vi.fn(() => false),
|
||||||
render() {
|
render() {
|
||||||
return h(Suspense, null, {
|
return h(Suspense, null, {
|
||||||
default: h('div', [h(ResolvingAsync), h(RejectingAsync)]),
|
default: h('div', [h(ResolvingAsync), h(RejectingAsync)]),
|
||||||
|
@ -84,7 +85,7 @@ describe('SSR Suspense', () => {
|
||||||
|
|
||||||
test('failing suspense in passing suspense', async () => {
|
test('failing suspense in passing suspense', async () => {
|
||||||
const Comp = {
|
const Comp = {
|
||||||
errorCaptured: jest.fn(() => false),
|
errorCaptured: vi.fn(() => false),
|
||||||
render() {
|
render() {
|
||||||
return h(Suspense, null, {
|
return h(Suspense, null, {
|
||||||
default: h('div', [
|
default: h('div', [
|
||||||
|
@ -109,7 +110,7 @@ describe('SSR Suspense', () => {
|
||||||
|
|
||||||
test('passing suspense in failing suspense', async () => {
|
test('passing suspense in failing suspense', async () => {
|
||||||
const Comp = {
|
const Comp = {
|
||||||
errorCaptured: jest.fn(() => false),
|
errorCaptured: vi.fn(() => false),
|
||||||
render() {
|
render() {
|
||||||
return h(Suspense, null, {
|
return h(Suspense, null, {
|
||||||
default: h('div', [
|
default: h('div', [
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import Vue from '@vue/compat'
|
import Vue from '@vue/compat'
|
||||||
import { nextTick } from '@vue/runtime-core'
|
import { nextTick } from '@vue/runtime-core'
|
||||||
import { CompilerDeprecationTypes } from '../../compiler-core/src'
|
import { CompilerDeprecationTypes } from '../../compiler-core/src'
|
||||||
|
@ -98,7 +99,7 @@ test('COMPILER_V_BIND_OBJECT_ORDER', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('COMPILER_V_ON_NATIVE', () => {
|
test('COMPILER_V_ON_NATIVE', () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: `<child @click="spy" @click.native="spy" />`,
|
template: `<child @click="spy" @click.native="spy" />`,
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import Vue from '@vue/compat'
|
import Vue from '@vue/compat'
|
||||||
import { effect, isReactive } from '@vue/reactivity'
|
import { effect, isReactive } from '@vue/reactivity'
|
||||||
import { h, nextTick } from '@vue/runtime-core'
|
import { h, nextTick } from '@vue/runtime-core'
|
||||||
|
@ -145,10 +146,10 @@ describe('GLOBAL_EXTEND', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not merge nested mixins created with Vue.extend', () => {
|
it('should not merge nested mixins created with Vue.extend', () => {
|
||||||
const a = jest.fn()
|
const a = vi.fn()
|
||||||
const b = jest.fn()
|
const b = vi.fn()
|
||||||
const c = jest.fn()
|
const c = vi.fn()
|
||||||
const d = jest.fn()
|
const d = vi.fn()
|
||||||
const A = Vue.extend({
|
const A = Vue.extend({
|
||||||
created: a
|
created: a
|
||||||
})
|
})
|
||||||
|
@ -475,7 +476,7 @@ test('local app-level mixin registration should not affect other local apps', ()
|
||||||
const app1 = createApp({ render: () => h('div') })
|
const app1 = createApp({ render: () => h('div') })
|
||||||
const app2 = createApp({})
|
const app2 = createApp({})
|
||||||
|
|
||||||
const mixin = { created: jest.fn() }
|
const mixin = { created: vi.fn() }
|
||||||
app1.mixin(mixin)
|
app1.mixin(mixin)
|
||||||
app2.mixin(mixin)
|
app2.mixin(mixin)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import Vue from '@vue/compat'
|
import Vue from '@vue/compat'
|
||||||
import {
|
import {
|
||||||
DeprecationTypes,
|
DeprecationTypes,
|
||||||
|
@ -24,8 +25,8 @@ test('GLOBAL_KEY_CODES', () => {
|
||||||
bar: [38, 87]
|
bar: [38, 87]
|
||||||
}
|
}
|
||||||
|
|
||||||
const onFoo = jest.fn()
|
const onFoo = vi.fn()
|
||||||
const onBar = jest.fn()
|
const onBar = vi.fn()
|
||||||
|
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
new Vue({
|
new Vue({
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import Vue from '@vue/compat'
|
import Vue from '@vue/compat'
|
||||||
import { Slots } from '../../runtime-core/src/componentSlots'
|
import { Slots } from '../../runtime-core/src/componentSlots'
|
||||||
import { Text } from '../../runtime-core/src/vnode'
|
import { Text } from '../../runtime-core/src/vnode'
|
||||||
|
@ -49,11 +50,11 @@ test('INSTANCE_DESTROY', () => {
|
||||||
// https://github.com/vuejs/vue/blob/dev/test/unit/features/instance/methods-events.spec.js
|
// https://github.com/vuejs/vue/blob/dev/test/unit/features/instance/methods-events.spec.js
|
||||||
describe('INSTANCE_EVENT_EMITTER', () => {
|
describe('INSTANCE_EVENT_EMITTER', () => {
|
||||||
let vm: LegacyPublicInstance
|
let vm: LegacyPublicInstance
|
||||||
let spy: jest.Mock
|
let spy: vi.Mock
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vm = new Vue()
|
vm = new Vue()
|
||||||
spy = jest.fn()
|
spy = vi.fn()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('$on', () => {
|
it('$on', () => {
|
||||||
|
@ -157,7 +158,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('$off event + fn', () => {
|
it('$off event + fn', () => {
|
||||||
const spy2 = jest.fn()
|
const spy2 = vi.fn()
|
||||||
vm.$on('test', spy)
|
vm.$on('test', spy)
|
||||||
vm.$on('test', spy2)
|
vm.$on('test', spy2)
|
||||||
vm.$off('test', spy)
|
vm.$off('test', spy)
|
||||||
|
@ -173,7 +174,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
|
||||||
|
|
||||||
describe('INSTANCE_EVENT_HOOKS', () => {
|
describe('INSTANCE_EVENT_HOOKS', () => {
|
||||||
test('instance API', () => {
|
test('instance API', () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const vm = new Vue({ template: 'foo' })
|
const vm = new Vue({ template: 'foo' })
|
||||||
vm.$on('hook:mounted', spy)
|
vm.$on('hook:mounted', spy)
|
||||||
vm.$mount()
|
vm.$mount()
|
||||||
|
@ -187,7 +188,7 @@ describe('INSTANCE_EVENT_HOOKS', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('via template', () => {
|
test('via template', () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
new Vue({
|
new Vue({
|
||||||
template: `<child @hook:mounted="spy"/>`,
|
template: `<child @hook:mounted="spy"/>`,
|
||||||
methods: { spy },
|
methods: { spy },
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import Vue from '@vue/compat'
|
import Vue from '@vue/compat'
|
||||||
import { nextTick } from '../../runtime-core/src/scheduler'
|
import { nextTick } from '../../runtime-core/src/scheduler'
|
||||||
import {
|
import {
|
||||||
|
@ -47,7 +48,7 @@ test('mode as function', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('WATCH_ARRAY', async () => {
|
test('WATCH_ARRAY', async () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -114,7 +115,7 @@ test('PROPS_DEFAULT_THIS', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('V_ON_KEYCODE_MODIFIER', () => {
|
test('V_ON_KEYCODE_MODIFIER', () => {
|
||||||
const spy = jest.fn()
|
const spy = vi.fn()
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: `<input @keyup.1="spy">`,
|
template: `<input @keyup.1="spy">`,
|
||||||
methods: { spy }
|
methods: { spy }
|
||||||
|
@ -131,11 +132,11 @@ test('V_ON_KEYCODE_MODIFIER', () => {
|
||||||
|
|
||||||
test('CUSTOM_DIR', async () => {
|
test('CUSTOM_DIR', async () => {
|
||||||
const myDir = {
|
const myDir = {
|
||||||
bind: jest.fn(),
|
bind: vi.fn(),
|
||||||
inserted: jest.fn(),
|
inserted: vi.fn(),
|
||||||
update: jest.fn(),
|
update: vi.fn(),
|
||||||
componentUpdated: jest.fn(),
|
componentUpdated: vi.fn(),
|
||||||
unbind: jest.fn()
|
unbind: vi.fn()
|
||||||
} as any
|
} as any
|
||||||
|
|
||||||
const getCalls = () =>
|
const getCalls = () =>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import Vue from '@vue/compat'
|
import Vue from '@vue/compat'
|
||||||
import { nextTick } from '../../runtime-core/src/scheduler'
|
import { nextTick } from '../../runtime-core/src/scheduler'
|
||||||
import {
|
import {
|
||||||
|
@ -84,8 +85,8 @@ test('data deep merge w/ extended constructor', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('beforeDestroy/destroyed', async () => {
|
test('beforeDestroy/destroyed', async () => {
|
||||||
const beforeDestroy = jest.fn()
|
const beforeDestroy = vi.fn()
|
||||||
const destroyed = jest.fn()
|
const destroyed = vi.fn()
|
||||||
|
|
||||||
const child = {
|
const child = {
|
||||||
template: `foo`,
|
template: `foo`,
|
||||||
|
@ -116,8 +117,8 @@ test('beforeDestroy/destroyed', async () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('beforeDestroy/destroyed in Vue.extend components', async () => {
|
test('beforeDestroy/destroyed in Vue.extend components', async () => {
|
||||||
const beforeDestroy = jest.fn()
|
const beforeDestroy = vi.fn()
|
||||||
const destroyed = jest.fn()
|
const destroyed = vi.fn()
|
||||||
|
|
||||||
const child = Vue.extend({
|
const child = Vue.extend({
|
||||||
template: `foo`,
|
template: `foo`,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
|
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { h, createApp, Transition, ref, nextTick } from 'vue'
|
import { h, createApp, Transition, ref, nextTick } from 'vue'
|
||||||
|
@ -264,12 +265,12 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'transition events without appear',
|
'transition events without appear',
|
||||||
async () => {
|
async () => {
|
||||||
const beforeLeaveSpy = jest.fn()
|
const beforeLeaveSpy = vi.fn()
|
||||||
const onLeaveSpy = jest.fn()
|
const onLeaveSpy = vi.fn()
|
||||||
const afterLeaveSpy = jest.fn()
|
const afterLeaveSpy = vi.fn()
|
||||||
const beforeEnterSpy = jest.fn()
|
const beforeEnterSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
const afterEnterSpy = jest.fn()
|
const afterEnterSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
|
@ -368,12 +369,12 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'events with arguments',
|
'events with arguments',
|
||||||
async () => {
|
async () => {
|
||||||
const beforeLeaveSpy = jest.fn()
|
const beforeLeaveSpy = vi.fn()
|
||||||
const onLeaveSpy = jest.fn()
|
const onLeaveSpy = vi.fn()
|
||||||
const afterLeaveSpy = jest.fn()
|
const afterLeaveSpy = vi.fn()
|
||||||
const beforeEnterSpy = jest.fn()
|
const beforeEnterSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
const afterEnterSpy = jest.fn()
|
const afterEnterSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
|
@ -482,7 +483,7 @@ describe('e2e: Transition', () => {
|
||||||
)
|
)
|
||||||
|
|
||||||
test('onEnterCancelled', async () => {
|
test('onEnterCancelled', async () => {
|
||||||
const enterCancelledSpy = jest.fn()
|
const enterCancelledSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('enterCancelledSpy', enterCancelledSpy)
|
await page().exposeFunction('enterCancelledSpy', enterCancelledSpy)
|
||||||
|
|
||||||
|
@ -622,15 +623,15 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'transition events with appear',
|
'transition events with appear',
|
||||||
async () => {
|
async () => {
|
||||||
const onLeaveSpy = jest.fn()
|
const onLeaveSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
const onAppearSpy = jest.fn()
|
const onAppearSpy = vi.fn()
|
||||||
const beforeLeaveSpy = jest.fn()
|
const beforeLeaveSpy = vi.fn()
|
||||||
const beforeEnterSpy = jest.fn()
|
const beforeEnterSpy = vi.fn()
|
||||||
const beforeAppearSpy = jest.fn()
|
const beforeAppearSpy = vi.fn()
|
||||||
const afterLeaveSpy = jest.fn()
|
const afterLeaveSpy = vi.fn()
|
||||||
const afterEnterSpy = jest.fn()
|
const afterEnterSpy = vi.fn()
|
||||||
const afterAppearSpy = jest.fn()
|
const afterAppearSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
|
@ -770,12 +771,12 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'css: false',
|
'css: false',
|
||||||
async () => {
|
async () => {
|
||||||
const onBeforeEnterSpy = jest.fn()
|
const onBeforeEnterSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
const onAfterEnterSpy = jest.fn()
|
const onAfterEnterSpy = vi.fn()
|
||||||
const onBeforeLeaveSpy = jest.fn()
|
const onBeforeLeaveSpy = vi.fn()
|
||||||
const onLeaveSpy = jest.fn()
|
const onLeaveSpy = vi.fn()
|
||||||
const onAfterLeaveSpy = jest.fn()
|
const onAfterLeaveSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onBeforeEnterSpy', onBeforeEnterSpy)
|
await page().exposeFunction('onBeforeEnterSpy', onBeforeEnterSpy)
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
|
@ -1219,8 +1220,8 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'async component transition inside Suspense',
|
'async component transition inside Suspense',
|
||||||
async () => {
|
async () => {
|
||||||
const onLeaveSpy = jest.fn()
|
const onLeaveSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
|
@ -1371,8 +1372,8 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'out-in mode with Suspense',
|
'out-in mode with Suspense',
|
||||||
async () => {
|
async () => {
|
||||||
const onLeaveSpy = jest.fn()
|
const onLeaveSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
|
@ -1561,12 +1562,12 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'transition events with v-show',
|
'transition events with v-show',
|
||||||
async () => {
|
async () => {
|
||||||
const beforeLeaveSpy = jest.fn()
|
const beforeLeaveSpy = vi.fn()
|
||||||
const onLeaveSpy = jest.fn()
|
const onLeaveSpy = vi.fn()
|
||||||
const afterLeaveSpy = jest.fn()
|
const afterLeaveSpy = vi.fn()
|
||||||
const beforeEnterSpy = jest.fn()
|
const beforeEnterSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
const afterEnterSpy = jest.fn()
|
const afterEnterSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
|
@ -1667,7 +1668,7 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'onLeaveCancelled (v-show only)',
|
'onLeaveCancelled (v-show only)',
|
||||||
async () => {
|
async () => {
|
||||||
const onLeaveCancelledSpy = jest.fn()
|
const onLeaveCancelledSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onLeaveCancelledSpy', onLeaveCancelledSpy)
|
await page().exposeFunction('onLeaveCancelledSpy', onLeaveCancelledSpy)
|
||||||
await page().evaluate(() => {
|
await page().evaluate(() => {
|
||||||
|
@ -1729,9 +1730,9 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'transition on appear with v-show',
|
'transition on appear with v-show',
|
||||||
async () => {
|
async () => {
|
||||||
const beforeEnterSpy = jest.fn()
|
const beforeEnterSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
const afterEnterSpy = jest.fn()
|
const afterEnterSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
await page().exposeFunction('beforeEnterSpy', beforeEnterSpy)
|
await page().exposeFunction('beforeEnterSpy', beforeEnterSpy)
|
||||||
|
@ -1835,9 +1836,9 @@ describe('e2e: Transition', () => {
|
||||||
test(
|
test(
|
||||||
'transition events should not call onEnter with v-show false',
|
'transition events should not call onEnter with v-show false',
|
||||||
async () => {
|
async () => {
|
||||||
const beforeEnterSpy = jest.fn()
|
const beforeEnterSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
const afterEnterSpy = jest.fn()
|
const afterEnterSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
await page().exposeFunction('beforeEnterSpy', beforeEnterSpy)
|
await page().exposeFunction('beforeEnterSpy', beforeEnterSpy)
|
||||||
|
@ -2199,8 +2200,8 @@ describe('e2e: Transition', () => {
|
||||||
|
|
||||||
// #3227
|
// #3227
|
||||||
test(`HOC w/ merged hooks`, async () => {
|
test(`HOC w/ merged hooks`, async () => {
|
||||||
const innerSpy = jest.fn()
|
const innerSpy = vi.fn()
|
||||||
const outerSpy = jest.fn()
|
const outerSpy = vi.fn()
|
||||||
|
|
||||||
const MyTransition = {
|
const MyTransition = {
|
||||||
render(this: any) {
|
render(this: any) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
|
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { createApp, ref } from 'vue'
|
import { createApp, ref } from 'vue'
|
||||||
|
@ -359,15 +360,15 @@ describe('e2e: TransitionGroup', () => {
|
||||||
test(
|
test(
|
||||||
'events',
|
'events',
|
||||||
async () => {
|
async () => {
|
||||||
const onLeaveSpy = jest.fn()
|
const onLeaveSpy = vi.fn()
|
||||||
const onEnterSpy = jest.fn()
|
const onEnterSpy = vi.fn()
|
||||||
const onAppearSpy = jest.fn()
|
const onAppearSpy = vi.fn()
|
||||||
const beforeLeaveSpy = jest.fn()
|
const beforeLeaveSpy = vi.fn()
|
||||||
const beforeEnterSpy = jest.fn()
|
const beforeEnterSpy = vi.fn()
|
||||||
const beforeAppearSpy = jest.fn()
|
const beforeAppearSpy = vi.fn()
|
||||||
const afterLeaveSpy = jest.fn()
|
const afterLeaveSpy = vi.fn()
|
||||||
const afterEnterSpy = jest.fn()
|
const afterEnterSpy = vi.fn()
|
||||||
const afterAppearSpy = jest.fn()
|
const afterAppearSpy = vi.fn()
|
||||||
|
|
||||||
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
await page().exposeFunction('onLeaveSpy', onLeaveSpy)
|
||||||
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
await page().exposeFunction('onEnterSpy', onEnterSpy)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { createApp } from '../src'
|
import { createApp } from '../src'
|
||||||
|
|
||||||
// https://github.com/vuejs/docs/pull/1890
|
// https://github.com/vuejs/docs/pull/1890
|
||||||
|
@ -18,8 +19,8 @@ test('custom element event casing', () => {
|
||||||
const container = document.createElement('div')
|
const container = document.createElement('div')
|
||||||
document.body.appendChild(container)
|
document.body.appendChild(container)
|
||||||
|
|
||||||
const handler = jest.fn()
|
const handler = vi.fn()
|
||||||
const handler2 = jest.fn()
|
const handler2 = vi.fn()
|
||||||
createApp({
|
createApp({
|
||||||
template: `
|
template: `
|
||||||
<custom-event-casing
|
<custom-event-casing
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
import { EMPTY_ARR } from '@vue/shared'
|
import { EMPTY_ARR } from '@vue/shared'
|
||||||
import { createApp, ref, nextTick, reactive } from '../src'
|
import { createApp, ref, nextTick, reactive } from '../src'
|
||||||
|
|
||||||
|
@ -21,11 +22,11 @@ describe('compiler + runtime integration', () => {
|
||||||
const one = {
|
const one = {
|
||||||
name: 'one',
|
name: 'one',
|
||||||
template: 'one',
|
template: 'one',
|
||||||
created: jest.fn(),
|
created: vi.fn(),
|
||||||
mounted: jest.fn(),
|
mounted: vi.fn(),
|
||||||
activated: jest.fn(),
|
activated: vi.fn(),
|
||||||
deactivated: jest.fn(),
|
deactivated: vi.fn(),
|
||||||
unmounted: jest.fn()
|
unmounted: vi.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
|
@ -166,7 +167,7 @@ describe('compiler + runtime integration', () => {
|
||||||
it('should support selector of rootContainer', () => {
|
it('should support selector of rootContainer', () => {
|
||||||
const container = document.createElement('div')
|
const container = document.createElement('div')
|
||||||
const origin = document.querySelector
|
const origin = document.querySelector
|
||||||
document.querySelector = jest.fn().mockReturnValue(container)
|
document.querySelector = vi.fn().mockReturnValue(container)
|
||||||
|
|
||||||
const App = {
|
const App = {
|
||||||
template: `{{ count }}`,
|
template: `{{ count }}`,
|
||||||
|
@ -203,7 +204,7 @@ describe('compiler + runtime integration', () => {
|
||||||
|
|
||||||
it('should warn when container is not found', () => {
|
it('should warn when container is not found', () => {
|
||||||
const origin = document.querySelector
|
const origin = document.querySelector
|
||||||
document.querySelector = jest.fn().mockReturnValue(null)
|
document.querySelector = vi.fn().mockReturnValue(null)
|
||||||
const App = {
|
const App = {
|
||||||
template: `{{ count }}`,
|
template: `{{ count }}`,
|
||||||
data() {
|
data() {
|
||||||
|
@ -226,7 +227,7 @@ describe('compiler + runtime integration', () => {
|
||||||
const target = document.createElement('div')
|
const target = document.createElement('div')
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
const origin = document.querySelector
|
const origin = document.querySelector
|
||||||
document.querySelector = jest.fn().mockReturnValue(target)
|
document.querySelector = vi.fn().mockReturnValue(target)
|
||||||
|
|
||||||
const App = {
|
const App = {
|
||||||
template: `
|
template: `
|
||||||
|
|
364
pnpm-lock.yaml
364
pnpm-lock.yaml
|
@ -53,6 +53,7 @@ importers:
|
||||||
tslib: ^2.4.0
|
tslib: ^2.4.0
|
||||||
typescript: ^4.8.0
|
typescript: ^4.8.0
|
||||||
vite: ^4.0.4
|
vite: ^4.0.4
|
||||||
|
vitest: ^0.28.2
|
||||||
vue: workspace:*
|
vue: workspace:*
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@babel/types': 7.16.0
|
'@babel/types': 7.16.0
|
||||||
|
@ -104,6 +105,7 @@ importers:
|
||||||
tslib: 2.4.0
|
tslib: 2.4.0
|
||||||
typescript: 4.8.2
|
typescript: 4.8.2
|
||||||
vite: 4.0.4_suj7upvbbzn7525gsozjyvtnxy
|
vite: 4.0.4_suj7upvbbzn7525gsozjyvtnxy
|
||||||
|
vitest: 0.28.2_terser@5.15.1
|
||||||
vue: link:packages/vue
|
vue: link:packages/vue
|
||||||
|
|
||||||
packages/compiler-core:
|
packages/compiler-core:
|
||||||
|
@ -1649,6 +1651,16 @@ packages:
|
||||||
'@babel/types': 7.16.0
|
'@babel/types': 7.16.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@types/chai-subset/1.3.3:
|
||||||
|
resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==}
|
||||||
|
dependencies:
|
||||||
|
'@types/chai': 4.3.4
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/@types/chai/4.3.4:
|
||||||
|
resolution: {integrity: sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/estree/0.0.48:
|
/@types/estree/0.0.48:
|
||||||
resolution: {integrity: sha512-LfZwXoGUDo0C3me81HXgkBg5CTQYb6xzEl+fNmbO4JdRiSKQ8A0GD1OBBvKAIsbCUgoyAty7m99GqqMQe784ew==}
|
resolution: {integrity: sha512-LfZwXoGUDo0C3me81HXgkBg5CTQYb6xzEl+fNmbO4JdRiSKQ8A0GD1OBBvKAIsbCUgoyAty7m99GqqMQe784ew==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -1897,6 +1909,38 @@ packages:
|
||||||
vue: link:packages/vue
|
vue: link:packages/vue
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@vitest/expect/0.28.2:
|
||||||
|
resolution: {integrity: sha512-syEAK7I24/aGR2lXma98WNnvMwAJ+fMx32yPcj8eLdCEWjZI3SH8ozMaKQMy65B/xZCZAl6MXmfjtJb2CpWPMg==}
|
||||||
|
dependencies:
|
||||||
|
'@vitest/spy': 0.28.2
|
||||||
|
'@vitest/utils': 0.28.2
|
||||||
|
chai: 4.3.7
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/@vitest/runner/0.28.2:
|
||||||
|
resolution: {integrity: sha512-BJ9CtfPwWM8uc5p7Ty0OprwApyh8RIaSK7QeQPhwfDYA59AAE009OytqA3aX0yj1Qy5+k/mYFJS8RJZgsueSGA==}
|
||||||
|
dependencies:
|
||||||
|
'@vitest/utils': 0.28.2
|
||||||
|
p-limit: 4.0.0
|
||||||
|
pathe: 1.1.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/@vitest/spy/0.28.2:
|
||||||
|
resolution: {integrity: sha512-KlLzTzi5E6tHcI12VT+brlY1Pdi7sUzLf9+YXgh80+CfLu9DqPZi38doBBAUhqEnW/emoLCMinPMMoJlNAQZXA==}
|
||||||
|
dependencies:
|
||||||
|
tinyspy: 1.0.2
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/@vitest/utils/0.28.2:
|
||||||
|
resolution: {integrity: sha512-wcVTNnVdr22IGxZHDgiXrxWYcXsNg0iX2iBuOH3tVs9eme6fXJ0wxjn0/gCpp0TofQSoUwo3tX8LNACFVseDuA==}
|
||||||
|
dependencies:
|
||||||
|
cli-truncate: 3.1.0
|
||||||
|
diff: 5.1.0
|
||||||
|
loupe: 2.3.6
|
||||||
|
picocolors: 1.0.0
|
||||||
|
pretty-format: 27.5.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@vue/consolidate/0.17.3:
|
/@vue/consolidate/0.17.3:
|
||||||
resolution: {integrity: sha512-nl0SWcTMzaaTnJ5G6V8VlMDA1CVVrNnaQKF1aBZU3kXtjgU9jtHMsEAsgjoRUx+T0EVJk9TgbmxGhK3pOk22zw==}
|
resolution: {integrity: sha512-nl0SWcTMzaaTnJ5G6V8VlMDA1CVVrNnaQKF1aBZU3kXtjgU9jtHMsEAsgjoRUx+T0EVJk9TgbmxGhK3pOk22zw==}
|
||||||
engines: {node: '>= 0.12.0'}
|
engines: {node: '>= 0.12.0'}
|
||||||
|
@ -2045,6 +2089,11 @@ packages:
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/ansi-regex/6.0.1:
|
||||||
|
resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/ansi-styles/3.2.1:
|
/ansi-styles/3.2.1:
|
||||||
resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==}
|
resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -2064,6 +2113,11 @@ packages:
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/ansi-styles/6.2.1:
|
||||||
|
resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/anymatch/3.1.2:
|
/anymatch/3.1.2:
|
||||||
resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==}
|
resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
|
@ -2117,6 +2171,10 @@ packages:
|
||||||
resolution: {integrity: sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==}
|
resolution: {integrity: sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/assertion-error/1.1.0:
|
||||||
|
resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/astral-regex/2.0.0:
|
/astral-regex/2.0.0:
|
||||||
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
|
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
@ -2402,6 +2460,11 @@ packages:
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/cac/6.7.14:
|
||||||
|
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/call-bind/1.0.2:
|
/call-bind/1.0.2:
|
||||||
resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==}
|
resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -2442,6 +2505,19 @@ packages:
|
||||||
resolution: {integrity: sha512-zaEMRH6xg8ESMi2eQ3R4eZ5qw/hJiVsO/HlLwniIwErij0JDr9P+8V4dtx1l+kLq6j3yy8l8W4fst1lBnat5wQ==}
|
resolution: {integrity: sha512-zaEMRH6xg8ESMi2eQ3R4eZ5qw/hJiVsO/HlLwniIwErij0JDr9P+8V4dtx1l+kLq6j3yy8l8W4fst1lBnat5wQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/chai/4.3.7:
|
||||||
|
resolution: {integrity: sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==}
|
||||||
|
engines: {node: '>=4'}
|
||||||
|
dependencies:
|
||||||
|
assertion-error: 1.1.0
|
||||||
|
check-error: 1.0.2
|
||||||
|
deep-eql: 4.1.3
|
||||||
|
get-func-name: 2.0.0
|
||||||
|
loupe: 2.3.6
|
||||||
|
pathval: 1.1.1
|
||||||
|
type-detect: 4.0.8
|
||||||
|
dev: true
|
||||||
|
|
||||||
/chalk/2.4.1:
|
/chalk/2.4.1:
|
||||||
resolution: {integrity: sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==}
|
resolution: {integrity: sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -2479,6 +2555,10 @@ packages:
|
||||||
is-regex: 1.1.4
|
is-regex: 1.1.4
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/check-error/1.0.2:
|
||||||
|
resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/chokidar/3.5.2:
|
/chokidar/3.5.2:
|
||||||
resolution: {integrity: sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==}
|
resolution: {integrity: sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==}
|
||||||
engines: {node: '>= 8.10.0'}
|
engines: {node: '>= 8.10.0'}
|
||||||
|
@ -2538,6 +2618,14 @@ packages:
|
||||||
string-width: 4.2.3
|
string-width: 4.2.3
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/cli-truncate/3.1.0:
|
||||||
|
resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==}
|
||||||
|
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||||
|
dependencies:
|
||||||
|
slice-ansi: 5.0.0
|
||||||
|
string-width: 5.1.2
|
||||||
|
dev: true
|
||||||
|
|
||||||
/clipboardy/2.3.0:
|
/clipboardy/2.3.0:
|
||||||
resolution: {integrity: sha512-mKhiIL2DrQIsuXMgBgnfEHOZOryC7kY7YO//TN6c63wlEm3NG5tz+YgY5rVi29KCmq/QQjKYvM7a19+MDOTHOQ==}
|
resolution: {integrity: sha512-mKhiIL2DrQIsuXMgBgnfEHOZOryC7kY7YO//TN6c63wlEm3NG5tz+YgY5rVi29KCmq/QQjKYvM7a19+MDOTHOQ==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
@ -3047,6 +3135,13 @@ packages:
|
||||||
resolution: {integrity: sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=}
|
resolution: {integrity: sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/deep-eql/4.1.3:
|
||||||
|
resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==}
|
||||||
|
engines: {node: '>=6'}
|
||||||
|
dependencies:
|
||||||
|
type-detect: 4.0.8
|
||||||
|
dev: true
|
||||||
|
|
||||||
/deep-extend/0.6.0:
|
/deep-extend/0.6.0:
|
||||||
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
|
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
|
||||||
engines: {node: '>=4.0.0'}
|
engines: {node: '>=4.0.0'}
|
||||||
|
@ -3100,6 +3195,11 @@ packages:
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/diff/5.1.0:
|
||||||
|
resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==}
|
||||||
|
engines: {node: '>=0.3.1'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/diffie-hellman/5.0.3:
|
/diffie-hellman/5.0.3:
|
||||||
resolution: {integrity: sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==}
|
resolution: {integrity: sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -3140,6 +3240,10 @@ packages:
|
||||||
is-obj: 2.0.0
|
is-obj: 2.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/eastasianwidth/0.2.0:
|
||||||
|
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/electron-to-chromium/1.4.16:
|
/electron-to-chromium/1.4.16:
|
||||||
resolution: {integrity: sha512-BQb7FgYwnu6haWLU63/CdVW+9xhmHls3RCQUFiV4lvw3wimEHTVcUk2hkuZo76QhR8nnDdfZE7evJIZqijwPdA==}
|
resolution: {integrity: sha512-BQb7FgYwnu6haWLU63/CdVW+9xhmHls3RCQUFiV4lvw3wimEHTVcUk2hkuZo76QhR8nnDdfZE7evJIZqijwPdA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -3165,6 +3269,10 @@ packages:
|
||||||
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/emoji-regex/9.2.2:
|
||||||
|
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/emojis-list/3.0.0:
|
/emojis-list/3.0.0:
|
||||||
resolution: {integrity: sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==}
|
resolution: {integrity: sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==}
|
||||||
engines: {node: '>= 4'}
|
engines: {node: '>= 4'}
|
||||||
|
@ -3765,6 +3873,10 @@ packages:
|
||||||
engines: {node: 6.* || 8.* || >= 10.*}
|
engines: {node: 6.* || 8.* || >= 10.*}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/get-func-name/2.0.0:
|
||||||
|
resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/get-intrinsic/1.1.1:
|
/get-intrinsic/1.1.1:
|
||||||
resolution: {integrity: sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==}
|
resolution: {integrity: sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -4244,6 +4356,11 @@ packages:
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/is-fullwidth-code-point/4.0.0:
|
||||||
|
resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/is-generator-fn/2.1.0:
|
/is-generator-fn/2.1.0:
|
||||||
resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==}
|
resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
@ -5024,6 +5141,10 @@ packages:
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/jsonc-parser/3.2.0:
|
||||||
|
resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/jsonfile/4.0.0:
|
/jsonfile/4.0.0:
|
||||||
resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==}
|
resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==}
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
|
@ -5238,6 +5359,11 @@ packages:
|
||||||
json5: 1.0.1
|
json5: 1.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/local-pkg/0.4.3:
|
||||||
|
resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==}
|
||||||
|
engines: {node: '>=14'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/locate-path/2.0.0:
|
/locate-path/2.0.0:
|
||||||
resolution: {integrity: sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==}
|
resolution: {integrity: sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -5303,6 +5429,12 @@ packages:
|
||||||
wrap-ansi: 6.2.0
|
wrap-ansi: 6.2.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/loupe/2.3.6:
|
||||||
|
resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==}
|
||||||
|
dependencies:
|
||||||
|
get-func-name: 2.0.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/lru-cache/4.1.5:
|
/lru-cache/4.1.5:
|
||||||
resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==}
|
resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -5517,6 +5649,15 @@ packages:
|
||||||
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
|
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/mlly/1.1.0:
|
||||||
|
resolution: {integrity: sha512-cwzBrBfwGC1gYJyfcy8TcZU1f+dbH/T+TuOhtYP2wLv/Fb51/uV7HJQfBPtEupZ2ORLRU1EKFS/QfS3eo9+kBQ==}
|
||||||
|
dependencies:
|
||||||
|
acorn: 8.8.1
|
||||||
|
pathe: 1.1.0
|
||||||
|
pkg-types: 1.0.1
|
||||||
|
ufo: 1.0.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/modify-values/1.0.1:
|
/modify-values/1.0.1:
|
||||||
resolution: {integrity: sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==}
|
resolution: {integrity: sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
@ -5749,6 +5890,13 @@ packages:
|
||||||
yocto-queue: 0.1.0
|
yocto-queue: 0.1.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/p-limit/4.0.0:
|
||||||
|
resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==}
|
||||||
|
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||||
|
dependencies:
|
||||||
|
yocto-queue: 1.0.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/p-locate/2.0.0:
|
/p-locate/2.0.0:
|
||||||
resolution: {integrity: sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==}
|
resolution: {integrity: sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -5874,6 +6022,14 @@ packages:
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/pathe/1.1.0:
|
||||||
|
resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/pathval/1.1.1:
|
||||||
|
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/pbkdf2/3.1.2:
|
/pbkdf2/3.1.2:
|
||||||
resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==}
|
resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==}
|
||||||
engines: {node: '>=0.12'}
|
engines: {node: '>=0.12'}
|
||||||
|
@ -5930,6 +6086,14 @@ packages:
|
||||||
find-up: 4.1.0
|
find-up: 4.1.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/pkg-types/1.0.1:
|
||||||
|
resolution: {integrity: sha512-jHv9HB+Ho7dj6ItwppRDDl0iZRYBD0jsakHXtFgoLr+cHSF6xC+QL54sJmWxyGxOLYSHm0afhXhXcQDQqH9z8g==}
|
||||||
|
dependencies:
|
||||||
|
jsonc-parser: 3.2.0
|
||||||
|
mlly: 1.1.0
|
||||||
|
pathe: 1.1.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/please-upgrade-node/3.2.0:
|
/please-upgrade-node/3.2.0:
|
||||||
resolution: {integrity: sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==}
|
resolution: {integrity: sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -6038,6 +6202,15 @@ packages:
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/pretty-format/27.5.1:
|
||||||
|
resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
|
||||||
|
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
|
||||||
|
dependencies:
|
||||||
|
ansi-regex: 5.0.1
|
||||||
|
ansi-styles: 5.2.0
|
||||||
|
react-is: 17.0.2
|
||||||
|
dev: true
|
||||||
|
|
||||||
/pretty-format/29.3.1:
|
/pretty-format/29.3.1:
|
||||||
resolution: {integrity: sha512-FyLnmb1cYJV8biEIiRyzRFvs2lry7PPIvOqKVe1GCUEYg4YGmlx1qG9EJNMxArYm7piII4qb8UV1Pncq5dxmcg==}
|
resolution: {integrity: sha512-FyLnmb1cYJV8biEIiRyzRFvs2lry7PPIvOqKVe1GCUEYg4YGmlx1qG9EJNMxArYm7piII4qb8UV1Pncq5dxmcg==}
|
||||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||||
|
@ -6296,6 +6469,10 @@ packages:
|
||||||
strip-json-comments: 2.0.1
|
strip-json-comments: 2.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/react-is/17.0.2:
|
||||||
|
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/react-is/18.2.0:
|
/react-is/18.2.0:
|
||||||
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
|
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -6724,6 +6901,10 @@ packages:
|
||||||
object-inspect: 1.11.1
|
object-inspect: 1.11.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/siginfo/2.0.0:
|
||||||
|
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/signal-exit/3.0.6:
|
/signal-exit/3.0.6:
|
||||||
resolution: {integrity: sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==}
|
resolution: {integrity: sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -6765,6 +6946,14 @@ packages:
|
||||||
is-fullwidth-code-point: 3.0.0
|
is-fullwidth-code-point: 3.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/slice-ansi/5.0.0:
|
||||||
|
resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dependencies:
|
||||||
|
ansi-styles: 6.2.1
|
||||||
|
is-fullwidth-code-point: 4.0.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/source-map-js/1.0.1:
|
/source-map-js/1.0.1:
|
||||||
resolution: {integrity: sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA==}
|
resolution: {integrity: sha512-4+TN2b3tqOCd/kaGRJ/sTYA0tR0mdXx26ipdolxcwtJVqEnqNYvlCAt1q3ypy4QMlYus+Zh34RNtYLoq2oQ4IA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
@ -6845,6 +7034,14 @@ packages:
|
||||||
escape-string-regexp: 2.0.0
|
escape-string-regexp: 2.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/stackback/0.0.2:
|
||||||
|
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/std-env/3.3.1:
|
||||||
|
resolution: {integrity: sha512-3H20QlwQsSm2OvAxWIYhs+j01MzzqwMwGiiO1NQaJYZgJZFPuAbf95/DiKRBSTYIJ2FeGUc+B/6mPGcWP9dO3Q==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/string-argv/0.3.1:
|
/string-argv/0.3.1:
|
||||||
resolution: {integrity: sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==}
|
resolution: {integrity: sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==}
|
||||||
engines: {node: '>=0.6.19'}
|
engines: {node: '>=0.6.19'}
|
||||||
|
@ -6883,6 +7080,15 @@ packages:
|
||||||
strip-ansi: 6.0.1
|
strip-ansi: 6.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/string-width/5.1.2:
|
||||||
|
resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dependencies:
|
||||||
|
eastasianwidth: 0.2.0
|
||||||
|
emoji-regex: 9.2.2
|
||||||
|
strip-ansi: 7.0.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/string.prototype.padend/3.1.3:
|
/string.prototype.padend/3.1.3:
|
||||||
resolution: {integrity: sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg==}
|
resolution: {integrity: sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
@ -6944,6 +7150,13 @@ packages:
|
||||||
ansi-regex: 5.0.1
|
ansi-regex: 5.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/strip-ansi/7.0.1:
|
||||||
|
resolution: {integrity: sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dependencies:
|
||||||
|
ansi-regex: 6.0.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/strip-bom/3.0.0:
|
/strip-bom/3.0.0:
|
||||||
resolution: {integrity: sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=}
|
resolution: {integrity: sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -6981,6 +7194,12 @@ packages:
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/strip-literal/1.0.0:
|
||||||
|
resolution: {integrity: sha512-5o4LsH1lzBzO9UFH63AJ2ad2/S2AVx6NtjOcaz+VTT2h1RiRvbipW72z8M/lxEhcPHDBQwpDrnTF7sXy/7OwCQ==}
|
||||||
|
dependencies:
|
||||||
|
acorn: 8.8.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/supports-color/5.5.0:
|
/supports-color/5.5.0:
|
||||||
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
|
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -7112,6 +7331,20 @@ packages:
|
||||||
resolution: {integrity: sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A==}
|
resolution: {integrity: sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/tinybench/2.3.1:
|
||||||
|
resolution: {integrity: sha512-hGYWYBMPr7p4g5IarQE7XhlyWveh1EKhy4wUBS1LrHXCKYgvz+4/jCqgmJqZxxldesn05vccrtME2RLLZNW7iA==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/tinypool/0.3.0:
|
||||||
|
resolution: {integrity: sha512-NX5KeqHOBZU6Bc0xj9Vr5Szbb1j8tUHIeD18s41aDJaPeC5QTdEhK0SpdpUrZlj2nv5cctNcSjaKNanXlfcVEQ==}
|
||||||
|
engines: {node: '>=14.0.0'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
|
/tinyspy/1.0.2:
|
||||||
|
resolution: {integrity: sha512-bSGlgwLBYf7PnUsQ6WOc6SJ3pGOcd+d8AA6EUnLDDM0kWEstC1JIlSZA3UNliDXhd9ABoS7hiRBDCu+XP/sf1Q==}
|
||||||
|
engines: {node: '>=14.0.0'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/tmpl/1.0.5:
|
/tmpl/1.0.5:
|
||||||
resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
|
resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -7281,6 +7514,10 @@ packages:
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/ufo/1.0.1:
|
||||||
|
resolution: {integrity: sha512-boAm74ubXHY7KJQZLlXrtMz52qFvpsbOxDcZOnw/Wf+LS4Mmyu7JxmzD4tDLtUQtmZECypJ0FrCz4QIe6dvKRA==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/uglify-js/3.17.4:
|
/uglify-js/3.17.4:
|
||||||
resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==}
|
resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==}
|
||||||
engines: {node: '>=0.8.0'}
|
engines: {node: '>=0.8.0'}
|
||||||
|
@ -7379,6 +7616,29 @@ packages:
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/vite-node/0.28.2_cuughdtwg7b3rwlnomrzdiszke:
|
||||||
|
resolution: {integrity: sha512-zyiJ3DLs9zXign4P2MD4PQk+7rdT+JkHukgmmS0KuImbCQ7WnCdea5imQVeT6OtUsBwsLztJxQODUsinVr91tg==}
|
||||||
|
engines: {node: '>=v14.16.0'}
|
||||||
|
hasBin: true
|
||||||
|
dependencies:
|
||||||
|
cac: 6.7.14
|
||||||
|
debug: 4.3.4
|
||||||
|
mlly: 1.1.0
|
||||||
|
pathe: 1.1.0
|
||||||
|
picocolors: 1.0.0
|
||||||
|
source-map: 0.6.1
|
||||||
|
source-map-support: 0.5.21
|
||||||
|
vite: 4.0.4_cuughdtwg7b3rwlnomrzdiszke
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@types/node'
|
||||||
|
- less
|
||||||
|
- sass
|
||||||
|
- stylus
|
||||||
|
- sugarss
|
||||||
|
- supports-color
|
||||||
|
- terser
|
||||||
|
dev: true
|
||||||
|
|
||||||
/vite/4.0.4:
|
/vite/4.0.4:
|
||||||
resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==}
|
resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
|
@ -7412,6 +7672,41 @@ packages:
|
||||||
fsevents: 2.3.2
|
fsevents: 2.3.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/vite/4.0.4_cuughdtwg7b3rwlnomrzdiszke:
|
||||||
|
resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==}
|
||||||
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
|
hasBin: true
|
||||||
|
peerDependencies:
|
||||||
|
'@types/node': '>= 14'
|
||||||
|
less: '*'
|
||||||
|
sass: '*'
|
||||||
|
stylus: '*'
|
||||||
|
sugarss: '*'
|
||||||
|
terser: ^5.4.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/node':
|
||||||
|
optional: true
|
||||||
|
less:
|
||||||
|
optional: true
|
||||||
|
sass:
|
||||||
|
optional: true
|
||||||
|
stylus:
|
||||||
|
optional: true
|
||||||
|
sugarss:
|
||||||
|
optional: true
|
||||||
|
terser:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
'@types/node': 16.18.2
|
||||||
|
esbuild: 0.16.17
|
||||||
|
postcss: 8.4.21
|
||||||
|
resolve: 1.22.1
|
||||||
|
rollup: 3.10.0
|
||||||
|
terser: 5.15.1
|
||||||
|
optionalDependencies:
|
||||||
|
fsevents: 2.3.2
|
||||||
|
dev: true
|
||||||
|
|
||||||
/vite/4.0.4_suj7upvbbzn7525gsozjyvtnxy:
|
/vite/4.0.4_suj7upvbbzn7525gsozjyvtnxy:
|
||||||
resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==}
|
resolution: {integrity: sha512-xevPU7M8FU0i/80DMR+YhgrzR5KS2ORy1B4xcX/cXLsvnUWvfHuqMmVU6N0YiJ4JWGRJJsLCgjEzKjG9/GKoSw==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
|
@ -7447,6 +7742,61 @@ packages:
|
||||||
fsevents: 2.3.2
|
fsevents: 2.3.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/vitest/0.28.2_terser@5.15.1:
|
||||||
|
resolution: {integrity: sha512-HJBlRla4Mng0OiZ8aWunCecJ6BzLDA4yuzuxiBuBU2MXjGB6I4zT7QgIBL/UrwGKlNxLwaDC5P/4OpeuTlW8yQ==}
|
||||||
|
engines: {node: '>=v14.16.0'}
|
||||||
|
hasBin: true
|
||||||
|
peerDependencies:
|
||||||
|
'@edge-runtime/vm': '*'
|
||||||
|
'@vitest/browser': '*'
|
||||||
|
'@vitest/ui': '*'
|
||||||
|
happy-dom: '*'
|
||||||
|
jsdom: '*'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@edge-runtime/vm':
|
||||||
|
optional: true
|
||||||
|
'@vitest/browser':
|
||||||
|
optional: true
|
||||||
|
'@vitest/ui':
|
||||||
|
optional: true
|
||||||
|
happy-dom:
|
||||||
|
optional: true
|
||||||
|
jsdom:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
'@types/chai': 4.3.4
|
||||||
|
'@types/chai-subset': 1.3.3
|
||||||
|
'@types/node': 16.18.2
|
||||||
|
'@vitest/expect': 0.28.2
|
||||||
|
'@vitest/runner': 0.28.2
|
||||||
|
'@vitest/spy': 0.28.2
|
||||||
|
'@vitest/utils': 0.28.2
|
||||||
|
acorn: 8.8.1
|
||||||
|
acorn-walk: 8.2.0
|
||||||
|
cac: 6.7.14
|
||||||
|
chai: 4.3.7
|
||||||
|
debug: 4.3.4
|
||||||
|
local-pkg: 0.4.3
|
||||||
|
pathe: 1.1.0
|
||||||
|
picocolors: 1.0.0
|
||||||
|
source-map: 0.6.1
|
||||||
|
std-env: 3.3.1
|
||||||
|
strip-literal: 1.0.0
|
||||||
|
tinybench: 2.3.1
|
||||||
|
tinypool: 0.3.0
|
||||||
|
tinyspy: 1.0.2
|
||||||
|
vite: 4.0.4_cuughdtwg7b3rwlnomrzdiszke
|
||||||
|
vite-node: 0.28.2_cuughdtwg7b3rwlnomrzdiszke
|
||||||
|
why-is-node-running: 2.2.2
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- less
|
||||||
|
- sass
|
||||||
|
- stylus
|
||||||
|
- sugarss
|
||||||
|
- supports-color
|
||||||
|
- terser
|
||||||
|
dev: true
|
||||||
|
|
||||||
/vlq/0.2.3:
|
/vlq/0.2.3:
|
||||||
resolution: {integrity: sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==}
|
resolution: {integrity: sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -7530,6 +7880,15 @@ packages:
|
||||||
isexe: 2.0.0
|
isexe: 2.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/why-is-node-running/2.2.2:
|
||||||
|
resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
hasBin: true
|
||||||
|
dependencies:
|
||||||
|
siginfo: 2.0.0
|
||||||
|
stackback: 0.0.2
|
||||||
|
dev: true
|
||||||
|
|
||||||
/widest-line/2.0.1:
|
/widest-line/2.0.1:
|
||||||
resolution: {integrity: sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA==}
|
resolution: {integrity: sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -7708,6 +8067,11 @@ packages:
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/yocto-queue/1.0.0:
|
||||||
|
resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}
|
||||||
|
engines: {node: '>=12.20'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/z-schema/5.0.4:
|
/z-schema/5.0.4:
|
||||||
resolution: {integrity: sha512-gm/lx3hDzJNcLwseIeQVm1UcwhWIKpSB4NqH89pTBtFns4k/HDHudsICtvG05Bvw/Mv3jMyk700y5dadueLHdA==}
|
resolution: {integrity: sha512-gm/lx3hDzJNcLwseIeQVm1UcwhWIKpSB4NqH89pTBtFns4k/HDHudsICtvG05Bvw/Mv3jMyk700y5dadueLHdA==}
|
||||||
engines: {node: '>=8.0.0'}
|
engines: {node: '>=8.0.0'}
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
import { vi } from 'vitest'
|
||||||
|
|
||||||
|
expect.extend({
|
||||||
|
toHaveBeenWarned(received: string) {
|
||||||
|
asserted.add(received)
|
||||||
|
const passed = warn.mock.calls.some(args => args[0].includes(received))
|
||||||
|
if (passed) {
|
||||||
|
return {
|
||||||
|
pass: true,
|
||||||
|
message: () => `expected "${received}" not to have been warned.`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const msgs = warn.mock.calls.map(args => args[0]).join('\n - ')
|
||||||
|
return {
|
||||||
|
pass: false,
|
||||||
|
message: () =>
|
||||||
|
`expected "${received}" to have been warned` +
|
||||||
|
(msgs.length
|
||||||
|
? `.\n\nActual messages:\n\n - ${msgs}`
|
||||||
|
: ` but no warning was recorded.`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toHaveBeenWarnedLast(received: string) {
|
||||||
|
asserted.add(received)
|
||||||
|
const passed =
|
||||||
|
warn.mock.calls[warn.mock.calls.length - 1][0].includes(received)
|
||||||
|
if (passed) {
|
||||||
|
return {
|
||||||
|
pass: true,
|
||||||
|
message: () => `expected "${received}" not to have been warned last.`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const msgs = warn.mock.calls.map(args => args[0]).join('\n - ')
|
||||||
|
return {
|
||||||
|
pass: false,
|
||||||
|
message: () =>
|
||||||
|
`expected "${received}" to have been warned last.\n\nActual messages:\n\n - ${msgs}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toHaveBeenWarnedTimes(received: string, n: number) {
|
||||||
|
asserted.add(received)
|
||||||
|
let found = 0
|
||||||
|
warn.mock.calls.forEach(args => {
|
||||||
|
if (args[0].includes(received)) {
|
||||||
|
found++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (found === n) {
|
||||||
|
return {
|
||||||
|
pass: true,
|
||||||
|
message: () => `expected "${received}" to have been warned ${n} times.`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
pass: false,
|
||||||
|
message: () =>
|
||||||
|
`expected "${received}" to have been warned ${n} times but got ${found}.`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let warn
|
||||||
|
const asserted: Set<string> = new Set()
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
asserted.clear()
|
||||||
|
warn = vi.spyOn(console, 'warn')
|
||||||
|
warn.mockImplementation(() => {})
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
const assertedArray = Array.from(asserted)
|
||||||
|
const nonAssertedWarnings = warn.mock.calls
|
||||||
|
.map(args => args[0])
|
||||||
|
.filter(received => {
|
||||||
|
return !assertedArray.some(assertedMsg => {
|
||||||
|
return received.includes(assertedMsg)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
warn.mockRestore()
|
||||||
|
if (nonAssertedWarnings.length) {
|
||||||
|
throw new Error(
|
||||||
|
`test case threw unexpected warnings:\n - ${nonAssertedWarnings.join(
|
||||||
|
'\n - '
|
||||||
|
)}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { defineConfig } from 'vitest/config'
|
||||||
|
import path from 'node:path'
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
import { readdirSync } from 'node:fs'
|
||||||
|
|
||||||
|
const resolve = p =>
|
||||||
|
path.resolve(fileURLToPath(import.meta.url), `../packages/${p}/src`)
|
||||||
|
const dirs = readdirSync(new URL('./packages', import.meta.url))
|
||||||
|
const alias = {}
|
||||||
|
for (const dir of dirs) {
|
||||||
|
alias[`@vue/${dir}`] = resolve(dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
define: {
|
||||||
|
__DEV__: true,
|
||||||
|
__TEST__: true,
|
||||||
|
__VERSION__: '"test"',
|
||||||
|
__BROWSER__: false,
|
||||||
|
__GLOBAL__: false,
|
||||||
|
__ESM_BUNDLER__: true,
|
||||||
|
__ESM_BROWSER__: false,
|
||||||
|
__NODE_JS__: true,
|
||||||
|
__SSR__: true,
|
||||||
|
__FEATURE_OPTIONS_API__: true,
|
||||||
|
__FEATURE_SUSPENSE__: true,
|
||||||
|
__FEATURE_PROD_DEVTOOLS__: false,
|
||||||
|
__COMPAT__: true
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
...alias,
|
||||||
|
vue: resolve('vue'),
|
||||||
|
'vue/compiler-sfc': resolve('compiler-sfc'),
|
||||||
|
'vue/server-renderer': resolve('server-renderer'),
|
||||||
|
'@vue/compat': resolve('vue-compat')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
setupFiles: 'scripts/setupVitest.ts'
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in New Issue