mirror of
https://github.com/tenrok/maska.git
synced 2026-05-15 11:59:38 +03:00
test: additional check for callbacks with binding
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { MaskInputOptions, vMaska } from '../../src'
|
||||
|
||||
const emit = defineEmits(['mask1', 'mask2', 'mask3'])
|
||||
|
||||
const bound1 = ref('')
|
||||
const bound2 = ref('')
|
||||
|
||||
const options1 = <MaskInputOptions>{
|
||||
onMaska: (detail) => emit('mask1', detail)
|
||||
}
|
||||
@@ -15,6 +19,8 @@ const options2 = <MaskInputOptions>{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input id="input1" v-maska="options1" data-maska="#-#" />
|
||||
<input id="input2" v-maska="options2" data-maska="#-#" />
|
||||
<input id="input1" v-maska:bound1="options1" data-maska="#-#" />
|
||||
<input id="input2" v-maska:bound2="options2" data-maska="#-#" />
|
||||
<div class="bound1">{{ bound1 }}</div>
|
||||
<div class="bound2">{{ bound2 }}</div>
|
||||
</template>
|
||||
|
||||
@@ -255,7 +255,7 @@ test('callbacks', async () => {
|
||||
expect(wrapper.emitted('mask1')).toHaveLength(2)
|
||||
expect(wrapper.emitted('mask1')[1][0]).toHaveProperty('completed', true)
|
||||
|
||||
await input2.setValue('1')
|
||||
await input2.setValue('3')
|
||||
expect(wrapper.emitted()).toHaveProperty('mask2')
|
||||
expect(wrapper.emitted()).toHaveProperty('mask3')
|
||||
expect(wrapper.emitted('mask2')).toHaveLength(1)
|
||||
@@ -263,11 +263,14 @@ test('callbacks', async () => {
|
||||
expect(wrapper.emitted('mask2')[0][0]).toHaveProperty('completed', false)
|
||||
expect(wrapper.emitted('mask3')[0][0]).toHaveProperty('completed', false)
|
||||
|
||||
await input2.setValue('12')
|
||||
await input2.setValue('34')
|
||||
expect(wrapper.emitted('mask2')).toHaveLength(2)
|
||||
expect(wrapper.emitted('mask3')).toHaveLength(2)
|
||||
expect(wrapper.emitted('mask2')[1][0]).toHaveProperty('completed', true)
|
||||
expect(wrapper.emitted('mask3')[1][0]).toHaveProperty('completed', true)
|
||||
|
||||
expect(wrapper.get('.bound1').element.textContent).toBe('1-2')
|
||||
expect(wrapper.get('.bound2').element.textContent).toBe('3-4')
|
||||
})
|
||||
|
||||
test('options api component', async () => {
|
||||
|
||||
Reference in New Issue
Block a user