describe('uiDate directive', function () {
'use strict';
var selectDate;
var scope;
var compile;
var dateFacade, baseValidator;
var selectDate;
selectDate = function (element, date) {
element.datepicker('setDate', date);
$.datepicker._selectDate(element);
};
beforeEach(module('ui.directives'));
beforeEach(module('FMApp'));
beforeEach(inject(function($rootScope, $compile, _baseValidator_, _dateFacade_) {
scope = $rootScope.$new();
compile = $compile;
dateFacade = _dateFacade_;
baseValidator = _baseValidator_;
}));
describe('setting dates:', function () {
it('should have a date picker attached', function () {
var element;
element = compile('<input ui-date/>')(scope);
expect(element.datepicker()).toBeDefined();
});
it('should put the date in the model', function () {
var aDate, element;
aDate = new Date(2016, 0, 1);
element = compile('<input ui-date ng-model="x" />')(scope);
scope.$apply();
selectDate(element, aDate);
expect(scope.x).toEqual('01/01/2016');
element.remove();
});
it('should format dates in the mm/dd format', function () {
var element, aDate;
aDate = new Date(2016, 2, 1);
element = compile('<input ui-date="{dateFormat:\'mm/dd\'}" ng-model="x" />')(scope);
scope.$apply();
selectDate(element, aDate);
expect(scope.x).toEqual('03/01');
element.remove();
});
it('should be able to set a date range', function() {
var element, startDate, endDate;
startDate = new Date(2016, 3, 1);
endDate = new Date(2016,3,3);
element = compile('<input ui-date="{dateFormat:\'mm/dd\', isRange: true}" ng-model="x" />')(scope);
scope.$apply();
element.val(startDate);
element.focus();
//$('.ui-datepicker-calendar').find('td').not('.ui-datepicker-unselectable').first().trigger('click');
scope.$apply();
console.log('scope.x', scope.x);
selectDate(element,...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.