2
0
mirror of https://github.com/tenrok/maska.git synced 2026-06-17 19:21:21 +03:00

Callback onMaska now can accept array

To make it possible use callback with binded value
This commit is contained in:
Alexander Shabunevich
2022-12-07 11:34:02 +03:00
parent 2d594a4837
commit 57f4f44959
5 changed files with 90 additions and 3 deletions
+30
View File
@@ -5,6 +5,7 @@ import { mount } from '@vue/test-utils'
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 Completed from './components/Completed.vue'
import Config from './components/Config.vue'
import DataAttr from './components/DataAttr.vue'
@@ -154,6 +155,35 @@ test('events', async () => {
expect(wrapper.emitted('mask')[1][0]).toHaveProperty('completed', true)
})
test('callbacks', async () => {
const wrapper = mount(Callbacks)
const input1 = wrapper.get('#input1')
const input2 = wrapper.get('#input2')
await input1.setValue('1')
expect(wrapper.emitted()).toHaveProperty('mask1')
expect(wrapper.emitted('mask1')).toHaveLength(1)
expect(wrapper.emitted('mask1')[0][0]).toHaveProperty('completed', false)
await input1.setValue('12')
expect(wrapper.emitted('mask1')).toHaveLength(2)
expect(wrapper.emitted('mask1')[1][0]).toHaveProperty('completed', true)
await input2.setValue('1')
expect(wrapper.emitted()).toHaveProperty('mask2')
expect(wrapper.emitted()).toHaveProperty('mask3')
expect(wrapper.emitted('mask2')).toHaveLength(1)
expect(wrapper.emitted('mask3')).toHaveLength(1)
expect(wrapper.emitted('mask2')[0][0]).toHaveProperty('completed', false)
expect(wrapper.emitted('mask3')[0][0]).toHaveProperty('completed', false)
await input2.setValue('12')
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)
})
test('options api component', async () => {
const wrapper = mount(Options)
const input = wrapper.get('input')