test(language-service): Make tests better by adding more assertions (#32630)

This commit adds more assertions to a few smoke tests in typescript_host_spec.ts

PR Close #32630
This commit is contained in:
Keen Yee Liau
2019-09-11 22:08:20 -07:00
committed by Kara Erickson
parent 5cf597249c
commit 7a569a7c52
3 changed files with 40 additions and 11 deletions

View File

@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {CompileNgModuleMetadata, NgAnalyzedModules} from '@angular/compiler';
import {setup} from '@angular/compiler-cli/test/test_support';
import * as fs from 'fs';
import * as path from 'path';
@ -403,3 +404,18 @@ function getReferenceMarkers(value: string): ReferenceResult {
function removeReferenceMarkers(value: string): string {
return value.replace(referenceMarker, (match, text) => text.replace(/ᐱ/g, ''));
}
/**
* Find the StaticSymbol that has the specified `directiveName` and return its
* Angular metadata, if any.
* @param ngModules analyzed modules
* @param directiveName
*/
export function findDirectiveMetadataByName(
ngModules: NgAnalyzedModules, directiveName: string): CompileNgModuleMetadata|undefined {
for (const [key, value] of ngModules.ngModuleByPipeOrDirective) {
if (key.name === directiveName) {
return value;
}
}
}