Skip to content

Commit 045c8cf

Browse files
Tests: Jest - Add back test case for text mask with invalid character
1 parent 3e06c8c commit 045c8cf

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/jest/cases/components/controls/Text.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ describe('Text component', () => {
115115
expect(input.value).toBe('123/abc')
116116
})
117117

118+
it('mask rejects invalid characters', async () => {
119+
120+
const { container } = render(
121+
fields.render({
122+
name : 'field-name',
123+
type : 'text',
124+
label : 'Label',
125+
inputMask : '999/aaa',
126+
})
127+
)
128+
129+
const input = container.querySelector('input.tui-input')
130+
const user = userEvent.setup()
131+
132+
// Type digits where letters are expected (after the /)
133+
await user.type(input, '123456')
134+
135+
// 456 are digits, but the last 3 slots expect letters (aaa) — should be rejected
136+
expect(input.value).not.toBe('123/456')
137+
expect(input.value).toBe('123/___')
138+
})
139+
118140
it('supports placeholder', () => {
119141

120142
const { container } = render(

0 commit comments

Comments
 (0)