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/animateSpec.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/animateSpec.js')
| -rw-r--r-- | test/ng/animateSpec.js | 53 | 
1 files changed, 53 insertions, 0 deletions
| diff --git a/test/ng/animateSpec.js b/test/ng/animateSpec.js new file mode 100644 index 00000000..7f440bb5 --- /dev/null +++ b/test/ng/animateSpec.js @@ -0,0 +1,53 @@ +describe("$animate", function() { + +  describe("without animation", function() { +    beforeEach(inject(function($compile, _$rootElement_, $rootScope) { +      element = $compile('<div></div>')($rootScope); +      $rootElement = _$rootElement_; +    })); + +    it("should add element at the start of enter animation", inject(function($animate, $compile, $rootScope) { +      var child = $compile('<div></div>')($rootScope); +      expect(element.contents().length).toBe(0); +      $animate.enter(child, element); +      expect(element.contents().length).toBe(1); +    })); + +    it("should remove the element at the end of leave animation", inject(function($animate, $compile, $rootScope) { +      var child = $compile('<div></div>')($rootScope); +      element.append(child); +      expect(element.contents().length).toBe(1); +      $animate.leave(child); +      expect(element.contents().length).toBe(0); +    })); + +    it("should reorder the move animation", inject(function($animate, $compile, $rootScope) { +      var child1 = $compile('<div>1</div>')($rootScope); +      var child2 = $compile('<div>2</div>')($rootScope); +      element.append(child1); +      element.append(child2); +      expect(element.text()).toBe('12'); +      $animate.move(child1, element, child2); +      expect(element.text()).toBe('21'); +    })); + +    it("should animate the show animation event", inject(function($animate) { +      element.addClass('ng-hide'); +      $animate.show(element); +      expect(element).toBeShown(); +    })); + +    it("should animate the hide animation event", inject(function($animate) { +      expect(element).toBeShown(); +      $animate.hide(element); +      expect(element).toBeHidden(); +    })); + +    it("should still perform DOM operations even if animations are disabled", inject(function($animate) { +      $animate.enabled(false); +      expect(element).toBeShown(); +      $animate.hide(element); +      expect(element).toBeHidden(); +    })); +  }); +}); | 
