Skip to content

Commit

Permalink
fix(tests): remove unneeded async() wrappers in karma tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBurleson committed Dec 28, 2016
1 parent 484a280 commit a77de3c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 30 deletions.
13 changes: 4 additions & 9 deletions src/lib/flexbox/api/flex.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import {Component, OnInit, DebugElement} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ComponentFixture, TestBed, async } from '@angular/core/testing';
import {ComponentFixture, TestBed } from '@angular/core/testing';

import {MockMatchMedia} from '../../media-query/mock/mock-match-media';
import {MatchMedia} from '../../media-query/match-media';
import {BreakPointsProvider} from '../../media-query/providers/break-points-provider';
import {BreakPointRegistry} from '../../media-query/breakpoints/break-point-registry';
import {FlexLayoutModule} from '../_module';

import {customMatchers, expect} from '../../utils/testing/custom-matchers';
import {customMatchers} from '../../utils/testing/custom-matchers';
import {makeCreateTestComponent, makeExpectDOMFrom, makeExpectDOMForQuery} from '../../utils/testing/helpers';

describe('flex directive', () => {
let fixture: ComponentFixture<any>;
let createTestComponent = makeCreateTestComponent(()=> TestFlexComponent);
let expectDOMFrom = makeExpectDOMFrom(()=> TestFlexComponent);
let expectDomForQuery = makeExpectDOMForQuery(()=> TestFlexComponent);
let activateMediaQuery = (alias, allowOverlaps?:boolean) => {
let matchMedia : MockMatchMedia = fixture.debugElement.injector.get(MatchMedia);
matchMedia.activate(alias,allowOverlaps);
};

beforeEach(async(() => {
beforeEach(() => {
jasmine.addMatchers(customMatchers);

// Configure testbed to prepare services
Expand All @@ -33,7 +28,7 @@ describe('flex directive', () => {
{provide: MatchMedia, useClass: MockMatchMedia}
]
})
}));
});
afterEach(() => {
if ( fixture ) {
fixture.debugElement.injector.get(MatchMedia).clearAll();
Expand Down
12 changes: 6 additions & 6 deletions src/lib/flexbox/api/hide.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {Component, OnInit, DebugElement} from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ComponentFixture, TestBed, async } from '@angular/core/testing';
import {ComponentFixture, TestBed } from '@angular/core/testing';

import {MockMatchMedia} from '../../media-query/mock/mock-match-media';
import {MatchMedia} from '../../media-query/match-media';
import {BreakPointsProvider} from '../../media-query/providers/break-points-provider';
import {BreakPointRegistry} from '../../media-query/breakpoints/break-point-registry';
import {FlexLayoutModule} from '../_module';

import {customMatchers, expect} from '../../utils/testing/custom-matchers';
import {makeCreateTestComponent, makeExpectDOMFrom, expectNativeEl} from '../../utils/testing/helpers';
import {customMatchers} from '../../utils/testing/custom-matchers';
import {makeCreateTestComponent, expectNativeEl} from '../../utils/testing/helpers';

describe('show directive', () => {
let fixture: ComponentFixture<any>;
Expand All @@ -19,7 +19,7 @@ describe('show directive', () => {
matchMedia.activate(alias);
};

beforeEach(async(() => {
beforeEach(() => {
jasmine.addMatchers(customMatchers);

// Configure testbed to prepare services
Expand All @@ -31,7 +31,7 @@ describe('show directive', () => {
{provide: MatchMedia, useClass: MockMatchMedia}
]
})
}));
});
afterEach(() => {
if ( fixture ) {
fixture.debugElement.injector.get(MatchMedia).clearAll();
Expand Down
6 changes: 3 additions & 3 deletions src/lib/flexbox/api/layout-align.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ComponentFixture, TestBed, async } from '@angular/core/testing';
import {ComponentFixture, TestBed } from '@angular/core/testing';

import {MockMatchMedia} from '../../media-query/mock/mock-match-media';
import {MatchMedia} from '../../media-query/match-media';
Expand All @@ -17,7 +17,7 @@ describe('layout-align directive', () => {
let createTestComponent = makeCreateTestComponent(()=> TestLayoutAlignComponent);
let expectDOMFrom = makeExpectDOMFrom(()=> TestLayoutAlignComponent);

beforeEach(async(() => {
beforeEach(() => {
jasmine.addMatchers(customMatchers);

// Configure testbed to prepare services
Expand All @@ -29,7 +29,7 @@ describe('layout-align directive', () => {
{provide: MatchMedia, useClass: MockMatchMedia}
]
})
}));
});
afterEach(() => {
if ( fixture ) {
fixture.debugElement.injector.get(MatchMedia).clearAll();
Expand Down
6 changes: 3 additions & 3 deletions src/lib/flexbox/api/layout.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ComponentFixture, TestBed, async } from '@angular/core/testing';
import {ComponentFixture, TestBed } from '@angular/core/testing';

import {MockMatchMedia} from '../../media-query/mock/mock-match-media';
import {MatchMedia} from '../../media-query/match-media';
Expand All @@ -20,7 +20,7 @@ describe('layout directive', () => {
matchMedia.activate(alias,allowOverlaps);
};

beforeEach(async(() => {
beforeEach(() => {
jasmine.addMatchers(customMatchers);

// Configure testbed to prepare services
Expand All @@ -32,7 +32,7 @@ describe('layout directive', () => {
{provide: MatchMedia, useClass: MockMatchMedia}
]
})
}));
});
afterEach(() => {
if ( fixture ) {
fixture.debugElement.injector.get(MatchMedia).clearAll();
Expand Down
12 changes: 6 additions & 6 deletions src/lib/flexbox/api/show.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {Component, OnInit, DebugElement} from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ComponentFixture, TestBed, async } from '@angular/core/testing';
import {ComponentFixture, TestBed } from '@angular/core/testing';

import {MockMatchMedia} from '../../media-query/mock/mock-match-media';
import {MatchMedia} from '../../media-query/match-media';
import {BreakPointsProvider} from '../../media-query/providers/break-points-provider';
import {BreakPointRegistry} from '../../media-query/breakpoints/break-point-registry';
import {FlexLayoutModule} from '../_module';

import {customMatchers, expect} from '../../utils/testing/custom-matchers';
import {makeCreateTestComponent, makeExpectDOMFrom, expectNativeEl} from '../../utils/testing/helpers';
import {customMatchers} from '../../utils/testing/custom-matchers';
import {makeCreateTestComponent, expectNativeEl} from '../../utils/testing/helpers';

describe('show directive', () => {
let fixture: ComponentFixture<any>;
Expand All @@ -19,7 +19,7 @@ describe('show directive', () => {
matchMedia.activate(alias, enableOverlaps);
};

beforeEach(async(() => {
beforeEach(() => {
jasmine.addMatchers(customMatchers);

// Configure testbed to prepare services
Expand All @@ -31,7 +31,7 @@ describe('show directive', () => {
{provide: MatchMedia, useClass: MockMatchMedia}
]
})
}));
});
afterEach(() => {
if ( fixture ) {
fixture.debugElement.injector.get(MatchMedia).clearAll();
Expand Down
6 changes: 3 additions & 3 deletions src/lib/flexbox/responsive/responsive-activation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import {Observable} from 'rxjs/Observable';

import { TestBed, inject, async } from '@angular/core/testing';
import { TestBed, inject } from '@angular/core/testing';

import {MockMatchMedia} from '../../media-query/mock/mock-match-media';
import {BreakPointRegistry} from '../../media-query/breakpoints/break-point-registry';
Expand Down Expand Up @@ -46,14 +46,14 @@ describe('responsive-activation', () => {
});

// Single async inject to save references; which are used in all tests below
beforeEach( async(inject(
beforeEach(inject(
[ BreakPointRegistry, MatchMedia, MediaMonitor ],
(_breakPoints_, _matchMedia_, _mediaMonitor_) => {
breakPoints = _breakPoints_; // Only used to look up mediaQuery by aliases
matchMedia = _matchMedia_; // Only used to manual/simulate activate a mediaQuery
monitor = _mediaMonitor_;
}
)));
));

it('does not report mediaQuery changes for static usages', () => {
let value;
Expand Down

0 comments on commit a77de3c

Please sign in to comment.