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() {
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);