2
0
mirror of https://github.com/tenrok/maska.git synced 2026-06-14 18:42:27 +03:00

allow custom escape character

This commit is contained in:
Dan Wilson
2023-04-18 14:00:50 -06:00
parent e965d15c81
commit e078efd695
4 changed files with 53 additions and 2 deletions
+36
View File
@@ -1449,6 +1449,42 @@ describe("Optional with multiple '-9' mask", () => {
})
})
describe("Custom escape with '$#!99' mask", () => {
beforeAll(() => {
input = prepareInput({
mask: '$#!99',
tokens: {
'$': { pattern: /\$/, escape: true },
'9': { pattern: /\d/, multiple: true }
},
})
})
afterEach(async () => {
await user.clear(input)
})
test('input { }', async () => {
await user.type(input, '{ }')
expect(input).toHaveValue('#9')
})
test('input 1', async () => {
await user.type(input, '1')
expect(input).toHaveValue('#91')
})
test('input 91', async () => {
await user.type(input, '91')
expect(input).toHaveValue('#91')
})
test('input 1234', async () => {
await user.type(input, '1234')
expect(input).toHaveValue('#91234')
})
})
describe('IP mask', () => {
beforeAll(() => {
input = prepareInput({