2
0
mirror of https://github.com/tenrok/maska.git synced 2026-06-05 16:42:28 +03:00

Update masked input on binded value change

This commit is contained in:
Alexander Shabunevich
2022-12-24 17:49:08 +03:00
parent 591ff1b0bc
commit 3b44a9b4a9
4 changed files with 40 additions and 4 deletions
+11
View File
@@ -0,0 +1,11 @@
<script setup>
import { ref } from 'vue'
import { vMaska } from '../../src'
const data = ref('123')
</script>
<template>
<input v-maska data-maska="#-#" v-model="data" />
<button @click="data = '345'">Set</button>
</template>
+14
View File
@@ -6,6 +6,7 @@ import BindInitial from './components/BindInitial.vue'
import BindMasked from './components/BindMasked.vue'
import BindUnmasked from './components/BindUnmasked.vue'
import Callbacks from './components/Callbacks.vue'
import ChangeValue from './components/ChangeValue.vue'
import Completed from './components/Completed.vue'
import Config from './components/Config.vue'
import Custom from './components/Custom.vue'
@@ -137,6 +138,19 @@ test('custom component', async () => {
expect(wrapper.get('div').element.textContent).toBe('1-2')
})
test('change value', async () => {
const wrapper = mount(ChangeValue)
const input = wrapper.get('input')
await new Promise((r) => setTimeout(r))
expect(input.element.value).toBe('1-2')
await wrapper.get('button').trigger('click')
expect(input.element.value).toBe('3-4')
})
test('multiple inputs', async () => {
const wrapper = mount(Multiple)
const input = wrapper.get<HTMLInputElement>('#input1')