fix(testing): remove test zone for now and rely on returned promises
Adds tests for public Dart and TS frameworks to make sure that components with templateUrl can be created by the TestComponentBuilder. Closes #6359 Closes #6601
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<span>from external template</span>
|
||||
@@ -94,6 +94,15 @@ class TestViewProvidersComp {
|
||||
constructor(private fancyService: FancyService) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'external-template-comp'})
|
||||
@View({templateUrl: '/base/modules/angular2/test/testing/static_assets/test.html'})
|
||||
class ExternalTemplateComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'bad-template-comp'})
|
||||
@View({templateUrl: 'non-existant.html'})
|
||||
class BadTemplateUrl {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
describe('angular2 jasmine matchers', () => {
|
||||
@@ -273,11 +282,12 @@ export function main() {
|
||||
restoreJasmineIt();
|
||||
});
|
||||
|
||||
it('should fail when an asynchronous error is thrown', (done) => {
|
||||
// TODO(juliemr): reenable this test when we are using a test zone and can capture this error.
|
||||
xit('should fail when an asynchronous error is thrown', (done) => {
|
||||
var itPromise = patchJasmineIt();
|
||||
|
||||
it('throws an async error',
|
||||
inject([], () => { setTimeout(() => { throw new Error('bar'); }, 0); }));
|
||||
injectAsync([], () => { setTimeout(() => { throw new Error('bar'); }, 0); }));
|
||||
|
||||
itPromise.then(() => { done.fail('Expected test to fail, but it did not'); }, (err) => {
|
||||
expect(err.message).toEqual('bar');
|
||||
@@ -304,6 +314,19 @@ export function main() {
|
||||
restoreJasmineIt();
|
||||
});
|
||||
|
||||
it('should fail when an XHR fails', (done) => {
|
||||
var itPromise = patchJasmineIt();
|
||||
|
||||
it('should fail with an error from a promise',
|
||||
injectAsync([TestComponentBuilder], (tcb) => { return tcb.createAsync(BadTemplateUrl); }));
|
||||
|
||||
itPromise.then(() => { done.fail('Expected test to fail, but it did not'); }, (err) => {
|
||||
expect(err).toEqual('Failed to load non-existant.html');
|
||||
done();
|
||||
});
|
||||
restoreJasmineIt();
|
||||
});
|
||||
|
||||
describe('using beforeEachProviders', () => {
|
||||
beforeEachProviders(() => [bind(FancyService).toValue(new FancyService())]);
|
||||
|
||||
@@ -428,5 +451,16 @@ export function main() {
|
||||
.toHaveText('injected value: mocked out value');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should allow an external templateUrl',
|
||||
injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
|
||||
return tcb.createAsync(ExternalTemplateComp)
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement)
|
||||
.toHaveText('from external template\n');
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user