describe('ddTimepicker', function () {
    var $scope,
        $sniffer,
        $document,
        $timeout,
        $compile,
        element;

    beforeEach(function () {
        module('dd.ui.dd-timepicker');

        inject(function ($rootScope, _$compile_, _$timeout_, _$sniffer_, _$document_) {
            $scope = $rootScope.$new();
            $sniffer = _$sniffer_;
            $timeout = _$timeout_;
            $document = _$document_;
            $compile = _$compile_;
        });
    });

    describe('Change model value', function () {

        it('apply parsed user input for model', function () {
            element = buildDirective($scope);

            changeInputValue(element, '8a');

            expect($scope.time).toEqual('08:00');
        });

        it('clear model if invalid time', function () {
            element = buildDirective($scope);

            changeInputValue(element, 'kepalas');

            expect($scope.time).toBeNull();
        });

        it('do not change model if not blured', function () {

            $scope.time = '10:15';
            element = buildDirective($scope);

            changeInputValue(element, '8p');

            expect($scope.time).toBe($scope.time);
        });

        it('return model as Date if is-date-type="true"', function () {

            $scope.time = '10:15';
            element = $compile(angular.element('<input id="time1" is-date-type="true" class="form-control" dd-timepicker type="text" ng-model="time" />'))($scope);
            $scope.$digest();

            changeInputValue(element, '10:20');

            expect($scope.time instanceof Date).toBe(true);
            expect($scope.time.getHours()).toBe(10);
            expect($scope.time.getMinutes()).toBe(20);
        });
    });

    describe('Keyboard', function () {
        it('arrow up increase time', function () {

            $scope.time = '10:15';
            element = buildDirective($scope);

            triggerKeypress(element, 38);

            expect($scope.time).toBe('10:16');
        });

        it('arrow down decreaes time', function () {

            $scope.time = '10:15';
            element = buildDirective($scope);

            triggerKeypress(element, 40);

            expect($scope.time).toBe('10:14');
        });

        it('on enter should create time from current datetime if input is empty', function () {

            $scope.time = '';
            element = buildDirective($scope);

            triggerKeypress(element, 13);

            expect($scope.time).toBeDefined();
        });

        it('on enter not create time if input not empty', function () {

            $scope.time = '10:10';
            element = buildDirective($scope);

            triggerKeypress(element, 13);

            expect($scope.time).toBe('10:10');
        });
    });

    function buildDirective(scope) {
        var element = $compile(angular.element('<input id="time1" class="form-control" dd-timepicker type="text" ng-model="time" />'))($scope);
        $scope.$digest();
        return element;
    }

    function changeInputValue(el, value) {
        el.val(value);
        el.trigger($sniffer.hasEvent('input') ? 'input' : 'change');
        $scope.$digest();
        element.trigger('blur');
    }

    function triggerKeypress(el, keycode) {
        var e = angular.element.Event("keypress");
        e.which = keycode;
        el.trigger(e);
    }
});
@@ -18,33 +18,32 @@
 icker', function
- 
 () %7B%0A    var $sc
@@ -153,33 +153,32 @@
 oreEach(function
- 
 () %7B%0A        mod
@@ -229,17 +229,16 @@
 function
- 
 ($rootSc
@@ -531,33 +531,32 @@
 value', function
- 
 () %7B%0A%0A        it
@@ -593,33 +593,32 @@
 model', function
- 
 () %7B%0A           
@@ -804,33 +804,32 @@
  time', function
- 
 () %7B%0A           
@@ -1020,33 +1020,32 @@
 lured', function
- 
 () %7B%0A%0A          
@@ -1284,33 +1284,32 @@
 true%22', function
- 
 () %7B%0A%0A          
@@ -1788,16 +1788,25 @@
 Keyboard
+ arrow up
 ', funct
@@ -1804,25 +1804,24 @@
 p', function
- 
 () %7B%0A       
@@ -1829,17 +1829,8 @@
 it('
-arrow up 
 incr
@@ -1834,24 +1834,38 @@
 ncrease time
+ by one minute
 ', function 
@@ -1855,39 +1855,37 @@
 inute', function
- 
 () %7B%0A
-%0A
             $sco
@@ -2056,44 +2056,104 @@
 %7D);%0A
-%0A
     
-    it('arrow down decreaes tim
+%7D);%0A%0A    describe('Keyboard arrow down', function() %7B%0A        it('decreaes time by one minut
 e', 
@@ -2152,39 +2152,37 @@
 inute', function
- 
 () %7B%0A
-%0A
             $sco
@@ -2353,37 +2353,73 @@
 %7D);%0A
-%0A
     
-    it('on enter should 
+%7D);%0A%0A    describe('Keyboard enter', function() %7B%0A        it('
 crea
@@ -2468,33 +2468,32 @@
 empty', function
- 
 () %7B%0A%0A          
@@ -2678,19 +2678,11 @@
 it('
+d
 on
- enter no
 t cr
@@ -2720,17 +2720,16 @@
 function
- 
 () %7B%0A%0A  

rename tests names