2012-03-08 23:00:38 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2012-04-09 18:20:55 +00:00
|
|
|
describe('ngShow / ngHide', function() {
|
2012-03-08 23:00:38 +00:00
|
|
|
var element;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
dealoc(element);
|
|
|
|
|
});
|
|
|
|
|
|
2012-04-09 18:20:55 +00:00
|
|
|
describe('ngShow', function() {
|
2012-03-08 23:00:38 +00:00
|
|
|
it('should show and hide an element', inject(function($rootScope, $compile) {
|
2012-03-09 08:00:05 +00:00
|
|
|
element = jqLite('<div ng-show="exp"></div>');
|
2012-03-08 23:00:38 +00:00
|
|
|
element = $compile(element)($rootScope);
|
|
|
|
|
$rootScope.$digest();
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(element).toBeHidden();
|
2012-03-08 23:00:38 +00:00
|
|
|
$rootScope.exp = true;
|
|
|
|
|
$rootScope.$digest();
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(element).toBeShown();
|
2012-03-08 23:00:38 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should make hidden element visible', inject(function($rootScope, $compile) {
|
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
2013-06-18 17:59:57 +00:00
|
|
|
element = jqLite('<div class="ng-hide" ng-show="exp"></div>');
|
2012-03-08 23:00:38 +00:00
|
|
|
element = $compile(element)($rootScope);
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(element).toBeHidden();
|
2012-03-08 23:00:38 +00:00
|
|
|
$rootScope.exp = true;
|
|
|
|
|
$rootScope.$digest();
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(element).toBeShown();
|
2012-03-08 23:00:38 +00:00
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
|
2012-04-09 18:20:55 +00:00
|
|
|
describe('ngHide', function() {
|
2012-03-08 23:00:38 +00:00
|
|
|
it('should hide an element', inject(function($rootScope, $compile) {
|
2012-03-09 08:00:05 +00:00
|
|
|
element = jqLite('<div ng-hide="exp"></div>');
|
2012-03-08 23:00:38 +00:00
|
|
|
element = $compile(element)($rootScope);
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(element).toBeShown();
|
2012-03-08 23:00:38 +00:00
|
|
|
$rootScope.exp = true;
|
|
|
|
|
$rootScope.$digest();
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(element).toBeHidden();
|
2012-03-08 23:00:38 +00:00
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
});
|
2013-03-20 23:24:23 +00:00
|
|
|
|
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
2013-06-18 17:59:57 +00:00
|
|
|
describe('ngShow / ngHide animations', function() {
|
2013-04-12 05:39:15 +00:00
|
|
|
var body, element, $rootElement;
|
2013-04-09 22:33:16 +00:00
|
|
|
|
|
|
|
|
function html(html) {
|
2013-04-12 05:39:15 +00:00
|
|
|
body.append($rootElement);
|
|
|
|
|
$rootElement.html(html);
|
|
|
|
|
element = $rootElement.children().eq(0);
|
2013-04-09 22:33:16 +00:00
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
|
// we need to run animation on attached elements;
|
|
|
|
|
body = jqLite(document.body);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(function(){
|
|
|
|
|
dealoc(body);
|
|
|
|
|
dealoc(element);
|
2013-04-12 05:39:15 +00:00
|
|
|
body.removeAttr('ng-animation-running');
|
2013-04-09 22:33:16 +00:00
|
|
|
});
|
2013-03-20 23:24:23 +00:00
|
|
|
|
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
2013-06-18 17:59:57 +00:00
|
|
|
beforeEach(module('mock.animate'));
|
|
|
|
|
|
|
|
|
|
beforeEach(module(function($animateProvider, $provide) {
|
|
|
|
|
return function(_$rootElement_) {
|
2013-04-12 05:39:15 +00:00
|
|
|
$rootElement = _$rootElement_;
|
2013-03-20 23:24:23 +00:00
|
|
|
};
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
describe('ngShow', function() {
|
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
2013-06-18 17:59:57 +00:00
|
|
|
it('should fire off the $animate.show and $animate.hide animation', inject(function($compile, $rootScope, $animate) {
|
|
|
|
|
var item;
|
2013-03-20 23:24:23 +00:00
|
|
|
var $scope = $rootScope.$new();
|
|
|
|
|
$scope.on = true;
|
2013-04-09 22:33:16 +00:00
|
|
|
element = $compile(html(
|
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
2013-06-18 17:59:57 +00:00
|
|
|
'<div ng-show="on">data</div>'
|
2013-04-09 22:33:16 +00:00
|
|
|
))($scope);
|
2013-03-20 23:24:23 +00:00
|
|
|
$scope.$digest();
|
|
|
|
|
|
2013-07-31 19:38:19 +00:00
|
|
|
item = $animate.flushNext('removeClass').element;
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(item.text()).toBe('data');
|
|
|
|
|
expect(item).toBeShown();
|
2013-03-20 23:24:23 +00:00
|
|
|
|
|
|
|
|
$scope.on = false;
|
|
|
|
|
$scope.$digest();
|
2013-04-09 22:33:16 +00:00
|
|
|
|
2013-07-31 19:38:19 +00:00
|
|
|
item = $animate.flushNext('addClass').element;
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(item.text()).toBe('data');
|
|
|
|
|
expect(item).toBeHidden();
|
|
|
|
|
}));
|
2013-03-20 23:24:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('ngHide', function() {
|
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
2013-06-18 17:59:57 +00:00
|
|
|
it('should fire off the $animate.show and $animate.hide animation', inject(function($compile, $rootScope, $animate) {
|
|
|
|
|
var item;
|
2013-03-20 23:24:23 +00:00
|
|
|
var $scope = $rootScope.$new();
|
|
|
|
|
$scope.off = true;
|
2013-04-09 22:33:16 +00:00
|
|
|
element = $compile(html(
|
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
2013-06-18 17:59:57 +00:00
|
|
|
'<div ng-hide="off">datum</div>'
|
2013-04-09 22:33:16 +00:00
|
|
|
))($scope);
|
2013-03-20 23:24:23 +00:00
|
|
|
$scope.$digest();
|
|
|
|
|
|
2013-07-31 19:38:19 +00:00
|
|
|
item = $animate.flushNext('addClass').element;
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(item.text()).toBe('datum');
|
|
|
|
|
expect(item).toBeHidden();
|
2013-03-20 23:24:23 +00:00
|
|
|
|
|
|
|
|
$scope.off = false;
|
|
|
|
|
$scope.$digest();
|
|
|
|
|
|
2013-07-31 19:38:19 +00:00
|
|
|
item = $animate.flushNext('removeClass').element;
|
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
2013-06-18 17:59:57 +00:00
|
|
|
expect(item.text()).toBe('datum');
|
|
|
|
|
expect(item).toBeShown();
|
2013-03-20 23:24:23 +00:00
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
});
|