test(animations): fix Node.js detection in animation tests (#24139)

PR Close #24139
This commit is contained in:
Vikram Subramanian 2018-05-25 13:52:58 -07:00 committed by Matias Niemelä
parent 1eafd04eb3
commit 3fd3c2ac4c
14 changed files with 14 additions and 18 deletions

View File

@ -20,7 +20,7 @@ function createDiv() {
{ {
describe('Animation', () => { describe('Animation', () => {
// these tests are only mean't to be run within the DOM (for now) // these tests are only mean't to be run within the DOM (for now)
if (typeof Element == 'undefined') return; if (isNode) return;
let rootElement: any; let rootElement: any;
let subElement1: any; let subElement1: any;

View File

@ -17,7 +17,7 @@ import {makeTrigger} from '../shared';
{ {
describe('AnimationTrigger', () => { describe('AnimationTrigger', () => {
// these tests are only mean't to be run within the DOM (for now) // these tests are only mean't to be run within the DOM (for now)
if (typeof Element == 'undefined') return; if (isNode) return;
let element: any; let element: any;
beforeEach(() => { beforeEach(() => {

View File

@ -16,9 +16,7 @@ import {assertElementExistsInDom, createElement, findKeyframeDefinition, forceRe
const CSS_KEYFRAME_RULE_TYPE = 7; const CSS_KEYFRAME_RULE_TYPE = 7;
describe('CssKeyframesDriver tests', () => { describe('CssKeyframesDriver tests', () => {
if (typeof Element == 'undefined' || typeof document == 'undefined' || if (isNode || typeof(window as any)['AnimationEvent'] == 'undefined') return;
typeof(window as any)['AnimationEvent'] == 'undefined')
return;
describe('building keyframes', () => { describe('building keyframes', () => {
it('should build CSS keyframe style object containing the keyframe styles', () => { it('should build CSS keyframe style object containing the keyframe styles', () => {

View File

@ -14,7 +14,7 @@ import {assertStyle, createElement} from './shared';
const CSS_KEYFRAME_RULE_TYPE = 7; const CSS_KEYFRAME_RULE_TYPE = 7;
describe('DirectStylePlayer tests', () => { describe('DirectStylePlayer tests', () => {
if (typeof Element == 'undefined' || typeof document == 'undefined') return; if (isNode) return;
it('should apply the styling to the given element when the animation starts and remove when destroyed', it('should apply the styling to the given element when the animation starts and remove when destroyed',
() => { () => {

View File

@ -13,9 +13,7 @@ import {assertStyle, createElement, makeAnimationEvent, supportsAnimationEventCr
const EMPTY_FN = () => {}; const EMPTY_FN = () => {};
{ {
describe('ElementAnimationStyleHandler', () => { describe('ElementAnimationStyleHandler', () => {
if (typeof Element == 'undefined' || typeof document == 'undefined' || if (isNode || typeof(window as any)['AnimationEvent'] == 'undefined') return;
typeof(window as any)['AnimationEvent'] == 'undefined')
return;
it('should add and remove an animation on to an element\'s styling', () => { it('should add and remove an animation on to an element\'s styling', () => {
const element = createElement(); const element = createElement();

View File

@ -21,7 +21,7 @@ import {MockAnimationDriver, MockAnimationPlayer} from '../../testing/src/mock_a
} }
// these tests are only mean't to be run within the DOM // these tests are only mean't to be run within the DOM
if (typeof Element == 'undefined') return; if (isNode) return;
describe('TimelineAnimationEngine', () => { describe('TimelineAnimationEngine', () => {
let element: any; let element: any;

View File

@ -20,7 +20,7 @@ const DEFAULT_NAMESPACE_ID = 'id';
const driver = new MockAnimationDriver(); const driver = new MockAnimationDriver();
// these tests are only mean't to be run within the DOM // these tests are only mean't to be run within the DOM
if (typeof Element == 'undefined') return; if (isNode) return;
describe('TransitionAnimationEngine', () => { describe('TransitionAnimationEngine', () => {
let element: any; let element: any;

View File

@ -12,7 +12,7 @@ import {WebAnimationsPlayer} from '../../../src/render/web_animations/web_animat
{ {
describe('WebAnimationsDriver', () => { describe('WebAnimationsDriver', () => {
if (typeof Element == 'undefined' || typeof document == 'undefined') return; if (isNode) return;
describe('when web-animations are not supported natively', () => { describe('when web-animations are not supported natively', () => {
it('should return an instance of a CssKeyframePlayer if scrubbing is not requested', () => { it('should return an instance of a CssKeyframePlayer if scrubbing is not requested', () => {

View File

@ -20,7 +20,7 @@ const DEFAULT_COMPONENT_ID = '1';
(function() { (function() {
// these tests are only mean't to be run within the DOM (for now) // these tests are only mean't to be run within the DOM (for now)
if (typeof Element == 'undefined') return; if (isNode) return;
describe('animation tests', function() { describe('animation tests', function() {
function getLog(): MockAnimationPlayer[] { function getLog(): MockAnimationPlayer[] {

View File

@ -21,7 +21,7 @@ import {fakeAsync, flushMicrotasks} from '../../testing/src/fake_async';
(function() { (function() {
// these tests are only mean't to be run within the DOM (for now) // these tests are only mean't to be run within the DOM (for now)
if (typeof Element == 'undefined') return; if (isNode) return;
describe('animation query tests', function() { describe('animation query tests', function() {
function getLog(): MockAnimationPlayer[] { function getLog(): MockAnimationPlayer[] {

View File

@ -16,7 +16,7 @@ import {RouterTestingModule} from '@angular/router/testing';
(function() { (function() {
// these tests are only mean't to be run within the DOM (for now) // these tests are only mean't to be run within the DOM (for now)
if (typeof Element == 'undefined') return; if (isNode) return;
describe('Animation Router Tests', function() { describe('Animation Router Tests', function() {
function getLog(): MockAnimationPlayer[] { function getLog(): MockAnimationPlayer[] {

View File

@ -17,7 +17,7 @@ import {TestBed} from '../../testing';
(function() { (function() {
// these tests are only mean't to be run within the DOM (for now) // these tests are only mean't to be run within the DOM (for now)
// Buggy in Chromium 39, see https://github.com/angular/angular/issues/15793 // Buggy in Chromium 39, see https://github.com/angular/angular/issues/15793
if (typeof Element == 'undefined') return; if (isNode) return;
describe('animation integration tests using css keyframe animations', function() { describe('animation integration tests using css keyframe animations', function() {

View File

@ -18,7 +18,7 @@ import {TestBed} from '../../testing';
(function() { (function() {
// these tests are only mean't to be run within the DOM (for now) // these tests are only mean't to be run within the DOM (for now)
// Buggy in Chromium 39, see https://github.com/angular/angular/issues/15793 // Buggy in Chromium 39, see https://github.com/angular/angular/issues/15793
if (typeof Element == 'undefined' || !ɵsupportsWebAnimations()) return; if (isNode || !ɵsupportsWebAnimations()) return;
describe('animation integration tests using web animations', function() { describe('animation integration tests using web animations', function() {

View File

@ -117,7 +117,7 @@ import {el} from '../../testing/src/browser_util';
describe('flushing animations', () => { describe('flushing animations', () => {
// these tests are only mean't to be run within the DOM // these tests are only mean't to be run within the DOM
if (typeof Element == 'undefined') return; if (isNode) return;
it('should flush and fire callbacks when the zone becomes stable', (async) => { it('should flush and fire callbacks when the zone becomes stable', (async) => {
@Component({ @Component({