test(dart/transform): e2e test inliner_for_test
Add an e2e test for the `inliner_for_test` transformer.
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
library examples.src.hello_world.absolute_url_expression_files;
|
||||
|
||||
import 'package:angular2/angular2.dart'
|
||||
show Component, Directive, View, NgElement;
|
||||
|
||||
@Component(selector: 'hello-app')
|
||||
@View(
|
||||
template: r'''{{greeting}}''',
|
||||
styles: const [r'''.greeting { .color: blue; }''',])
|
||||
class HelloCmp {}
|
||||
|
||||
@Injectable() hello() {}
|
@ -9,5 +9,4 @@ import 'package:angular2/angular2.dart'
|
||||
styleUrls: const ['package:other_package/template.css'])
|
||||
class HelloCmp {}
|
||||
|
||||
@Injectable()
|
||||
hello() {}
|
||||
@Injectable() hello() {}
|
||||
|
@ -1,11 +1,9 @@
|
||||
library angular2.test.transform.inliner_for_test.all_tests;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:angular2/src/transform/common/asset_reader.dart';
|
||||
import 'package:angular2/src/transform/inliner_for_test.dart';
|
||||
import 'package:barback/barback.dart';
|
||||
import 'package:code_transformers/tests.dart';
|
||||
import 'package:guinness/guinness.dart';
|
||||
import 'package:dart_style/dart_style.dart';
|
||||
|
||||
@ -15,9 +13,10 @@ main() {
|
||||
allTests();
|
||||
}
|
||||
|
||||
allTests() {
|
||||
DartFormatter formatter = new DartFormatter();
|
||||
|
||||
void allTests() {
|
||||
AssetReader absoluteReader;
|
||||
DartFormatter formatter = new DartFormatter();
|
||||
|
||||
beforeEach(() {
|
||||
absoluteReader = new TestAssetReader();
|
||||
@ -79,6 +78,68 @@ allTests() {
|
||||
|
||||
expect(output).toContain("{{greeting}}");
|
||||
});
|
||||
|
||||
_runAbsoluteUrlEndToEndTest();
|
||||
_runMultiStylesEndToEndTest();
|
||||
}
|
||||
|
||||
AssetId _assetId(String path) => new AssetId('a', 'inliner_for_test/$path');
|
||||
|
||||
void _runAbsoluteUrlEndToEndTest() {
|
||||
InlinerForTest transformer = new InlinerForTest(formatCode: true);
|
||||
var inputMap = {
|
||||
'a|absolute_url_expression_files/hello.dart':
|
||||
_readFile('absolute_url_expression_files/hello.dart'),
|
||||
'other_package|lib/template.css':
|
||||
_readFile('absolute_url_expression_files/template.css'),
|
||||
'other_package|lib/template.html':
|
||||
_readFile('absolute_url_expression_files/template.html')
|
||||
};
|
||||
var outputMap = {
|
||||
'a|absolute_url_expression_files/hello.dart':
|
||||
_readFile('absolute_url_expression_files/expected/hello.dart')
|
||||
};
|
||||
testPhases(
|
||||
'Inliner For Test should inline `templateUrl` and `styleUrls` values '
|
||||
'expressed as absolute urls',
|
||||
[
|
||||
[transformer]
|
||||
],
|
||||
inputMap,
|
||||
outputMap,
|
||||
[]);
|
||||
}
|
||||
|
||||
void _runMultiStylesEndToEndTest() {
|
||||
InlinerForTest transformer = new InlinerForTest(formatCode: true);
|
||||
var inputMap = {
|
||||
'pkg|web/hello.dart': _readFile('multiple_style_urls_files/hello.dart'),
|
||||
'pkg|web/template.css': _readFile('multiple_style_urls_files/template.css'),
|
||||
'pkg|web/template_other.css':
|
||||
_readFile('multiple_style_urls_files/template_other.css'),
|
||||
'pkg|web/template.html':
|
||||
_readFile('multiple_style_urls_files/template.html')
|
||||
};
|
||||
var outputMap = {
|
||||
'pkg|web/hello.dart':
|
||||
_readFile('multiple_style_urls_files/expected/hello.dart')
|
||||
};
|
||||
testPhases(
|
||||
'Inliner For Test should inline `templateUrl` and `styleUrls` values '
|
||||
'expressed as relative urls',
|
||||
[
|
||||
[transformer]
|
||||
],
|
||||
inputMap,
|
||||
outputMap,
|
||||
[]);
|
||||
}
|
||||
|
||||
/// Smooths over differences in CWD between IDEs and running tests in Travis.
|
||||
String _readFile(String path) {
|
||||
var code = readFile('inliner_for_test/$path');
|
||||
if (path.endsWith('.dart')) {
|
||||
code = formatter.format(code);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
library examples.src.hello_world.multiple_style_urls_files;
|
||||
|
||||
import 'package:angular2/angular2.dart'
|
||||
show Component, Directive, View, NgElement;
|
||||
|
||||
@Component(selector: 'hello-app')
|
||||
@View(
|
||||
template: r'''{{greeting}}''',
|
||||
styles: const [
|
||||
r'''.greeting { .color: blue; }''',
|
||||
r'''.hello { .color: red; }''',
|
||||
])
|
||||
class HelloCmp {}
|
Reference in New Issue
Block a user