test(dart/transform): Update unit tests to expect code in <file>.template.dart

Closes #6711
This commit is contained in:
Tim Blasi
2016-01-26 16:36:13 -08:00
committed by Timothy Blasi
parent 8c36aa866a
commit 566d3ede04
31 changed files with 148 additions and 143 deletions

View File

@ -73,6 +73,17 @@ class TransformerOptions {
/// at any time.
final bool lazyTransformers;
/// Whether to generate compiled templates.
///
/// This option is strictly for internal testing and is not available as an
/// option on the transformer.
/// Setting this to `false` means that our generated .template.dart files do
/// not have any compiled templates or change detectors defined in them.
/// These files will not be usable, but this allows us to test the code output
/// of the transformer without breaking when compiled template internals
/// change.
final bool genCompiledTemplates;
TransformerOptions._internal(
this.entryPoints,
this.entryPointGlobs,
@ -80,13 +91,14 @@ class TransformerOptions {
this.mirrorMode,
this.initReflector,
this.annotationMatcher,
{this.genChangeDetectionDebugInfo,
this.reflectPropertiesAsAttributes,
this.platformDirectives,
this.platformPipes,
{this.formatCode,
this.genChangeDetectionDebugInfo,
this.genCompiledTemplates,
this.inlineViews,
this.lazyTransformers,
this.formatCode});
this.platformDirectives,
this.platformPipes,
this.reflectPropertiesAsAttributes});
factory TransformerOptions(List<String> entryPoints,
{String modeName: 'release',
@ -95,6 +107,7 @@ class TransformerOptions {
List<ClassDescriptor> customAnnotationDescriptors: const [],
bool inlineViews: false,
bool genChangeDetectionDebugInfo: false,
bool genCompiledTemplates: true,
bool reflectPropertiesAsAttributes: false,
List<String> platformDirectives,
List<String> platformPipes,
@ -108,6 +121,7 @@ class TransformerOptions {
return new TransformerOptions._internal(entryPoints, entryPointGlobs,
modeName, mirrorMode, initReflector, annotationMatcher,
genChangeDetectionDebugInfo: genChangeDetectionDebugInfo,
genCompiledTemplates: genCompiledTemplates,
reflectPropertiesAsAttributes: reflectPropertiesAsAttributes,
platformDirectives: platformDirectives,
platformPipes: platformPipes,

View File

@ -4,6 +4,7 @@ import 'dart:async';
import 'package:barback/barback.dart';
import 'package:angular2/src/compiler/source_module.dart';
import 'package:angular2/src/core/change_detection/interfaces.dart';
import 'package:angular2/src/facade/lang.dart';
import 'package:angular2/src/core/reflection/reflection.dart';

View File

@ -52,16 +52,11 @@ class TemplateCompiler extends Transformer implements LazyTransformer {
if (outputs != null) {
if (outputs.ngDeps != null) {
final buf = new StringBuffer();
final templatesSrc =
options.genCompiledTemplates ? outputs.templatesSource : null;
writeTemplateFile(
new NgDepsWriter(buf), outputs.ngDeps, outputs.templatesSource);
new NgDepsWriter(buf), outputs.ngDeps, templatesSrc);
ngDepsCode = formatter.format(buf.toString());
if (primaryId.path.endsWith('index.ng_meta.json')) {
final buf2 = new StringBuffer();
var writer = new NgDepsWriter(buf2);
outputs.ngDeps.imports.forEach(writer.writeImportModel);
print(buf2.toString());
}
}
}
transform.addOutput(