MCPcopy
hub / github.com/vuejs/core / mockProps

Function mockProps

packages/runtime-core/__tests__/components/BaseTransition.spec.ts:38–78  ·  view source on GitHub ↗
(
  extra: BaseTransitionProps<TestElement> = {},
  withKeepAlive = false,
)

Source from the content-addressed store, hash-verified

36}
37
38function mockProps(
39 extra: BaseTransitionProps<TestElement> = {},
40 withKeepAlive = false,
41) {
42 const cbs: {
43 doneEnter: Record<string, () => void>
44 doneLeave: Record<string, () => void>
45 } = {
46 doneEnter: {},
47 doneLeave: {},
48 }
49 const props: BaseTransitionProps<TestElement> = {
50 onBeforeEnter: vi.fn(el => {
51 if (!extra.persisted && !withKeepAlive) {
52 expect(el.parentNode).toBeNull()
53 }
54 }),
55 onEnter: vi.fn((el, done) => {
56 cbs.doneEnter[serialize(el as TestElement)] = done
57 }),
58 onAfterEnter: vi.fn<(el: TestElement) => void>(),
59 onEnterCancelled: vi.fn<(el: TestElement) => void>(),
60 onBeforeLeave: vi.fn<(el: TestElement) => void>(),
61 onLeave: vi.fn((el, done) => {
62 cbs.doneLeave[serialize(el as TestElement)] = done
63 }),
64 onAfterLeave: vi.fn<(el: TestElement) => void>(),
65 onLeaveCancelled: vi.fn<(el: TestElement) => void>(),
66 onBeforeAppear: vi.fn<(el: TestElement) => void>(),
67 onAppear: vi.fn((el, done) => {
68 cbs.doneEnter[serialize(el as TestElement)] = done
69 }),
70 onAfterAppear: vi.fn<(el: TestElement) => void>(),
71 onAppearCancelled: vi.fn<(el: TestElement) => void>(),
72 ...extra,
73 }
74 return {
75 props,
76 cbs,
77 }
78}
79
80function assertCalls(
81 props: BaseTransitionProps<TestElement>,

Callers 10

testToggleOnOffFunction · 0.85
testToggleBranchesFunction · 0.85
testOutInFunction · 0.85
testOutInBeforeFinishFunction · 0.85
testOutInDoubleToggleFunction · 0.85
testInOutFunction · 0.85
testInOutBeforeFinishFunction · 0.85

Calls 1

serializeFunction · 0.90

Tested by

no test coverage detected