unit test EditField ignore_keys

develop
myk002 2022-08-29 11:49:12 -07:00 committed by Myk
parent 074a6ec5cd
commit c178fa35a2
1 changed files with 15 additions and 0 deletions

@ -54,3 +54,18 @@ function test.editfield_click()
expect.eq(3, e.cursor) expect.eq(3, e.cursor)
end) end)
end end
function test.editfield_ignore_keys()
local e = widgets.EditField{ignore_keys={'CUSTOM_B', 'CUSTOM_C'}}
e:setFocus(true)
e:onInput{_STRING=string.byte('a'), CUSTOM_A=true}
expect.eq('a', e.text, '"a" should be accepted')
e:onInput{_STRING=string.byte('b'), CUSTOM_B=true}
expect.eq('a', e.text, '"b" should be rejected')
e:onInput{_STRING=string.byte('c'), CUSTOM_C=true}
expect.eq('a', e.text, '"c" should be rejected')
e:onInput{_STRING=string.byte('d'), CUSTOM_D=true}
expect.eq('ad', e.text, '"d" should be accepted')
end