diff options
| author | Matias Niemelä | 2013-06-18 13:59:57 -0400 | 
|---|---|---|
| committer | Misko Hevery | 2013-07-26 23:49:54 -0700 | 
| commit | 81923f1e41560327f7de6e8fddfda0d2612658f3 (patch) | |
| tree | bbf8151bddf4d026f8f5fa3196b84a45ecd9c858 /test/ng/directive/ngIncludeSpec.js | |
| parent | 11521a4cde689c2bd6aaa227b1f45cb3fb53725b (diff) | |
| download | angular.js-81923f1e41560327f7de6e8fddfda0d2612658f3.tar.bz2 | |
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
  - $animate.enter(element, parent, after, done);
  - $animate.leave(element, done);
  - $animate.move(element, parent, after, done);
  - $animate.addClass(element, className, done);
  - $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
Diffstat (limited to 'test/ng/directive/ngIncludeSpec.js')
| -rw-r--r-- | test/ng/directive/ngIncludeSpec.js | 98 | 
1 files changed, 18 insertions, 80 deletions
| diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 6cb78755..286ee5af 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -341,8 +341,7 @@ describe('ngInclude', function() {    });  }); -describe('ngInclude ngAnimate', function() { -  var vendorPrefix, window; +describe('ngInclude animations', function() {    var body, element, $rootElement;    function html(html) { @@ -351,11 +350,6 @@ describe('ngInclude ngAnimate', function() {      return element;    } -  function applyCSS(element, cssProp, cssValue) { -    element.css(cssProp, cssValue); -    element.css(vendorPrefix + cssProp, cssValue); -  } -    beforeEach(module(function() {      // we need to run animation on attached elements;      return function(_$rootElement_) { @@ -370,107 +364,51 @@ describe('ngInclude ngAnimate', function() {      dealoc(element);    }); -  beforeEach(module(function($animationProvider, $provide) { -    $provide.value('$window', window = angular.mock.createMockWindow()); -    return function($sniffer, $animator) { -      vendorPrefix = '-' + $sniffer.vendorPrefix + '-'; -      $animator.enabled(true); -    }; -  })); +  beforeEach(module('mock.animate'));    afterEach(function(){      dealoc(element);    }); -  it('should fire off the enter animation + add and remove the css classes', -    inject(function($compile, $rootScope, $templateCache, $sniffer) { +  it('should fire off the enter animation', +    inject(function($compile, $rootScope, $templateCache, $animate) { +      var item;        $templateCache.put('enter', [200, '<div>data</div>', {}]);        $rootScope.tpl = 'enter';        element = $compile(html(          '<div ' + -          'ng-include="tpl" ' + -          'ng-animate="{enter: \'custom-enter\'}">' + +          'ng-include="tpl">' +          '</div>'        ))($rootScope);        $rootScope.$digest(); -      //if we add the custom css stuff here then it will get picked up before the animation takes place -      var child = jqLite(element.children()[0]); -      applyCSS(child, 'transition', '1s linear all'); - -      if ($sniffer.transitions) { -        expect(child.attr('class')).toContain('custom-enter'); -        window.setTimeout.expect(1).process(); - -        expect(child.attr('class')).toContain('custom-enter-active'); -        window.setTimeout.expect(1000).process(); -      } else { -       expect(window.setTimeout.queue).toEqual([]); -      } - -      expect(child.attr('class')).not.toContain('custom-enter'); -      expect(child.attr('class')).not.toContain('custom-enter-active'); +      item = $animate.process('leave').element; +      item = $animate.process('enter').element; +      expect(item.text()).toBe('data');    })); -  it('should fire off the leave animation + add and remove the css classes', -    inject(function($compile, $rootScope, $templateCache, $sniffer) { +  it('should fire off the leave animation', +    inject(function($compile, $rootScope, $templateCache, $animate) { +      var item;        $templateCache.put('enter', [200, '<div>data</div>', {}]);        $rootScope.tpl = 'enter';        element = $compile(html(          '<div ' + -          'ng-include="tpl" ' + -          'ng-animate="{leave: \'custom-leave\'}">' + +          'ng-include="tpl">' +          '</div>'        ))($rootScope);        $rootScope.$digest(); -      //if we add the custom css stuff here then it will get picked up before the animation takes place -      var child = jqLite(element.children()[0]); -      applyCSS(child, 'transition', '1s linear all'); +      item = $animate.process('leave').element; +      item = $animate.process('enter').element; +      expect(item.text()).toBe('data');        $rootScope.tpl = '';        $rootScope.$digest(); -      if ($sniffer.transitions) { -        expect(child.attr('class')).toContain('custom-leave'); -        window.setTimeout.expect(1).process(); - -        expect(child.attr('class')).toContain('custom-leave-active'); -        window.setTimeout.expect(1000).process(); -      } else { -       expect(window.setTimeout.queue).toEqual([]); -      } - -      expect(child.attr('class')).not.toContain('custom-leave'); -      expect(child.attr('class')).not.toContain('custom-leave-active'); -  })); - -  it('should catch and use the correct duration for animation', -    inject(function($compile, $rootScope, $templateCache, $sniffer) { -      $templateCache.put('enter', [200, '<div>data</div>', {}]); -      $rootScope.tpl = 'enter'; -      element = $compile(html( -        '<div ' + -          'ng-include="tpl" ' + -          'ng-animate="{enter: \'custom-enter\'}">' + -        '</div>' -      ))($rootScope); -      $rootScope.$digest(); - -      //if we add the custom css stuff here then it will get picked up before the animation takes place -      var child = jqLite(element.children()[0]); -      applyCSS(child, 'transition', '0.5s linear all'); - -      $rootScope.tpl = 'enter'; -      $rootScope.$digest(); - -      if ($sniffer.transitions) { -        window.setTimeout.expect(1).process(); -        window.setTimeout.expect(500).process(); -      } else { -        expect(window.setTimeout.queue).toEqual([]); -      } +      item = $animate.process('leave').element; +      expect(item.text()).toBe('data');    }));  }); | 
