diff options
| author | Misko Hevery | 2013-03-20 16:24:23 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2013-04-02 14:05:06 -0700 | 
| commit | 0b6f1ce5f89f47f9302ff1e8cd8f4b92f837c413 (patch) | |
| tree | 8cbc0c86024dd4f97d0aa54e0c9b7df9b0d56b86 /test/ng/directive/ngShowHideSpec.js | |
| parent | 4bfb66ce0be46d3a0e9da2f80f3e1d0c2b559828 (diff) | |
| download | angular.js-0b6f1ce5f89f47f9302ff1e8cd8f4b92f837c413.tar.bz2 | |
feat(ngAnimate): add support for animation
Diffstat (limited to 'test/ng/directive/ngShowHideSpec.js')
| -rw-r--r-- | test/ng/directive/ngShowHideSpec.js | 101 | 
1 files changed, 101 insertions, 0 deletions
| diff --git a/test/ng/directive/ngShowHideSpec.js b/test/ng/directive/ngShowHideSpec.js index ee251dbf..d1d314e7 100644 --- a/test/ng/directive/ngShowHideSpec.js +++ b/test/ng/directive/ngShowHideSpec.js @@ -41,3 +41,104 @@ describe('ngShow / ngHide', function() {      }));    });  }); + +describe('ngShow / ngHide - ngAnimate', function() { +  var element, window; +  var vendorPrefix; + +  beforeEach(module(function($animationProvider, $provide) { +    $provide.value('$window', window = angular.mock.createMockWindow()); +    return function($sniffer) { +      vendorPrefix = '-' + $sniffer.vendorPrefix + '-'; +    }; +  })); + +  afterEach(function() { +    dealoc(element); +  }); + +  describe('ngShow', function() { +    it('should fire off the animator.show and animator.hide animation', inject(function($compile, $rootScope, $sniffer) { +      var $scope = $rootScope.$new(); +      $scope.on = true; +      element = $compile( +        '<div ' + +          'style="'+vendorPrefix+'transition: 1s linear all"' + +          'ng-show="on" ' + +          'ng-animate="{show: \'custom-show\', hide: \'custom-hide\'}">' + +        '</div>' +      )($scope); +      $scope.$digest(); + +      if ($sniffer.supportsTransitions) { +        expect(element.attr('class')).toContain('custom-show-setup'); +        window.setTimeout.expect(1).process(); + +        expect(element.attr('class')).toContain('custom-show-start'); +        window.setTimeout.expect(1000).process(); +      } else { +        expect(window.setTimeout.queue).toEqual([]); +      } + +      expect(element.attr('class')).not.toContain('custom-show-start'); +      expect(element.attr('class')).not.toContain('custom-show-setup'); + +      $scope.on = false; +      $scope.$digest(); +      if ($sniffer.supportsTransitions) { +        expect(element.attr('class')).toContain('custom-hide-setup'); +        window.setTimeout.expect(1).process(); +        expect(element.attr('class')).toContain('custom-hide-start'); +        window.setTimeout.expect(1000).process(); +      } else { +        expect(window.setTimeout.queue).toEqual([]); +      } + +      expect(element.attr('class')).not.toContain('custom-hide-start'); +      expect(element.attr('class')).not.toContain('custom-hide-setup'); +    })); +  }); + +  describe('ngHide', function() { +    it('should fire off the animator.show and animator.hide animation', inject(function($compile, $rootScope, $sniffer) { +      var $scope = $rootScope.$new(); +      $scope.off = true; +      element = $compile( +          '<div ' + +              'style="'+vendorPrefix+'transition: 1s linear all"' + +              'ng-hide="off" ' + +              'ng-animate="{show: \'custom-show\', hide: \'custom-hide\'}">' + +              '</div>' +      )($scope); +      $scope.$digest(); + +      if ($sniffer.supportsTransitions) { +        expect(element.attr('class')).toContain('custom-hide-setup'); +        window.setTimeout.expect(1).process(); + +        expect(element.attr('class')).toContain('custom-hide-start'); +        window.setTimeout.expect(1000).process(); +      } else { +        expect(window.setTimeout.queue).toEqual([]); +      } + +      expect(element.attr('class')).not.toContain('custom-hide-start'); +      expect(element.attr('class')).not.toContain('custom-hide-setup'); + +      $scope.off = false; +      $scope.$digest(); + +      if ($sniffer.supportsTransitions) { +        expect(element.attr('class')).toContain('custom-show-setup'); +        window.setTimeout.expect(1).process(); +        expect(element.attr('class')).toContain('custom-show-start'); +        window.setTimeout.expect(1000).process(); +      } else { +        expect(window.setTimeout.queue).toEqual([]); +      } + +      expect(element.attr('class')).not.toContain('custom-show-start'); +      expect(element.attr('class')).not.toContain('custom-show-setup'); +    })); +  }); +}); | 
