From 5b26addc61eca95e6d09308eb5a566b131989e5a Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Mon, 10 Aug 2020 19:08:32 +0200 Subject: [PATCH] Fix broken date before/end constraint validation. --- src/pat/validation/tests.js | 152 ++++++++++++++++++++----------- src/pat/validation/validation.js | 47 +++++----- 2 files changed, 124 insertions(+), 75 deletions(-) diff --git a/src/pat/validation/tests.js b/src/pat/validation/tests.js index 8d76a39cb..55cc261d5 100644 --- a/src/pat/validation/tests.js +++ b/src/pat/validation/tests.js @@ -127,57 +127,107 @@ define(["pat-registry", "pat-validation"], function(registry, pattern) { expect($el.find('em.warning').text()).toBe("Slegs heelgetalle"); }); - // Unfortunately date validation cannot be tested using the Constraints - // API. ``ValidityState`` information is not updated after - // programmatically setting values. - // See whole discussion here: https://twitter.com/thetetet/status/1285239806205755393 - // and: https://stackoverflow.com/questions/53226031/html-input-validity-not-checked-when-value-is-changed-by-javascript - - //it("validates dates", function() { - // var $el = $( - // '
'+ - // ''+ - // '
'); - // var input = $el[0].querySelector('input'); - // input.value = '2000-02-30'; - // var pat = pattern.init($el); - // pat.validateForm(); - // debugger; - // expect($el.find('em.warning').length).toBe(1); - // expect($el.find('em.warning').text()).toBe("This value must be a valid date"); - - // $el = $( - // '
'+ - // ''+ - // '
'); - // input = $el[0].querySelector('input'); - // input.value = '2000-02-28'; - // pat = pattern.init($el); - // pat.validateForm(); - // expect($el.find('em.warning').length).toBe(0); - //}); - - //it("doesn't validate empty optional dates", function() { - // var $el = $( - // '
'+ - // ''+ - // '
'); - // var pat = pattern.init($el); - // pat.validateForm(); - // expect($el.find('em.warning').length).toBe(0); - //}); - - //it("do require-validate non-empty required dates", function() { - // var $el = $( - // '
'+ - // ''+ - // '