(CustomInput: ComponentOptions)
| 84 | }) |
| 85 | |
| 86 | async function runTestWithModifier(CustomInput: ComponentOptions) { |
| 87 | const vm = new Vue({ |
| 88 | data() { |
| 89 | return { |
| 90 | text: ' foo ', |
| 91 | } |
| 92 | }, |
| 93 | components: { |
| 94 | CustomInput, |
| 95 | }, |
| 96 | template: ` |
| 97 | <div> |
| 98 | <span>{{ text }}</span> |
| 99 | <custom-input v-model.trim="text"></custom-input> |
| 100 | </div> |
| 101 | `, |
| 102 | }).$mount() as any |
| 103 | |
| 104 | const input = vm.$el.querySelector('input') |
| 105 | const span = vm.$el.querySelector('span') |
| 106 | |
| 107 | expect(input.value).toBe(' foo ') |
| 108 | expect(span.textContent).toBe(' foo ') |
| 109 | |
| 110 | expect( |
| 111 | (deprecationData[DeprecationTypes.COMPONENT_V_MODEL].message as Function)( |
| 112 | CustomInput, |
| 113 | ), |
| 114 | ).toHaveBeenWarned() |
| 115 | |
| 116 | input.value = ' bar ' |
| 117 | triggerEvent(input, 'input') |
| 118 | await nextTick() |
| 119 | |
| 120 | expect(input.value).toBe('bar') |
| 121 | expect(span.textContent).toBe('bar') |
| 122 | } |
| 123 | |
| 124 | test('with model modifiers', async () => { |
| 125 | await runTestWithModifier({ |
no test coverage detected