chore: run updated prettier
This commit is contained in:
@@ -123,15 +123,16 @@ describe('SFC <script setup> helpers', () => {
|
||||
|
||||
beforeInstance = getCurrentInstance()
|
||||
|
||||
const msg = (([__temp, __restore] = withAsyncContext(
|
||||
() =>
|
||||
new Promise(r => {
|
||||
resolve = r
|
||||
})
|
||||
)),
|
||||
(__temp = await __temp),
|
||||
__restore(),
|
||||
__temp)
|
||||
const msg =
|
||||
(([__temp, __restore] = withAsyncContext(
|
||||
() =>
|
||||
new Promise(r => {
|
||||
resolve = r
|
||||
})
|
||||
)),
|
||||
(__temp = await __temp),
|
||||
__restore(),
|
||||
__temp)
|
||||
|
||||
// register the lifecycle after an await statement
|
||||
onMounted(spy)
|
||||
@@ -141,7 +142,10 @@ describe('SFC <script setup> helpers', () => {
|
||||
})
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
render(h(() => h(Suspense, () => h(Comp))), root)
|
||||
render(
|
||||
h(() => h(Suspense, () => h(Comp))),
|
||||
root
|
||||
)
|
||||
|
||||
expect(spy).not.toHaveBeenCalled()
|
||||
resolve!('hello')
|
||||
@@ -186,7 +190,10 @@ describe('SFC <script setup> helpers', () => {
|
||||
})
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
render(h(() => h(Suspense, () => h(Comp))), root)
|
||||
render(
|
||||
h(() => h(Suspense, () => h(Comp))),
|
||||
root
|
||||
)
|
||||
|
||||
expect(spy).not.toHaveBeenCalled()
|
||||
reject!()
|
||||
@@ -242,7 +249,10 @@ describe('SFC <script setup> helpers', () => {
|
||||
})
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
render(h(() => h(Suspense, () => h(Comp))), root)
|
||||
render(
|
||||
h(() => h(Suspense, () => h(Comp))),
|
||||
root
|
||||
)
|
||||
|
||||
await ready
|
||||
expect(inBandInstance).toBe(beforeInstance)
|
||||
|
||||
@@ -115,8 +115,8 @@ describe('api: template refs', () => {
|
||||
const fn = jest.fn()
|
||||
const toggle = ref(true)
|
||||
|
||||
const Comp = defineComponent(() => () =>
|
||||
toggle.value ? h('div', { ref: fn }) : null
|
||||
const Comp = defineComponent(
|
||||
() => () => toggle.value ? h('div', { ref: fn }) : null
|
||||
)
|
||||
render(h(Comp), root)
|
||||
expect(fn.mock.calls[0][0]).toBe(root.children[0])
|
||||
|
||||
@@ -168,7 +168,10 @@ describe('api: watch', () => {
|
||||
state.count++
|
||||
count.value++
|
||||
await nextTick()
|
||||
expect(dummy).toMatchObject([[2, 2, 3], [1, 1, 2]])
|
||||
expect(dummy).toMatchObject([
|
||||
[2, 2, 3],
|
||||
[1, 1, 2]
|
||||
])
|
||||
})
|
||||
|
||||
it('watching multiple sources: readonly array', async () => {
|
||||
@@ -188,7 +191,10 @@ describe('api: watch', () => {
|
||||
state.count++
|
||||
status.value = true
|
||||
await nextTick()
|
||||
expect(dummy).toMatchObject([[2, true], [1, false]])
|
||||
expect(dummy).toMatchObject([
|
||||
[2, true],
|
||||
[1, false]
|
||||
])
|
||||
})
|
||||
|
||||
it('watching multiple sources: reactive object (with automatic deep: true)', async () => {
|
||||
@@ -568,7 +574,10 @@ describe('api: watch', () => {
|
||||
count: ref(0)
|
||||
},
|
||||
array: [1, 2, 3],
|
||||
map: new Map([['a', 1], ['b', 2]]),
|
||||
map: new Map([
|
||||
['a', 1],
|
||||
['b', 2]
|
||||
]),
|
||||
set: new Set([1, 2, 3])
|
||||
})
|
||||
|
||||
@@ -868,7 +877,10 @@ describe('api: watch', () => {
|
||||
mounted() {
|
||||
// this call runs while Comp is currentInstance, but
|
||||
// the effect for this `$watch` should nontheless be registered with Child
|
||||
this.comp!.$watch(() => this.show, () => void 0)
|
||||
this.comp!.$watch(
|
||||
() => this.show,
|
||||
() => void 0
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -895,7 +907,7 @@ describe('api: watch', () => {
|
||||
render() {},
|
||||
created(this: any) {
|
||||
instance = this
|
||||
this.$watch(source, function() {})
|
||||
this.$watch(source, function () {})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ describe('component: proxy', () => {
|
||||
expect(() => (instanceProxy.$data = {})).toThrow(TypeError)
|
||||
expect(`Attempting to mutate public property "$data"`).toHaveBeenWarned()
|
||||
|
||||
const nextTickThis = await instanceProxy.$nextTick(function(this: any) {
|
||||
const nextTickThis = await instanceProxy.$nextTick(function (this: any) {
|
||||
return this
|
||||
})
|
||||
expect(nextTickThis).toBe(instanceProxy)
|
||||
|
||||
@@ -258,9 +258,8 @@ describe('BaseTransition', () => {
|
||||
) {
|
||||
const toggle = ref(true)
|
||||
const { props, cbs } = mockProps({ mode })
|
||||
const root = mount(
|
||||
props,
|
||||
() => (toggle.value ? trueBranch() : falseBranch())
|
||||
const root = mount(props, () =>
|
||||
toggle.value ? trueBranch() : falseBranch()
|
||||
)
|
||||
|
||||
// without appear: true, enter hooks should not be called on mount
|
||||
@@ -348,9 +347,8 @@ describe('BaseTransition', () => {
|
||||
}: ToggleOptions) {
|
||||
const toggle = ref(false)
|
||||
const { props, cbs } = mockProps()
|
||||
const root = mount(
|
||||
props,
|
||||
() => (toggle.value ? trueBranch() : falseBranch())
|
||||
const root = mount(props, () =>
|
||||
toggle.value ? trueBranch() : falseBranch()
|
||||
)
|
||||
|
||||
// start enter
|
||||
|
||||
@@ -841,10 +841,8 @@ describe('KeepAlive', () => {
|
||||
const instanceRef = ref<any>(null)
|
||||
const App = {
|
||||
render: () => {
|
||||
return h(
|
||||
KeepAlive,
|
||||
{ include: 'Foo' },
|
||||
() => (toggle.value ? h(AsyncComp, { ref: instanceRef }) : null)
|
||||
return h(KeepAlive, { include: 'Foo' }, () =>
|
||||
toggle.value ? h(AsyncComp, { ref: instanceRef }) : null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,10 @@ describe('renderer: teleport', () => {
|
||||
const root = nodeOps.createElement('div')
|
||||
const children = ref([h('div', 'teleported')])
|
||||
|
||||
render(h(() => h(Teleport, { to: target }, children.value)), root)
|
||||
render(
|
||||
h(() => h(Teleport, { to: target }, children.value)),
|
||||
root
|
||||
)
|
||||
expect(serializeInner(target)).toMatchInlineSnapshot(
|
||||
`"<div>teleported</div>"`
|
||||
)
|
||||
|
||||
@@ -42,7 +42,10 @@ describe('createSlot', () => {
|
||||
it('should add each slot to the record when given slot is an array', () => {
|
||||
const dynamicSlot = [
|
||||
{ name: 'descriptor', fn: slot },
|
||||
[{ name: 'descriptor2', fn: slot }, { name: 'descriptor3', fn: slot }]
|
||||
[
|
||||
{ name: 'descriptor2', fn: slot },
|
||||
{ name: 'descriptor3', fn: slot }
|
||||
]
|
||||
]
|
||||
|
||||
const actual = createSlots(record, dynamicSlot)
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('renderList', () => {
|
||||
})
|
||||
|
||||
it('should render an item for entry in an iterable', () => {
|
||||
const iterable = function*() {
|
||||
const iterable = function* () {
|
||||
yield 1
|
||||
yield 2
|
||||
yield 3
|
||||
|
||||
@@ -759,9 +759,11 @@ describe('SSR hydration', () => {
|
||||
})
|
||||
|
||||
expect(
|
||||
(app.mount(svgContainer).$.subTree as VNode<Node, Element> & {
|
||||
el: Element
|
||||
}).el instanceof SVGElement
|
||||
(
|
||||
app.mount(svgContainer).$.subTree as VNode<Node, Element> & {
|
||||
el: Element
|
||||
}
|
||||
).el instanceof SVGElement
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -321,21 +321,28 @@ describe('renderer: keyed children', () => {
|
||||
}
|
||||
|
||||
for (let n = 0; n < samples; ++n) {
|
||||
render(h('span', arr.map(n => spanNumWithOpacity(n, '1'))), root)
|
||||
render(
|
||||
h(
|
||||
'span',
|
||||
arr.map(n => spanNumWithOpacity(n, '1'))
|
||||
),
|
||||
root
|
||||
)
|
||||
elm = root.children[0] as TestElement
|
||||
|
||||
for (let i = 0; i < elms; ++i) {
|
||||
expect(serializeInner(elm.children[i] as TestElement)).toBe(
|
||||
i.toString()
|
||||
)
|
||||
opacities[i] = Math.random()
|
||||
.toFixed(5)
|
||||
.toString()
|
||||
opacities[i] = Math.random().toFixed(5).toString()
|
||||
}
|
||||
|
||||
const shufArr = shuffle(arr.slice(0))
|
||||
render(
|
||||
h('span', arr.map(n => spanNumWithOpacity(shufArr[n], opacities[n]))),
|
||||
h(
|
||||
'span',
|
||||
arr.map(n => spanNumWithOpacity(shufArr[n], opacities[n]))
|
||||
),
|
||||
root
|
||||
)
|
||||
elm = root.children[0] as TestElement
|
||||
|
||||
@@ -217,7 +217,10 @@ describe('renderer: component', () => {
|
||||
const Child = {
|
||||
props: ['value'],
|
||||
setup(props: any, { emit }: SetupContext) {
|
||||
watch(() => props.value, (val: number) => emit('update', val))
|
||||
watch(
|
||||
() => props.value,
|
||||
(val: number) => emit('update', val)
|
||||
)
|
||||
|
||||
return () => {
|
||||
return h('div', props.value)
|
||||
|
||||
@@ -417,11 +417,12 @@ describe('renderer: optimized mode', () => {
|
||||
const Comp = defineComponent({
|
||||
setup(_props, { slots }) {
|
||||
return () => {
|
||||
const vnode = (openBlock(),
|
||||
(block = createBlock('div', null, {
|
||||
default: withCtx(() => [renderSlot(slots, 'default')]),
|
||||
_: SlotFlags.FORWARDED
|
||||
})))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
(block = createBlock('div', null, {
|
||||
default: withCtx(() => [renderSlot(slots, 'default')]),
|
||||
_: SlotFlags.FORWARDED
|
||||
})))
|
||||
|
||||
return vnode
|
||||
}
|
||||
@@ -449,8 +450,9 @@ describe('renderer: optimized mode', () => {
|
||||
expect(block!.dynamicChildren![0].type).toBe(Fragment)
|
||||
expect(block!.dynamicChildren![0].dynamicChildren!.length).toBe(1)
|
||||
expect(
|
||||
serialize(block!.dynamicChildren![0].dynamicChildren![0]
|
||||
.el as TestElement)
|
||||
serialize(
|
||||
block!.dynamicChildren![0].dynamicChildren![0].el as TestElement
|
||||
)
|
||||
).toBe('<p>0</p>')
|
||||
|
||||
foo.value++
|
||||
|
||||
@@ -226,7 +226,7 @@ describe('backwards compat with <=3.0.7', () => {
|
||||
test('should work on slots', () => {
|
||||
const Child = {
|
||||
__scopeId: 'child',
|
||||
render: withChildId(function(this: any) {
|
||||
render: withChildId(function (this: any) {
|
||||
return h('div', renderSlot(this.$slots, 'default'))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -411,9 +411,9 @@ describe('vnode', () => {
|
||||
})
|
||||
|
||||
test('handlers', () => {
|
||||
let clickHandler1 = function() {}
|
||||
let clickHandler2 = function() {}
|
||||
let focusHandler2 = function() {}
|
||||
let clickHandler1 = function () {}
|
||||
let clickHandler2 = function () {}
|
||||
let focusHandler2 = function () {}
|
||||
|
||||
let props1: Data = { onClick: clickHandler1 }
|
||||
let props2: Data = { onClick: clickHandler2, onFocus: focusHandler2 }
|
||||
@@ -439,37 +439,41 @@ describe('vnode', () => {
|
||||
test('with patchFlags', () => {
|
||||
const hoist = createVNode('div')
|
||||
let vnode1
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
|
||||
]))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
|
||||
})
|
||||
|
||||
test('should not track vnodes with only HYDRATE_EVENTS flag', () => {
|
||||
const hoist = createVNode('div')
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
createVNode('div', null, 'text', PatchFlags.HYDRATE_EVENTS)
|
||||
]))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
createVNode('div', null, 'text', PatchFlags.HYDRATE_EVENTS)
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([])
|
||||
})
|
||||
|
||||
test('many times call openBlock', () => {
|
||||
const hoist = createVNode('div')
|
||||
let vnode1, vnode2, vnode3
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)),
|
||||
(vnode2 = (openBlock(),
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode3 = createVNode('div', null, 'text', PatchFlags.TEXT))
|
||||
])))
|
||||
]))
|
||||
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)),
|
||||
(vnode2 =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode3 = createVNode('div', null, 'text', PatchFlags.TEXT))
|
||||
])))
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([vnode1, vnode2])
|
||||
expect(vnode2.dynamicChildren).toStrictEqual([vnode3])
|
||||
})
|
||||
@@ -477,33 +481,36 @@ describe('vnode', () => {
|
||||
test('with stateful component', () => {
|
||||
const hoist = createVNode('div')
|
||||
let vnode1
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode({}, null, 'text'))
|
||||
]))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode({}, null, 'text'))
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
|
||||
})
|
||||
|
||||
test('with functional component', () => {
|
||||
const hoist = createVNode('div')
|
||||
let vnode1
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode(() => {}, null, 'text'))
|
||||
]))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode(() => {}, null, 'text'))
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
|
||||
})
|
||||
|
||||
test('with suspense', () => {
|
||||
const hoist = createVNode('div')
|
||||
let vnode1
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode(() => {}, null, 'text'))
|
||||
]))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
hoist,
|
||||
(vnode1 = createVNode(() => {}, null, 'text'))
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
|
||||
})
|
||||
|
||||
@@ -516,32 +523,35 @@ describe('vnode', () => {
|
||||
test('element block should track normalized slot children', () => {
|
||||
const hoist = createVNode('div')
|
||||
let vnode1: any
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, {
|
||||
default: () => {
|
||||
return [
|
||||
hoist,
|
||||
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
|
||||
]
|
||||
}
|
||||
}))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, {
|
||||
default: () => {
|
||||
return [
|
||||
hoist,
|
||||
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
|
||||
]
|
||||
}
|
||||
}))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
|
||||
})
|
||||
|
||||
test('openBlock w/ disableTracking: true', () => {
|
||||
const hoist = createVNode('div')
|
||||
let vnode1
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
// a v-for fragment block generated by the compiler
|
||||
// disables tracking because it always diffs its
|
||||
// children.
|
||||
(vnode1 = (openBlock(true),
|
||||
createBlock(Fragment, null, [
|
||||
hoist,
|
||||
/*vnode2*/ createVNode(() => {}, null, 'text')
|
||||
])))
|
||||
]))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
// a v-for fragment block generated by the compiler
|
||||
// disables tracking because it always diffs its
|
||||
// children.
|
||||
(vnode1 =
|
||||
(openBlock(true),
|
||||
createBlock(Fragment, null, [
|
||||
hoist,
|
||||
/*vnode2*/ createVNode(() => {}, null, 'text')
|
||||
])))
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
|
||||
expect(vnode1.dynamicChildren).toStrictEqual([])
|
||||
})
|
||||
@@ -549,27 +559,30 @@ describe('vnode', () => {
|
||||
test('openBlock without disableTracking: true', () => {
|
||||
const hoist = createVNode('div')
|
||||
let vnode1, vnode2
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
(vnode1 = (openBlock(),
|
||||
createBlock(Fragment, null, [
|
||||
hoist,
|
||||
(vnode2 = createVNode(() => {}, null, 'text'))
|
||||
])))
|
||||
]))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
(vnode1 =
|
||||
(openBlock(),
|
||||
createBlock(Fragment, null, [
|
||||
hoist,
|
||||
(vnode2 = createVNode(() => {}, null, 'text'))
|
||||
])))
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([vnode1])
|
||||
expect(vnode1.dynamicChildren).toStrictEqual([vnode2])
|
||||
})
|
||||
|
||||
test('should not track openBlock() when tracking is disabled', () => {
|
||||
let vnode1
|
||||
const vnode = (openBlock(),
|
||||
createBlock('div', null, [
|
||||
setBlockTracking(-1),
|
||||
(vnode1 = (openBlock(), createBlock('div'))),
|
||||
setBlockTracking(1),
|
||||
vnode1
|
||||
]))
|
||||
const vnode =
|
||||
(openBlock(),
|
||||
createBlock('div', null, [
|
||||
setBlockTracking(-1),
|
||||
(vnode1 = (openBlock(), createBlock('div'))),
|
||||
setBlockTracking(1),
|
||||
vnode1
|
||||
]))
|
||||
expect(vnode.dynamicChildren).toStrictEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user