fix(ivy): TestBed should tolerate synchronous use of compileComponents (#28350)

TestBed.compileComponents has always been an async API. However,
ViewEngine tolerated using this API in a synchronous manner if the
components declared in the testing module did not have any async
resources (templateUrl, styleUrls). This change makes the ivy TestBed
mirror this tolerance by configuring such components synchronously.

Ref: FW-992

PR Close #28350
This commit is contained in:
Jeremy Elbourn
2019-01-23 15:09:27 -08:00
committed by Jason Aden
parent f8c70011b1
commit 3deda898d0
3 changed files with 54 additions and 19 deletions

View File

@ -91,8 +91,8 @@ export function maybeQueueResolutionOfComponentResources(metadata: Component) {
}
}
export function componentNeedsResolution(component: Component) {
return component.templateUrl || component.styleUrls && component.styleUrls.length;
export function componentNeedsResolution(component: Component): boolean {
return !!(component.templateUrl || component.styleUrls && component.styleUrls.length);
}
export function clearResolutionOfComponentResourcesQueue() {
componentResourceResolutionQueue.clear();
@ -100,4 +100,4 @@ export function clearResolutionOfComponentResourcesQueue() {
function unwrapResponse(response: string | {text(): Promise<string>}): string|Promise<string> {
return typeof response == 'string' ? response : response.text();
}
}