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
+20
View File
@@ -63,6 +63,26 @@ describe('test init', () => {
)
})
test('test callbacks', async () => {
document.body.innerHTML = `<input id="input" data-maska="#-#">`
const input = <HTMLInputElement>document.getElementById('input')
const onMaska1 = vi.fn()
const onMaska2 = vi.fn()
new MaskInput(input, { onMaska: [onMaska1, onMaska2] })
await user.type(input, '12')
expect(onMaska1).toHaveBeenCalledTimes(2)
expect(onMaska2).toHaveBeenCalledTimes(2)
expect(onMaska1).toHaveBeenLastCalledWith(
expect.objectContaining({
masked: '1-2',
unmasked: '12',
completed: true
})
)
})
test('test hooks', async () => {
document.body.innerHTML = `<input id="input" data-maska="@-@">`
const input = <HTMLInputElement>document.getElementById('input')