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

Function runTest

packages/vue-compat/__tests__/componentVModel.spec.ts:25–64  ·  view source on GitHub ↗
(CustomInput: ComponentOptions)

Source from the content-addressed store, hash-verified

23
24describe('COMPONENT_V_MODEL', () => {
25 async function runTest(CustomInput: ComponentOptions) {
26 const vm = new Vue({
27 data() {
28 return {
29 text: 'foo',
30 }
31 },
32 components: { CustomInput },
33 template: `
34 <div>
35 <span>{{ text }}</span>
36 <custom-input v-model="text"></custom-input>
37 </div>
38 `,
39 }).$mount() as any
40
41 const input = vm.$el.querySelector('input')
42 const span = vm.$el.querySelector('span')
43
44 expect(input.value).toBe('foo')
45 expect(span.textContent).toBe('foo')
46
47 expect(
48 (deprecationData[DeprecationTypes.COMPONENT_V_MODEL].message as Function)(
49 CustomInput,
50 ),
51 ).toHaveBeenWarned()
52
53 input.value = 'bar'
54 triggerEvent(input, 'input')
55 await nextTick()
56
57 expect(input.value).toBe('bar')
58 expect(span.textContent).toBe('bar')
59
60 vm.text = 'baz'
61 await nextTick()
62 expect(input.value).toBe('baz')
63 expect(span.textContent).toBe('baz')
64 }
65
66 test('basic usage', async () => {
67 await runTest({

Callers 1

Calls 5

triggerEventFunction · 0.90
nextTickFunction · 0.90
$mountMethod · 0.80
querySelectorMethod · 0.80
toHaveBeenWarnedMethod · 0.80

Tested by

no test coverage detected