JSFiddle - React, Tailwind, and code Playground

by Steven Senkus

JavaScript

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,...