Fix old tests to reflect new validation and add new test to verify that new validatio...
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 2 Oct 2015 22:25:52 +0000 (22:25 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 16 Oct 2015 23:05:29 +0000 (23:05 +0000)
Js Hint fixes

Js Hint fixes

Js Hint fixes

Fix typo found by Dave

ang/crmMailing/RadioDate.js
tests/karma/unit/crmMailingRadioDateSpec.js

index f509d62f1326f133bb04d3556e4d022f3354edf3..153e9562b9307689c698d9d5c295e52f2d2a7e17 100644 (file)
@@ -64,7 +64,7 @@
               ngModel.$setValidity('dateTimeInThePast', !($(this).val().length && submittedDate < currentDate));
               if ($(this).val().length && submittedDate < currentDate) {
                 crmUiAlert({
-                  text: ts('The Scheulded date and time is in the past'),
+                  text: ts('The scheduled date and time is in the past'),
                   title: ts('Error')
                 });
               }
index a90a820f6bb27d22780afef38aa5e9a68524511a..4ffee0cc6d7edcd9a59370264ec2142e7d48115c 100644 (file)
@@ -80,11 +80,31 @@ describe('crmMailingRadioDate', function() {
 
       model.the_date = '2014-01-02 02:03:00';
       $rootScope.$digest();
-      expect($rootScope.myForm.$valid).toBe(true);
+      expect($rootScope.myForm.$valid).toBe(false);
       expect(element.find('.radio-now').prop('checked')).toBe(false);
       expect(element.find('.radio-at').prop('checked')).toBe(true);
       expect(element.find('.crm-form-date').datepicker('getDate').toDateString()).toEqual('Thu Jan 02 2014');
       expect(element.find('.crm-form-time').timeEntry('getTime').getMinutes()).toBe(3);
+
+      var now = new Date();
+      now.setDate(now.getDate() + 1);
+      var month = '' + (now.getMonth() + 1);
+      var day = '' + now.getDate();
+      var year = now.getFullYear();
+      var hours = '' + now.getHours();
+      var minutes = '' + now.getMinutes();
+      if (month.length < 2) month = '0' + month;
+      if (day.length < 2) day = '0' + day;
+      var datenow = [year, month, day].join('-');
+      var time = [hours, minutes, "00"].join(':');
+      var currentDate = datenow + ' ' + time;
+      var n = now.toDateString();
+      model.the_date = currentDate;
+      $rootScope.$digest();
+      expect($rootScope.myForm.$valid).toBe(true);
+      expect(element.find('.radio-now').prop('checked')).toBe(false);
+      expect(element.find('.radio-at').prop('checked')).toBe(true);
+      expect(element.find('.crm-form-date').datepicker('getDate').toDateString()).toEqual(n);
     });
 
     it('should update the model after changing the date and time', function() {
@@ -107,7 +127,7 @@ describe('crmMailingRadioDate', function() {
       element.find('.crm-form-time').timeEntry('setTime', '04:05').trigger('change');
       $rootScope.$digest();
       expect(model.the_date).toBe('2014-01-03 04:05:00');
-      expect($rootScope.myForm.$valid).toBe(true);
+      expect($rootScope.myForm.$valid).toBe(false);
       expect(element.find('.radio-now').prop('checked')).toBe(false);
       expect(element.find('.radio-at').prop('checked')).toBe(true);