2
0
mirror of https://github.com/tenrok/maska.git synced 2026-05-15 11:59:38 +03:00

#51 Added test,

switched jest env to jsdom,
lint fixed
This commit is contained in:
Yury Mamedov
2021-11-10 01:28:55 +03:00
parent d3f1a7b582
commit 0cf4d7c7b8
5 changed files with 32 additions and 11 deletions
+17
View File
@@ -1,5 +1,6 @@
import mask from './../src/mask'
import tokens from './../src/tokens'
import Maska from './../src/maska'
test('12 #.#', () => {
expect(mask('12', '#.#', tokens)).toBe('1.2')
@@ -205,3 +206,19 @@ test('Custom transform with `uppercase` and `lowercase` enabled: abkTYX -> АВ
}
})).toBe('авктух')
})
test('Custom value preprocessing', () => {
const elem = document.createElement('input')
document.body.appendChild(elem)
const mask = new Maska(elem, {
mask: 'S*',
preprocessor: function(val) {
return val.toLocaleUpperCase()
}
})
elem.value = "abkTYX"
elem.dispatchEvent(new Event('input', {bubbles: true}))
expect(elem.value).toBe("ABKTYX")
})