OLD | NEW |
(Empty) | |
| 1 library ng_animate_spec; |
| 2 |
| 3 import '../_specs.dart'; |
| 4 |
| 5 main() { |
| 6 module((Module module) { |
| 7 module |
| 8 ..type(AnimationOptimizer) |
| 9 ..type(NgAnimate) |
| 10 ..type(NgAnimateChildren); |
| 11 }); |
| 12 describe('ng-animate', () { |
| 13 TestBed _; |
| 14 AnimationOptimizer optimizer; |
| 15 beforeEach(() { |
| 16 setUpInjector(); |
| 17 module((Module module) { |
| 18 module |
| 19 ..type(AnimationOptimizer) |
| 20 ..type(NgAnimate) |
| 21 ..type(NgAnimateChildren); |
| 22 }); |
| 23 inject((TestBed tb, AnimationOptimizer opt) { |
| 24 _ = tb; |
| 25 optimizer = opt; |
| 26 }); |
| 27 }); |
| 28 |
| 29 afterEach(() { |
| 30 tearDownInjector(); |
| 31 }); |
| 32 |
| 33 it('should control animations on elements', () { |
| 34 _.compile('<div ng-animate="never"><div></div></div>'); |
| 35 _.rootScope.apply(); |
| 36 |
| 37 expect(optimizer.shouldAnimate(_.rootElement)).toBeFalsy(); |
| 38 expect(optimizer.shouldAnimate(_.rootElement.children[0])).toBeTruthy(); |
| 39 |
| 40 _.compile('<div ng-animate="always">' |
| 41 + '<div ng-animate="never"></div></div>'); |
| 42 _.rootScope.apply(); |
| 43 expect(optimizer.shouldAnimate(_.rootElement)).toBeTruthy(); |
| 44 expect(optimizer.shouldAnimate(_.rootElement.children[0])).toBeFalsy(); |
| 45 |
| 46 |
| 47 _.compile('<div ng-animate="never">' |
| 48 + '<div ng-animate="always"></div></div>'); |
| 49 _.rootScope.apply(); |
| 50 expect(optimizer.shouldAnimate(_.rootElement)).toBeFalsy(); |
| 51 expect(optimizer.shouldAnimate(_.rootElement.children[0])).toBeTruthy(); |
| 52 }); |
| 53 |
| 54 it('should control animations and override running animations', () { |
| 55 var animation = new NoOpAnimation(); |
| 56 _.compile('<div><div ng-animate="always"></div></div>'); |
| 57 _.rootScope.apply(); |
| 58 optimizer.track(animation, _.rootElement); |
| 59 expect(optimizer.shouldAnimate(_.rootElement)).toBeTruthy(); |
| 60 expect(optimizer.shouldAnimate(_.rootElement.children[0])).toBeTruthy(); |
| 61 |
| 62 animation = new NoOpAnimation(); |
| 63 _.compile('<div><div ng-animate="auto"></div></div>'); |
| 64 _.rootScope.apply(); |
| 65 optimizer.track(animation, _.rootElement); |
| 66 expect(optimizer.shouldAnimate(_.rootElement)).toBeTruthy(); |
| 67 expect(optimizer.shouldAnimate(_.rootElement.children[0])).toBeFalsy(); |
| 68 }); |
| 69 |
| 70 describe("children", () { |
| 71 it('should prevent child animations', () { |
| 72 _.compile('<div ng-animate-children="never"><div></div></div>'); |
| 73 |
| 74 expect(optimizer.shouldAnimate(_.rootElement)).toBeTruthy(); |
| 75 expect(optimizer.shouldAnimate(_.rootElement.children[0])).toBeFalsy(); |
| 76 }); |
| 77 |
| 78 it('should forcibly allow child animations', () { |
| 79 _.compile('<div ng-animate-children="always"><div></div></div>'); |
| 80 optimizer.track(new NoOpAnimation(), _.rootElement); |
| 81 |
| 82 expect(optimizer.shouldAnimate(_.rootElement)).toBeTruthy(); |
| 83 expect(optimizer.shouldAnimate(_.rootElement.children[0])).toBeTruthy(); |
| 84 }); |
| 85 }); |
| 86 }); |
| 87 } |
OLD | NEW |