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

feat: use RegExp 'u' flag by default

This commit is contained in:
Alexander Shabunevich
2025-07-02 13:00:01 +03:00
parent 13570ed875
commit 615c597897
4 changed files with 49 additions and 2 deletions
+22
View File
@@ -2162,3 +2162,25 @@ describe('Number mask', () => {
expect(input).toHaveValue('1,234')
})
})
describe('Unicode tokens mask', () => {
test('default number', async () => {
document.body.innerHTML = `<input id="input" data-maska="A" data-maska-tokens="A:[\\p{L}]:multiple">`
const input = <HTMLInputElement>document.getElementById('input')
new MaskInput(input)
await user.type(input, '1')
expect(input).toHaveValue('')
await user.type(input, 'z')
expect(input).toHaveValue('z')
await user.type(input, 'я')
expect(input).toHaveValue('zя')
await user.type(input, '1')
expect(input).toHaveValue('zя')
await user.clear(input)
})
})
+13
View File
@@ -820,3 +820,16 @@ test('tokens replaced', () => {
expect(mask.unmasked('12')).toBe('1')
})
test('unicode tokens', () => {
const mask = new Mask({
mask: 'A',
// @ts-expect-error
tokens: { A: { pattern: '[\\p{L}]', multiple: true } }
})
expect(mask.masked('1')).toBe('')
expect(mask.masked('z')).toBe('z')
expect(mask.masked('zя')).toBe('zя')
expect(mask.masked('zя1')).toBe('zя')
})