test(aio): remove compileComponents from all tests

By reflex we began all component tests with an async `beforeEach` that called `compileComponents`.
In at least one case (`live-example.component.spec.ts`) that led to the `it` tests being async as well.
There is no need to call `.compileComponents` because CLI web pack + plugin inlines all templates and styles.
While `.compileComponents` was harmless, it added complexity and distraction which we should not inflict on future readers and testers.
This commit is contained in:
Ward Bell 2017-05-15 10:44:06 -07:00 committed by Pete Bacon Darwin
parent 44195858e6
commit 2ee7662737
10 changed files with 90 additions and 106 deletions

View File

@ -35,12 +35,9 @@ describe('AppComponent', () => {
let locationService: MockLocationService; let locationService: MockLocationService;
let sidenav: HTMLElement; let sidenav: HTMLElement;
beforeEach(async(() => {
createTestingModule('a/b');
TestBed.compileComponents();
}));
beforeEach(() => { beforeEach(() => {
createTestingModule('a/b');
fixture = TestBed.createComponent(AppComponent); fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
@ -366,15 +363,14 @@ describe('AppComponent', () => {
}); });
describe('initial rendering', () => { describe('initial rendering', () => {
beforeEach(async(() => { beforeEach(() => {
createTestingModule('a/b'); createTestingModule('a/b');
// Remove the DocViewer for this test and hide the missing component message // Remove the DocViewer for this test and hide the missing component message
TestBed.overrideModule(AppModule, { TestBed.overrideModule(AppModule, {
remove: { declarations: [DocViewerComponent] }, remove: { declarations: [DocViewerComponent] },
add: { schemas: [NO_ERRORS_SCHEMA] } add: { schemas: [NO_ERRORS_SCHEMA] }
}); });
TestBed.compileComponents(); });
}));
it('should initially add the starting class until the first document is rendered', () => { it('should initially add the starting class until the first document is rendered', () => {
fixture = TestBed.createComponent(AppComponent); fixture = TestBed.createComponent(AppComponent);

View File

@ -10,7 +10,7 @@ describe('ApiListComponent', () => {
let fixture: ComponentFixture<ApiListComponent>; let fixture: ComponentFixture<ApiListComponent>;
let sections: ApiSection[]; let sections: ApiSection[];
beforeEach(async(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ ApiListComponent ], declarations: [ ApiListComponent ],
providers: [ providers: [
@ -18,10 +18,7 @@ describe('ApiListComponent', () => {
{ provide: LocationService, useClass: TestLocationService } { provide: LocationService, useClass: TestLocationService }
] ]
}); });
TestBed.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ApiListComponent); fixture = TestBed.createComponent(ApiListComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
sections = getApiSections(); sections = getApiSections();

View File

@ -41,7 +41,7 @@ describe('CodeComponent', () => {
delete window['prettyPrintOne']; delete window['prettyPrintOne'];
}); });
beforeEach(async(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ MdSnackBarModule, NoopAnimationsModule ], imports: [ MdSnackBarModule, NoopAnimationsModule ],
declarations: [ CodeComponent, HostComponent ], declarations: [ CodeComponent, HostComponent ],
@ -50,9 +50,8 @@ describe('CodeComponent', () => {
CopierService, CopierService,
{provide: Logger, useClass: TestLogger } {provide: Logger, useClass: TestLogger }
] ]
}) });
.compileComponents(); });
}));
// Must be async because // Must be async because
// CodeComponent creates PrettyPrintService which async loads `prettify.js`. // CodeComponent creates PrettyPrintService which async loads `prettify.js`.

View File

@ -5,9 +5,11 @@ import { CurrentLocationComponent } from './current-location.component';
describe('CurrentLocationComponent', () => { describe('CurrentLocationComponent', () => {
let element: HTMLElement;
let fixture: ComponentFixture<CurrentLocationComponent>;
let locationService: MockLocationService; let locationService: MockLocationService;
beforeEach(async(() => { beforeEach(() => {
locationService = new MockLocationService('initial/url'); locationService = new MockLocationService('initial/url');
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@ -16,13 +18,12 @@ describe('CurrentLocationComponent', () => {
{ provide: LocationService, useValue: locationService } { provide: LocationService, useValue: locationService }
] ]
}); });
TestBed.compileComponents();
})); fixture = TestBed.createComponent(CurrentLocationComponent);
element = fixture.nativeElement;
});
it('should render the current location', () => { it('should render the current location', () => {
const fixture = TestBed.createComponent(CurrentLocationComponent);
const element: HTMLElement = fixture.nativeElement;
fixture.detectChanges(); fixture.detectChanges();
expect(element.innerText).toEqual('initial/url'); expect(element.innerText).toEqual('initial/url');

View File

@ -38,9 +38,6 @@ describe('LiveExampleComponent', () => {
} }
function testComponent(testFn: () => void) { function testComponent(testFn: () => void) {
return TestBed
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(HostComponent); fixture = TestBed.createComponent(HostComponent);
hostComponent = fixture.componentInstance; hostComponent = fixture.componentInstance;
liveExampleDe = fixture.debugElement.children[0]; liveExampleDe = fixture.debugElement.children[0];
@ -53,8 +50,8 @@ describe('LiveExampleComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
liveExampleComponent.onResize(1033); // wide by default liveExampleComponent.onResize(1033); // wide by default
fixture.detectChanges(); fixture.detectChanges();
})
.then(testFn); testFn();
} }
//////// tests //////// //////// tests ////////
@ -76,49 +73,49 @@ describe('LiveExampleComponent', () => {
function getLiveExampleAnchor() { return getAnchors()[0]; } function getLiveExampleAnchor() { return getAnchors()[0]; }
function getDownloadAnchor() { return getAnchors()[1]; } function getDownloadAnchor() { return getAnchors()[1]; }
it('should create LiveExampleComponent', async(() => { it('should create LiveExampleComponent', () => {
testComponent(() => { testComponent(() => {
expect(liveExampleComponent).toBeTruthy('LiveExampleComponent'); expect(liveExampleComponent).toBeTruthy('LiveExampleComponent');
}); });
})); });
it('should have expected plunker & download hrefs', async(() => { it('should have expected plunker & download hrefs', () => {
testPath = '/tutorial/toh-pt1'; testPath = '/tutorial/toh-pt1';
testComponent(() => { testComponent(() => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs[0]).toContain('/toh-pt1/eplnkr.html'); expect(hrefs[0]).toContain('/toh-pt1/eplnkr.html');
expect(hrefs[1]).toContain('/toh-pt1/toh-pt1.zip'); expect(hrefs[1]).toContain('/toh-pt1/toh-pt1.zip');
}); });
})); });
it('should have expected plunker & download hrefs even when path has # frag', async(() => { it('should have expected plunker & download hrefs even when path has # frag', () => {
testPath = '/tutorial/toh-pt1#somewhere'; testPath = '/tutorial/toh-pt1#somewhere';
testComponent(() => { testComponent(() => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs[0]).toContain('/toh-pt1/eplnkr.html'); expect(hrefs[0]).toContain('/toh-pt1/eplnkr.html');
expect(hrefs[1]).toContain('/toh-pt1/toh-pt1.zip'); expect(hrefs[1]).toContain('/toh-pt1/toh-pt1.zip');
}); });
})); });
it('should have expected plunker & download hrefs even when path has ? params', async(() => { it('should have expected plunker & download hrefs even when path has ? params', () => {
testPath = '/tutorial/toh-pt1?foo=1&bar="bar"'; testPath = '/tutorial/toh-pt1?foo=1&bar="bar"';
testComponent(() => { testComponent(() => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs[0]).toContain('/toh-pt1/eplnkr.html'); expect(hrefs[0]).toContain('/toh-pt1/eplnkr.html');
expect(hrefs[1]).toContain('/toh-pt1/toh-pt1.zip'); expect(hrefs[1]).toContain('/toh-pt1/toh-pt1.zip');
}); });
})); });
it('should have expected flat-style plunker when has `flat-style`', async(() => { it('should have expected flat-style plunker when has `flat-style`', () => {
testPath = '/tutorial/toh-pt1'; testPath = '/tutorial/toh-pt1';
setHostTemplate('<live-example flat-style></live-example>'); setHostTemplate('<live-example flat-style></live-example>');
testComponent(() => { testComponent(() => {
// The file should be "plnkr.html", not "eplnkr.html" // The file should be "plnkr.html", not "eplnkr.html"
expect(getLiveExampleAnchor().href).toContain('/plnkr.html'); expect(getLiveExampleAnchor().href).toContain('/plnkr.html');
}); });
})); });
it('should have expected plunker & download hrefs when has example directory (name)', async(() => { it('should have expected plunker & download hrefs when has example directory (name)', () => {
testPath = '/guide/somewhere'; testPath = '/guide/somewhere';
setHostTemplate('<live-example name="toh-pt1"></live-example>'); setHostTemplate('<live-example name="toh-pt1"></live-example>');
testComponent(() => { testComponent(() => {
@ -126,9 +123,9 @@ describe('LiveExampleComponent', () => {
expect(hrefs[0]).toContain('/toh-pt1/eplnkr.html'); expect(hrefs[0]).toContain('/toh-pt1/eplnkr.html');
expect(hrefs[1]).toContain('/toh-pt1/toh-pt1.zip'); expect(hrefs[1]).toContain('/toh-pt1/toh-pt1.zip');
}); });
})); });
it('should have expected plunker & download hrefs when has `plnkr`', async(() => { it('should have expected plunker & download hrefs when has `plnkr`', () => {
testPath = '/testing'; testPath = '/testing';
setHostTemplate('<live-example plnkr="app-specs"></live-example>'); setHostTemplate('<live-example plnkr="app-specs"></live-example>');
testComponent(() => { testComponent(() => {
@ -136,9 +133,9 @@ describe('LiveExampleComponent', () => {
expect(hrefs[0]).toContain('/testing/app-specs.eplnkr.html'); expect(hrefs[0]).toContain('/testing/app-specs.eplnkr.html');
expect(hrefs[1]).toContain('/testing/app-specs.testing.zip'); expect(hrefs[1]).toContain('/testing/app-specs.testing.zip');
}); });
})); });
it('should have expected plunker & download hrefs when has `name` & `plnkr`', async(() => { it('should have expected plunker & download hrefs when has `name` & `plnkr`', () => {
testPath = '/guide/somewhere'; testPath = '/guide/somewhere';
setHostTemplate('<live-example name="testing" plnkr="app-specs"></live-example>'); setHostTemplate('<live-example name="testing" plnkr="app-specs"></live-example>');
testComponent(() => { testComponent(() => {
@ -146,42 +143,42 @@ describe('LiveExampleComponent', () => {
expect(hrefs[0]).toContain('/testing/app-specs.eplnkr.html'); expect(hrefs[0]).toContain('/testing/app-specs.eplnkr.html');
expect(hrefs[1]).toContain('/testing/app-specs.testing.zip'); expect(hrefs[1]).toContain('/testing/app-specs.testing.zip');
}); });
})); });
it('should be embedded style by default', async(() => { it('should be embedded style by default', () => {
setHostTemplate('<live-example></live-example>'); setHostTemplate('<live-example></live-example>');
testComponent(() => { testComponent(() => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs[0]).toContain(defaultTestPath + '/eplnkr.html'); expect(hrefs[0]).toContain(defaultTestPath + '/eplnkr.html');
}); });
})); });
it('should be flat style when flat-style requested', async(() => { it('should be flat style when flat-style requested', () => {
setHostTemplate('<live-example flat-style></live-example>'); setHostTemplate('<live-example flat-style></live-example>');
testComponent(() => { testComponent(() => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs[0]).toContain(defaultTestPath + '/plnkr.html'); expect(hrefs[0]).toContain(defaultTestPath + '/plnkr.html');
}); });
})); });
it('should not have a download link when `noDownload` atty present', async(() => { it('should not have a download link when `noDownload` atty present', () => {
setHostTemplate('<live-example noDownload></live-example>'); setHostTemplate('<live-example noDownload></live-example>');
testComponent(() => { testComponent(() => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs.length).toBe(1, 'only the plunker live-example anchor'); expect(hrefs.length).toBe(1, 'only the plunker live-example anchor');
expect(hrefs[0]).toContain('plnkr.html'); expect(hrefs[0]).toContain('plnkr.html');
}); });
})); });
it('should only have a download link when `downloadOnly` atty present', async(() => { it('should only have a download link when `downloadOnly` atty present', () => {
setHostTemplate('<live-example downloadOnly>download this</live-example>'); setHostTemplate('<live-example downloadOnly>download this</live-example>');
testComponent(() => { testComponent(() => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs.length).toBe(1, 'only the zip anchor'); expect(hrefs.length).toBe(1, 'only the zip anchor');
expect(hrefs[0]).toContain('.zip'); }); expect(hrefs[0]).toContain('.zip'); });
})); });
it('should have default title when no title attribute or content', async(() => { it('should have default title when no title attribute or content', () => {
setHostTemplate('<live-example></live-example>'); setHostTemplate('<live-example></live-example>');
testComponent(() => { testComponent(() => {
const expectedTitle = 'live example'; const expectedTitle = 'live example';
@ -189,9 +186,9 @@ describe('LiveExampleComponent', () => {
expect(anchor.innerText).toBe(expectedTitle, 'anchor content'); expect(anchor.innerText).toBe(expectedTitle, 'anchor content');
expect(anchor.getAttribute('title')).toBe(expectedTitle, 'title'); expect(anchor.getAttribute('title')).toBe(expectedTitle, 'title');
}); });
})); });
it('should add title when set `title` attribute', async(() => { it('should add title when set `title` attribute', () => {
const expectedTitle = 'Great Example'; const expectedTitle = 'Great Example';
setHostTemplate(`<live-example title="${expectedTitle}"></live-example>`); setHostTemplate(`<live-example title="${expectedTitle}"></live-example>`);
testComponent(() => { testComponent(() => {
@ -199,9 +196,9 @@ describe('LiveExampleComponent', () => {
expect(anchor.innerText).toBe(expectedTitle, 'anchor content'); expect(anchor.innerText).toBe(expectedTitle, 'anchor content');
expect(anchor.getAttribute('title')).toBe(expectedTitle, 'title'); expect(anchor.getAttribute('title')).toBe(expectedTitle, 'title');
}); });
})); });
it('should add title from <live-example> body', async(() => { it('should add title from <live-example> body', () => {
liveExampleContent = 'The Greatest Example'; liveExampleContent = 'The Greatest Example';
setHostTemplate('<live-example title="ignore this title"></live-example>'); setHostTemplate('<live-example title="ignore this title"></live-example>');
testComponent(() => { testComponent(() => {
@ -209,16 +206,16 @@ describe('LiveExampleComponent', () => {
expect(anchor.innerText).toBe(liveExampleContent, 'anchor content'); expect(anchor.innerText).toBe(liveExampleContent, 'anchor content');
expect(anchor.getAttribute('title')).toBe(liveExampleContent, 'title'); expect(anchor.getAttribute('title')).toBe(liveExampleContent, 'title');
}); });
})); });
it('should not duplicate the exampleDir on a zip when there is a / on the name', async(() => { it('should not duplicate the exampleDir on a zip when there is a / on the name', () => {
setHostTemplate('<live-example name="testing/ts"></live-example>'); setHostTemplate('<live-example name="testing/ts"></live-example>');
testComponent(() => { testComponent(() => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs[0]).toContain('/testing/ts/eplnkr.html'); expect(hrefs[0]).toContain('/testing/ts/eplnkr.html');
expect(hrefs[1]).toContain('/testing/ts/testing.zip'); expect(hrefs[1]).toContain('/testing/ts/testing.zip');
}); });
})); });
}); });
describe('when embedded', () => { describe('when embedded', () => {
@ -240,45 +237,45 @@ describe('LiveExampleComponent', () => {
describe('before click', () => { describe('before click', () => {
it('should have hidden, embedded plunker', async(() => { it('should have hidden, embedded plunker', () => {
setHostTemplate('<live-example embedded></live-example>'); setHostTemplate('<live-example embedded></live-example>');
testComponent(() => { testComponent(() => {
expect(liveExampleComponent.mode).toBe('embedded', 'component is embedded'); expect(liveExampleComponent.mode).toBe('embedded', 'component is embedded');
expect(liveExampleComponent.showEmbedded).toBe(false, 'component.showEmbedded'); expect(liveExampleComponent.showEmbedded).toBe(false, 'component.showEmbedded');
expect(getEmbeddedPlunkerComponent()).toBeNull('no EmbeddedPlunkerComponent'); expect(getEmbeddedPlunkerComponent()).toBeNull('no EmbeddedPlunkerComponent');
}); });
})); });
it('should have default plunker placeholder image', async(() => { it('should have default plunker placeholder image', () => {
setHostTemplate('<live-example embedded></live-example>'); setHostTemplate('<live-example embedded></live-example>');
testComponent(() => { testComponent(() => {
expect(getImg().src).toContain('plunker/placeholder.png'); expect(getImg().src).toContain('plunker/placeholder.png');
}); });
})); });
it('should have specified plunker placeholder image', async(() => { it('should have specified plunker placeholder image', () => {
const expectedSrc = 'example/demo.png'; const expectedSrc = 'example/demo.png';
setHostTemplate(`<live-example embedded img="${expectedSrc}"></live-example>`); setHostTemplate(`<live-example embedded img="${expectedSrc}"></live-example>`);
testComponent(() => { testComponent(() => {
expect(getImg().src).toContain(expectedSrc); expect(getImg().src).toContain(expectedSrc);
}); });
})); });
it('should have download paragraph with expected anchor href', async(() => { it('should have download paragraph with expected anchor href', () => {
testPath = '/tutorial/toh-pt1'; testPath = '/tutorial/toh-pt1';
setHostTemplate('<live-example embedded></live-example>'); setHostTemplate('<live-example embedded></live-example>');
testComponent(() => { testComponent(() => {
expect(getDownloadAnchor().href).toContain('/toh-pt1/toh-pt1.zip'); expect(getDownloadAnchor().href).toContain('/toh-pt1/toh-pt1.zip');
}); });
})); });
it('should not have download paragraph when has `nodownload`', async(() => { it('should not have download paragraph when has `nodownload`', () => {
testPath = '/tutorial/toh-pt1'; testPath = '/tutorial/toh-pt1';
setHostTemplate('<live-example embedded nodownload></live-example>'); setHostTemplate('<live-example embedded nodownload></live-example>');
testComponent(() => { testComponent(() => {
expect(getDownloadAnchor()).toBeNull(); expect(getDownloadAnchor()).toBeNull();
}); });
})); });
}); });
@ -289,7 +286,7 @@ describe('LiveExampleComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
} }
it('should show plunker in the page', async(() => { it('should show plunker in the page', () => {
setHostTemplate('<live-example embedded></live-example>'); setHostTemplate('<live-example embedded></live-example>');
testComponent(() => { testComponent(() => {
clickImg(); clickImg();
@ -297,14 +294,14 @@ describe('LiveExampleComponent', () => {
expect(liveExampleComponent.showEmbedded).toBe(true, 'component.showEmbedded'); expect(liveExampleComponent.showEmbedded).toBe(true, 'component.showEmbedded');
expect(getEmbeddedPlunkerComponent()).toBeDefined('has EmbeddedPlunkerComponent'); expect(getEmbeddedPlunkerComponent()).toBeDefined('has EmbeddedPlunkerComponent');
}); });
})); });
}); });
}); });
describe('when narrow display (mobile)', () => { describe('when narrow display (mobile)', () => {
it('should be embedded style when no style defined', async(() => { it('should be embedded style when no style defined', () => {
setHostTemplate('<live-example></live-example>'); setHostTemplate('<live-example></live-example>');
testComponent(() => { testComponent(() => {
liveExampleComponent.onResize(600); // narrow liveExampleComponent.onResize(600); // narrow
@ -312,9 +309,9 @@ describe('LiveExampleComponent', () => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs[0]).toContain(defaultTestPath + '/eplnkr.html'); expect(hrefs[0]).toContain(defaultTestPath + '/eplnkr.html');
}); });
})); });
it('should be embedded style even when flat-style requested', async(() => { it('should be embedded style even when flat-style requested', () => {
setHostTemplate('<live-example flat-style></live-example>'); setHostTemplate('<live-example flat-style></live-example>');
testComponent(() => { testComponent(() => {
liveExampleComponent.onResize(600); // narrow liveExampleComponent.onResize(600); // narrow
@ -322,7 +319,6 @@ describe('LiveExampleComponent', () => {
const hrefs = getHrefs(); const hrefs = getHrefs();
expect(hrefs[0]).toContain(defaultTestPath + '/eplnkr.html'); expect(hrefs[0]).toContain(defaultTestPath + '/eplnkr.html');
}); });
})); });
}); });
}); });

View File

@ -28,16 +28,15 @@ describe('TocComponent', () => {
}; };
} }
beforeEach(async(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ HostEmbeddedTocComponent, HostNotEmbeddedTocComponent, TocComponent ], declarations: [ HostEmbeddedTocComponent, HostNotEmbeddedTocComponent, TocComponent ],
providers: [ providers: [
{ provide: ScrollService, useClass: TestScrollService }, { provide: ScrollService, useClass: TestScrollService },
{ provide: TocService, useClass: TestTocService } { provide: TocService, useClass: TestTocService }
] ]
}) });
.compileComponents(); });
}));
describe('when embedded in doc body', () => { describe('when embedded in doc body', () => {
let fixture: ComponentFixture<HostEmbeddedTocComponent>; let fixture: ComponentFixture<HostEmbeddedTocComponent>;

View File

@ -112,7 +112,7 @@ describe('DocViewerComponent', () => {
component.currentDoc = { contents, id }; component.currentDoc = { contents, id };
} }
beforeEach(async(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ TestModule ], imports: [ TestModule ],
declarations: [ declarations: [
@ -125,9 +125,8 @@ describe('DocViewerComponent', () => {
{ provide: Title, useClass: TestTitleService }, { provide: Title, useClass: TestTitleService },
{ provide: TocService, useClass: TestTocService } { provide: TocService, useClass: TestTocService }
] ]
}) });
.compileComponents(); });
}));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(TestComponent); fixture = TestBed.createComponent(TestComponent);

View File

@ -9,15 +9,14 @@ describe('TopMenuComponent', () => {
let component: TopMenuComponent; let component: TopMenuComponent;
let fixture: ComponentFixture<TopMenuComponent>; let fixture: ComponentFixture<TopMenuComponent>;
beforeEach(async(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ TopMenuComponent ], declarations: [ TopMenuComponent ],
providers: [ providers: [
{ provide: NavigationService, useClass: TestNavigationService } { provide: NavigationService, useClass: TestNavigationService }
] ]
}) });
.compileComponents(); });
}));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(TopMenuComponent); fixture = TestBed.createComponent(TopMenuComponent);

View File

@ -18,15 +18,14 @@ describe('SearchBoxComponent', () => {
let host: HostComponent; let host: HostComponent;
let fixture: ComponentFixture<HostComponent>; let fixture: ComponentFixture<HostComponent>;
beforeEach(async(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ SearchBoxComponent, HostComponent ], declarations: [ SearchBoxComponent, HostComponent ],
providers: [ providers: [
{ provide: LocationService, useFactory: () => new MockLocationService('') } { provide: LocationService, useFactory: () => new MockLocationService('') }
] ]
}) });
.compileComponents(); });
}));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(HostComponent); fixture = TestBed.createComponent(HostComponent);

View File

@ -33,15 +33,14 @@ describe('SearchResultsComponent', () => {
return take === undefined ? results : results.slice(0, take); return take === undefined ? results : results.slice(0, take);
} }
beforeEach(async(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ SearchResultsComponent ], declarations: [ SearchResultsComponent ],
providers: [ providers: [
{ provide: SearchService, useFactory: () => new MockSearchService() } { provide: SearchService, useFactory: () => new MockSearchService() }
] ]
}) });
.compileComponents(); });
}));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(SearchResultsComponent); fixture = TestBed.createComponent(SearchResultsComponent);