jquery.formance icon indicating copy to clipboard operation
jquery.formance copied to clipboard

Tests are failing on restrictNumeric and restrictAlphaNumeric

Open omarshammas opened this issue 11 years ago • 1 comments

The tests are failing, but in practice it works.

omarshammas avatar Sep 10 '13 20:09 omarshammas

It appears that triggering the keypress event using js is not the same as clicking the input field and pressing 4.

$number = $('<input />').val('123')

e = $.Event('keypress')
e.which = 52 # 4
$number.trigger(e)

assert_equal '1234', $number.val()

So you may be wondering why do the tests pass on the other fields even though their formatters are also listening to the keypress event?

Even though they're listening for the keypress event, the value of the field is modified directly. For example the data formatter does

$target.val("#{val} / ")

omarshammas avatar Sep 10 '13 20:09 omarshammas