test: improve symbol-extractor test by ignoring $1 suffix (#28098)

PR Close #28098
This commit is contained in:
Misko Hevery
2019-01-12 00:59:48 -08:00
committed by Andrew Kushnir
parent da2880d7c4
commit 6a9a48b0ac
19 changed files with 111 additions and 82 deletions

View File

@ -15,7 +15,7 @@ import {componentNeedsResolution, maybeQueueResolutionOfComponentResources} from
import {ViewEncapsulation} from '../../metadata/view';
import {EMPTY_ARRAY, EMPTY_OBJ} from '../empty';
import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF} from '../fields';
import {stringify} from '../util';
import {renderStringify} from '../util';
import {R3DirectiveMetadataFacade, getCompilerFacade} from './compiler_facade';
import {R3ComponentMetadataFacade, R3QueryMetadataFacade} from './compiler_facade_interface';
@ -43,9 +43,9 @@ export function compileComponent(type: Type<any>, metadata: Component): void {
const compiler = getCompilerFacade();
if (ngComponentDef === null) {
if (componentNeedsResolution(metadata)) {
const error = [`Component '${stringify(type)}' is not resolved:`];
const error = [`Component '${renderStringify(type)}' is not resolved:`];
if (metadata.templateUrl) {
error.push(` - templateUrl: ${stringify(metadata.templateUrl)}`);
error.push(` - templateUrl: ${renderStringify(metadata.templateUrl)}`);
}
if (metadata.styleUrls && metadata.styleUrls.length) {
error.push(` - styleUrls: ${JSON.stringify(metadata.styleUrls)}`);
@ -69,7 +69,7 @@ export function compileComponent(type: Type<any>, metadata: Component): void {
viewProviders: metadata.viewProviders || null,
};
ngComponentDef = compiler.compileComponent(
angularCoreEnv, `ng://${stringify(type)}/template.html`, meta);
angularCoreEnv, `ng://${renderStringify(type)}/template.html`, meta);
// When NgModule decorator executed, we enqueued the module definition such that
// it would only dequeue and add itself as module scope to all of its declarations,
@ -176,7 +176,7 @@ function extractQueriesMetadata(
if (!ann.selector) {
throw new Error(
`Can't construct a query for the property "${field}" of ` +
`"${stringify(type)}" since the query selector wasn't defined.`);
`"${renderStringify(type)}" since the query selector wasn't defined.`);
}
queriesMeta.push(convertToR3QueryMetadata(field, ann));
}

View File

@ -17,7 +17,7 @@ import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../d
import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from '../fields';
import {ComponentDef} from '../interfaces/definition';
import {NgModuleType} from '../ng_module_ref';
import {stringify} from '../util';
import {renderStringify} from '../util';
import {R3InjectorMetadataFacade, getCompilerFacade} from './compiler_facade';
import {angularCoreEnv} from './environment';
@ -183,7 +183,7 @@ function verifySemanticsOfNgModuleDef(moduleType: NgModuleType): void {
const def = getComponentDef(type) || getDirectiveDef(type) || getPipeDef(type);
if (!def) {
errors.push(
`Unexpected value '${stringify(type)}' declared by the module '${stringify(moduleType)}'. Please add a @Pipe/@Directive/@Component annotation.`);
`Unexpected value '${renderStringify(type)}' declared by the module '${renderStringify(moduleType)}'. Please add a @Pipe/@Directive/@Component annotation.`);
}
}
@ -197,7 +197,7 @@ function verifySemanticsOfNgModuleDef(moduleType: NgModuleType): void {
if (combinedDeclarations.lastIndexOf(type) === -1) {
// We are exporting something which we don't explicitly declare or import.
errors.push(
`Can't export ${kind} ${stringify(type)} from ${stringify(moduleType)} as it was neither declared nor imported!`);
`Can't export ${kind} ${renderStringify(type)} from ${renderStringify(moduleType)} as it was neither declared nor imported!`);
}
}
}
@ -206,11 +206,11 @@ function verifySemanticsOfNgModuleDef(moduleType: NgModuleType): void {
type = resolveForwardRef(type);
const existingModule = ownerNgModule.get(type);
if (existingModule && existingModule !== moduleType) {
const modules = [existingModule, moduleType].map(stringify).sort();
const modules = [existingModule, moduleType].map(renderStringify).sort();
errors.push(
`Type ${stringify(type)} is part of the declarations of 2 modules: ${modules[0]} and ${modules[1]}! ` +
`Please consider moving ${stringify(type)} to a higher module that imports ${modules[0]} and ${modules[1]}. ` +
`You can also create a new NgModule that exports and includes ${stringify(type)} then import that NgModule in ${modules[0]} and ${modules[1]}.`);
`Type ${renderStringify(type)} is part of the declarations of 2 modules: ${modules[0]} and ${modules[1]}! ` +
`Please consider moving ${renderStringify(type)} to a higher module that imports ${modules[0]} and ${modules[1]}. ` +
`You can also create a new NgModule that exports and includes ${renderStringify(type)} then import that NgModule in ${modules[0]} and ${modules[1]}.`);
} else {
// Mark type as having owner.
ownerNgModule.set(type, moduleType);
@ -222,7 +222,7 @@ function verifySemanticsOfNgModuleDef(moduleType: NgModuleType): void {
const existingModule = ownerNgModule.get(type);
if (!existingModule) {
errors.push(
`Component ${stringify(type)} is not part of any NgModule or the module has not been imported into your module.`);
`Component ${renderStringify(type)} is not part of any NgModule or the module has not been imported into your module.`);
}
}

View File

@ -9,7 +9,7 @@
import {Type} from '../../interface/type';
import {Pipe} from '../../metadata/directives';
import {NG_PIPE_DEF} from '../fields';
import {stringify} from '../util';
import {renderStringify} from '../util';
import {getCompilerFacade} from './compiler_facade';
import {angularCoreEnv} from './environment';
@ -21,7 +21,7 @@ export function compilePipe(type: Type<any>, meta: Pipe): void {
get: () => {
if (ngPipeDef === null) {
ngPipeDef = getCompilerFacade().compilePipe(
angularCoreEnv, `ng://${stringify(type)}/ngPipeDef.js`, {
angularCoreEnv, `ng://${renderStringify(type)}/ngPipeDef.js`, {
type: type,
name: type.name,
deps: reflectDependencies(type),