mirror of
https://github.com/angular/angular.git
synced 2026-12-06 05:09:14 -05:00
+17









Alex Rickabaugh
Alan Agius
Andrew Kushnir
Andrew Scott
Andrew Seguin
Cédric Exbrayat
Charles Lyding
Dave Shevitz
Doug Parker
Dylan Hunn
Emma Twersky
George Kalpakas
Igor Minar
Jeremy Elbourn
Jessica Janiuk
JiaLiPassion
Joey Perrott
Joost Koehoorn
Kristiyan Kostadinov
Madleina Scheidegger
Mark Thompson
Minko Gechev
Paul Gschwendtner
Pawel Kozlowski
Pete Bacon Darwin
Wagner Maciel
Zach Arend
84ef01d9d2
This commit removes the View Engine runtime. Itself, this change is relatively straightforward, but it represents the final step in a multi-year journey. It's only possible due to the hard work of many current and former team members and collaborators, who are too numerous to list here. Co-authored-by: Alan Agius <[email protected]> Co-authored-by: Andrew Kushnir <[email protected]> Co-authored-by: Andrew Scott <[email protected]> Co-authored-by: Andrew Seguin <[email protected]> Co-authored-by: Cédric Exbrayat <[email protected]> Co-authored-by: Charles Lyding <[email protected]> Co-authored-by: Dave Shevitz <[email protected]> Co-authored-by: Doug Parker <[email protected]> Co-authored-by: Dylan Hunn <[email protected]> Co-authored-by: Emma Twersky <[email protected]> Co-authored-by: George Kalpakas <[email protected]> Co-authored-by: Igor Minar <[email protected]> Co-authored-by: Jeremy Elbourn <[email protected]> Co-authored-by: Jessica Janiuk <[email protected]> Co-authored-by: JiaLiPassion <[email protected]> Co-authored-by: Joey Perrott <[email protected]> Co-authored-by: Joost Koehoorn <[email protected]> Co-authored-by: Kristiyan Kostadinov <[email protected]> Co-authored-by: Madleina Scheidegger <[email protected]> Co-authored-by: Mark Thompson <[email protected]> Co-authored-by: Minko Gechev <[email protected]> Co-authored-by: Paul Gschwendtner <[email protected]> Co-authored-by: Pawel Kozlowski <[email protected]> Co-authored-by: Pete Bacon Darwin <[email protected]> Co-authored-by: Wagner Maciel <[email protected]> Co-authored-by: Zach Arend <[email protected]> PR Close #44218
132 lines
4.5 KiB
TypeScript
132 lines
4.5 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {ResourceLoader} from '@angular/compiler';
|
|
import {Compiler, Component, NgModule} from '@angular/core';
|
|
import {fakeAsync, inject, TestBed, tick, waitForAsync} from '@angular/core/testing';
|
|
import {ResourceLoaderImpl} from '@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl';
|
|
|
|
// Components for the tests.
|
|
class FancyService {
|
|
value: string = 'real value';
|
|
getAsyncValue() {
|
|
return Promise.resolve('async value');
|
|
}
|
|
getTimeoutValue() {
|
|
return new Promise((resolve, reject) => {
|
|
setTimeout(() => {
|
|
resolve('timeout value');
|
|
}, 10);
|
|
});
|
|
}
|
|
}
|
|
|
|
// Tests for angular/testing bundle specific to the browser environment.
|
|
// For general tests, see test/testing/testing_public_spec.ts.
|
|
if (isBrowser) {
|
|
describe('test APIs for the browser', () => {
|
|
describe('using the async helper', () => {
|
|
let actuallyDone: boolean;
|
|
|
|
beforeEach(() => {
|
|
actuallyDone = false;
|
|
});
|
|
|
|
afterEach(() => {
|
|
expect(actuallyDone).toEqual(true);
|
|
});
|
|
|
|
it('should run async tests with ResourceLoaders', waitForAsync(() => {
|
|
const resourceLoader = new ResourceLoaderImpl();
|
|
resourceLoader
|
|
.get('/base/angular/packages/platform-browser/test/static_assets/test.html')
|
|
.then(() => {
|
|
actuallyDone = true;
|
|
});
|
|
}),
|
|
10000); // Long timeout here because this test makes an actual ResourceLoader.
|
|
});
|
|
|
|
describe('using the test injector with the inject helper', () => {
|
|
describe('setting up Providers', () => {
|
|
beforeEach(() => {
|
|
TestBed.configureTestingModule(
|
|
{providers: [{provide: FancyService, useValue: new FancyService()}]});
|
|
});
|
|
|
|
it('provides a real ResourceLoader instance',
|
|
inject([ResourceLoader], (resourceLoader: ResourceLoader) => {
|
|
expect(resourceLoader instanceof ResourceLoaderImpl).toBeTruthy();
|
|
}));
|
|
|
|
it('should allow the use of fakeAsync',
|
|
fakeAsync(inject([FancyService], (service: any /** TODO #9100 */) => {
|
|
let value: any /** TODO #9100 */;
|
|
service.getAsyncValue().then(function(val: any /** TODO #9100 */) {
|
|
value = val;
|
|
});
|
|
tick();
|
|
expect(value).toEqual('async value');
|
|
})));
|
|
});
|
|
});
|
|
|
|
describe('Compiler', () => {
|
|
it('should return NgModule id when asked', () => {
|
|
@NgModule({
|
|
id: 'test-module',
|
|
})
|
|
class TestModule {
|
|
}
|
|
|
|
TestBed.configureTestingModule({
|
|
imports: [TestModule],
|
|
});
|
|
const compiler = TestBed.inject(Compiler);
|
|
expect(compiler.getModuleId(TestModule)).toBe('test-module');
|
|
});
|
|
});
|
|
|
|
describe('errors', () => {
|
|
describe('should fail when an ResourceLoader fails', () => {
|
|
// TODO(alxhub): figure out why this is failing on saucelabs
|
|
xit('should fail with an error from a promise', async () => {
|
|
@Component({selector: 'bad-template-comp', templateUrl: 'non-existent.html'})
|
|
class BadTemplateUrl {
|
|
}
|
|
|
|
TestBed.configureTestingModule({declarations: [BadTemplateUrl]});
|
|
await expectAsync(TestBed.compileComponents())
|
|
.toBeRejectedWith('Failed to load non-existent.html');
|
|
}, 10000);
|
|
});
|
|
});
|
|
|
|
describe('TestBed createComponent', function() {
|
|
// TODO(alxhub): disable while we figure out how this should work
|
|
xit('should allow an external templateUrl', waitForAsync(() => {
|
|
@Component({
|
|
selector: 'external-template-comp',
|
|
templateUrl: '/base/angular/packages/platform-browser/test/static_assets/test.html'
|
|
})
|
|
class ExternalTemplateComp {
|
|
}
|
|
|
|
TestBed.configureTestingModule({declarations: [ExternalTemplateComp]});
|
|
TestBed.compileComponents().then(() => {
|
|
const componentFixture = TestBed.createComponent(ExternalTemplateComp);
|
|
componentFixture.detectChanges();
|
|
expect(componentFixture.nativeElement.textContent).toEqual('from external template');
|
|
});
|
|
}),
|
|
10000); // Long timeout here because this test makes an actual ResourceLoader
|
|
// request, and is slow on Edge.
|
|
});
|
|
});
|
|
}
|