refactor(tests): move public test APIs to TestBed (#10621)
Completely remove deprecated TestComponentBuilder and friends.
This commit is contained in:
parent
43512aa5eb
commit
aff1bc9f2d
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {XHR} from '@angular/compiler';
|
import {XHR} from '@angular/compiler';
|
||||||
import {Component, bind} from '@angular/core';
|
import {Component, bind} from '@angular/core';
|
||||||
import {TestComponentBuilder, addProviders, async, fakeAsync, inject, tick} from '@angular/core/testing';
|
import {TestBed, async, fakeAsync, flushMicrotasks, inject, tick} from '@angular/core/testing';
|
||||||
|
|
||||||
import {XHRImpl} from '../src/xhr/xhr_impl';
|
import {XHRImpl} from '../src/xhr/xhr_impl';
|
||||||
|
|
||||||
@ -56,7 +56,10 @@ export function main() {
|
|||||||
|
|
||||||
describe('using the test injector with the inject helper', () => {
|
describe('using the test injector with the inject helper', () => {
|
||||||
describe('setting up Providers', () => {
|
describe('setting up Providers', () => {
|
||||||
beforeEach(() => addProviders([{provide: FancyService, useValue: new FancyService()}]));
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule(
|
||||||
|
{providers: [{provide: FancyService, useValue: new FancyService()}]});
|
||||||
|
});
|
||||||
|
|
||||||
it('provides a real XHR instance',
|
it('provides a real XHR instance',
|
||||||
inject([XHR], (xhr: XHR) => { expect(xhr instanceof XHRImpl).toBeTruthy(); }));
|
inject([XHR], (xhr: XHR) => { expect(xhr instanceof XHRImpl).toBeTruthy(); }));
|
||||||
@ -96,10 +99,10 @@ export function main() {
|
|||||||
it('should fail when an XHR fails', (done: any /** TODO #9100 */) => {
|
it('should fail when an XHR fails', (done: any /** TODO #9100 */) => {
|
||||||
var itPromise = patchJasmineIt();
|
var itPromise = patchJasmineIt();
|
||||||
|
|
||||||
it('should fail with an error from a promise',
|
it('should fail with an error from a promise', async(() => {
|
||||||
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
TestBed.configureTestingModule({declarations: [BadTemplateUrl]});
|
||||||
return tcb.createAsync(BadTemplateUrl);
|
TestBed.compileComponents();
|
||||||
})));
|
}));
|
||||||
|
|
||||||
itPromise.then(
|
itPromise.then(
|
||||||
() => { done.fail('Expected test to fail, but it did not'); },
|
() => { done.fail('Expected test to fail, but it did not'); },
|
||||||
@ -113,17 +116,15 @@ export function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('test component builder', function() {
|
describe('test component builder', function() {
|
||||||
it('should allow an external templateUrl',
|
it('should allow an external templateUrl', async(() => {
|
||||||
async(inject(
|
TestBed.configureTestingModule({declarations: [ExternalTemplateComp]});
|
||||||
[TestComponentBuilder],
|
TestBed.compileComponents().then(() => {
|
||||||
(tcb: TestComponentBuilder) => {
|
let componentFixture = TestBed.createComponent(ExternalTemplateComp);
|
||||||
|
componentFixture.detectChanges();
|
||||||
tcb.createAsync(ExternalTemplateComp).then((componentFixture) => {
|
expect(componentFixture.debugElement.nativeElement.textContent)
|
||||||
componentFixture.detectChanges();
|
.toEqual('from external template\n');
|
||||||
expect(componentFixture.debugElement.nativeElement.textContent)
|
});
|
||||||
.toEqual('from external template\n');
|
}),
|
||||||
});
|
|
||||||
})),
|
|
||||||
10000); // Long timeout here because this test makes an actual XHR, and is slow on Edge.
|
10000); // Long timeout here because this test makes an actual XHR, and is slow on Edge.
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user