У меня проблема миграции с angular -animate.js с версии 1.2 до 1.3. Вот моя анимация
'use strict';
angular.module('cookbook', ['ngAnimate'])
.animation('.slide-down', function() {
var NG_HIDE_CLASS = 'ng-hide';
return {
beforeAddClass: function(element, className, done) {
alert('before add');
if(className === NG_HIDE_CLASS) {
element.slideUp(done);
}
},
removeClass: function(element, className, done) {
if(className === NG_HIDE_CLASS) {
element.hide().slideDown(done);
}
}
};
});
Синхронный тест
'use strict';
describe('A Brief Look At Testing Animations(changed) - ', function() {
var scope;
var element;
var $animate;
var $rootElement;
beforeEach(module('cookbook', 'ngAnimateMock'));
describe('Synchronous testing of animations', function() {
var animatedShow = false;
var animatedHide = false;
beforeEach(module(function($animateProvider) {
$animateProvider.register('.slide-down', function() {
return {
beforeAddClass: function(element, className, done) {
debugger;alert(1);
animatedHide = true;
done();
},
removeClass: function(element, className, done) {
animatedShow = true;
done();
}
};
});
}));
beforeEach(inject(function($injector) {
scope = $injector.get('$rootScope').$new();
$rootElement = $injector.get('$rootElement');
}));
beforeEach(inject(function($compile) {
element = angular.element('<div class="slide-down" ng-show="hint"></div>');
$compile(element)(scope);
scope.$digest();
$rootElement.append(element);
}));
it('should animate to show', function() {
scope.hint = true;
scope.$digest();
expect(animatedShow).toBeTruthy();
});
it('should animate to hide', function() {
scope.hint = true;
scope.$digest();
scope.hint = false;
scope.$digest();
expect(animatedHide).toBeTruthy();
});
});
});
и spec runner
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Angular Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="../../lib/jasmine-2.0.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="../../lib/jasmine-2.0.0/jasmine.css">
<script type="text/javascript" src="../../lib/jasmine-2.0.0/jasmine.js"></script>
<script type="text/javascript" src="../../lib/jasmine-2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="../../lib/jasmine-2.0.0/boot.js"></script>
<script type="text/javascript" src="../../lib/angular-1.2.28_/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../lib/angular-1.3.15/angular.js"></script>
<script type="text/javascript" src="../../lib/angular-1.3.15/angular-route.js"></script>
<script type="text/javascript" src="../../lib/angular-1.3.15/angular-ui-router.js"></script>
<script type="text/javascript" src="../../lib/angular-1.3.15/angular-mocks.js"></script>
<script type="text/javascript" src="../../lib/angular-1.2.28_/angular-animate.js"></script>
<!--DOESN'T WORK WITH 1.3.15-->
<!--<script type="text/javascript" src="../../lib/angular-1.3.15/angular-animate.js"></script>-->
<!-- include source files here... -->
<script type="text/javascript" src="../src/cookbook.js"></script>
<link rel="stylesheet" href="../src/styles.css">
<!-- include spec files here... -->
<script type="text/javascript" src="cookbookSpec.js"></script>
</head>
<body>
</body>
</html>
Когда я использую angular -animate 1.2.28, все тесты передаются, но после переключения на 1.3.15 тесты не выполняются. Теперь я пытаюсь исследовать разницу между двумя версиями angular -animate. Может быть, у кого-то была эта проблема. Спасибо всем за ваши ответы.