mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 07:14:44 +00:00
test($animator): ensure invalid $sniffer.transitions and $sniffer.animations flags are caught in animation spec code
This commit is contained in:
parent
3a49b7eec4
commit
24ed61cf5c
1 changed files with 44 additions and 12 deletions
|
|
@ -386,6 +386,9 @@ describe("$animator", function() {
|
||||||
window.setTimeout.expect(1).process();
|
window.setTimeout.expect(1).process();
|
||||||
window.setTimeout.expect(4000).process();
|
window.setTimeout.expect(4000).process();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
expect(element[0].style.display).toBe('');
|
expect(element[0].style.display).toBe('');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -408,6 +411,9 @@ describe("$animator", function() {
|
||||||
window.setTimeout.expect(1).process();
|
window.setTimeout.expect(1).process();
|
||||||
window.setTimeout.expect(6000).process();
|
window.setTimeout.expect(6000).process();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
expect(element[0].style.display).toBe('');
|
expect(element[0].style.display).toBe('');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -430,6 +436,9 @@ describe("$animator", function() {
|
||||||
window.setTimeout.expect(1).process();
|
window.setTimeout.expect(1).process();
|
||||||
window.setTimeout.expect(2000).process();
|
window.setTimeout.expect(2000).process();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
expect(element[0].style.display).toBe('');
|
expect(element[0].style.display).toBe('');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -454,6 +463,9 @@ describe("$animator", function() {
|
||||||
window.setTimeout.expect(1).process();
|
window.setTimeout.expect(1).process();
|
||||||
window.setTimeout.expect(20000).process();
|
window.setTimeout.expect(20000).process();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
expect(element[0].style.display).toBe('');
|
expect(element[0].style.display).toBe('');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -475,8 +487,6 @@ describe("$animator", function() {
|
||||||
|
|
||||||
it("should finish the previous animation when a new animation is started",
|
it("should finish the previous animation when a new animation is started",
|
||||||
inject(function($animator, $rootScope, $compile, $sniffer) {
|
inject(function($animator, $rootScope, $compile, $sniffer) {
|
||||||
if(!$sniffer.animations) return;
|
|
||||||
|
|
||||||
var style = 'animation: some_animation 2s linear 0s 1 alternate;' +
|
var style = 'animation: some_animation 2s linear 0s 1 alternate;' +
|
||||||
vendorPrefix + 'animation: some_animation 2s linear 0s 1 alternate;'
|
vendorPrefix + 'animation: some_animation 2s linear 0s 1 alternate;'
|
||||||
|
|
||||||
|
|
@ -486,11 +496,19 @@ describe("$animator", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
animator.show(element);
|
animator.show(element);
|
||||||
window.setTimeout.expect(1).process();
|
if($sniffer.animations) {
|
||||||
expect(element.hasClass('show')).toBe(true);
|
window.setTimeout.expect(1).process();
|
||||||
expect(element.hasClass('show-active')).toBe(true);
|
expect(element.hasClass('show')).toBe(true);
|
||||||
|
expect(element.hasClass('show-active')).toBe(true);
|
||||||
|
}
|
||||||
|
else { //animation is skipped
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
animator.hide(element);
|
animator.hide(element);
|
||||||
|
if(!$sniffer.animations) {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
expect(element.hasClass('show')).toBe(false);
|
expect(element.hasClass('show')).toBe(false);
|
||||||
expect(element.hasClass('show-active')).toBe(false);
|
expect(element.hasClass('show-active')).toBe(false);
|
||||||
}));
|
}));
|
||||||
|
|
@ -520,6 +538,9 @@ describe("$animator", function() {
|
||||||
window.setTimeout.expect(1).process();
|
window.setTimeout.expect(1).process();
|
||||||
window.setTimeout.expect(1000).process();
|
window.setTimeout.expect(1000).process();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
expect(element[0].style.display).toBe('');
|
expect(element[0].style.display).toBe('');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -536,6 +557,9 @@ describe("$animator", function() {
|
||||||
window.setTimeout.expect(1).process();
|
window.setTimeout.expect(1).process();
|
||||||
window.setTimeout.expect(2000).process();
|
window.setTimeout.expect(2000).process();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
expect(element[0].style.display).toBe('');
|
expect(element[0].style.display).toBe('');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -565,17 +589,17 @@ describe("$animator", function() {
|
||||||
if ($sniffer.transitions) {
|
if ($sniffer.transitions) {
|
||||||
window.setTimeout.expect(1).process();
|
window.setTimeout.expect(1).process();
|
||||||
window.setTimeout.expect(3000).process();
|
window.setTimeout.expect(3000).process();
|
||||||
return;
|
}
|
||||||
|
else {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
}
|
}
|
||||||
expect(element[0].style.display).toBe('');
|
expect(element[0].style.display).toBe('');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("should finish the previous transition when a new animation is started",
|
it("should finish the previous transition when a new animation is started",
|
||||||
inject(function($animator, $rootScope, $compile, $sniffer) {
|
inject(function($animator, $rootScope, $compile, $sniffer) {
|
||||||
if(!$sniffer.animations) return;
|
|
||||||
|
|
||||||
var style = 'transition: 1s linear all;' +
|
var style = 'transition: 1s linear all;' +
|
||||||
vendorPrefix + 'animation: 1s linear all;'
|
vendorPrefix + 'transition: 1s linear all;'
|
||||||
|
|
||||||
element = $compile(html('<div style="' + style + '">1</div>'))($rootScope);
|
element = $compile(html('<div style="' + style + '">1</div>'))($rootScope);
|
||||||
var animator = $animator($rootScope, {
|
var animator = $animator($rootScope, {
|
||||||
|
|
@ -583,11 +607,19 @@ describe("$animator", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
animator.show(element);
|
animator.show(element);
|
||||||
window.setTimeout.expect(1).process();
|
if($sniffer.transitions) {
|
||||||
expect(element.hasClass('show')).toBe(true);
|
window.setTimeout.expect(1).process();
|
||||||
expect(element.hasClass('show-active')).toBe(true);
|
expect(element.hasClass('show')).toBe(true);
|
||||||
|
expect(element.hasClass('show-active')).toBe(true);
|
||||||
|
}
|
||||||
|
else { //animation is skipped
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
animator.hide(element);
|
animator.hide(element);
|
||||||
|
if(!$sniffer.transitions) {
|
||||||
|
expect(window.setTimeout.queue.length).toBe(0);
|
||||||
|
}
|
||||||
expect(element.hasClass('show')).toBe(false);
|
expect(element.hasClass('show')).toBe(false);
|
||||||
expect(element.hasClass('show-active')).toBe(false);
|
expect(element.hasClass('show-active')).toBe(false);
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue