refactor(dart/transform): Use package:guinness in tests
`guinness` is a Dart port of Jasmine. Since the rest of Angular 2 uses Jasmine, use it for the transformer too. Closes #8 Closes #1037 Closes #1000
This commit is contained in:
parent
4e82cc0861
commit
b35f288794
|
@ -7,7 +7,7 @@ import 'package:angular2/src/transform/common/formatter.dart';
|
||||||
import 'package:code_transformers/tests.dart';
|
import 'package:code_transformers/tests.dart';
|
||||||
import 'package:dart_style/dart_style.dart';
|
import 'package:dart_style/dart_style.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:unittest/unittest.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
import 'package:unittest/vm_config.dart';
|
import 'package:unittest/vm_config.dart';
|
||||||
|
|
||||||
import '../common/read_file.dart';
|
import '../common/read_file.dart';
|
||||||
|
@ -17,7 +17,7 @@ var formatter = new DartFormatter();
|
||||||
void allTests() {
|
void allTests() {
|
||||||
var reader = new TestAssetReader();
|
var reader = new TestAssetReader();
|
||||||
|
|
||||||
test('should generate a setter for a `bind` property in an annotation.',
|
it('should generate a setter for a `bind` property in an annotation.',
|
||||||
() async {
|
() async {
|
||||||
var inputPath = 'bind_generator/basic_bind_files/bar.ng_deps.dart';
|
var inputPath = 'bind_generator/basic_bind_files/bar.ng_deps.dart';
|
||||||
var expected = formatter.format(
|
var expected = formatter.format(
|
||||||
|
@ -25,10 +25,10 @@ void allTests() {
|
||||||
|
|
||||||
var output = formatter
|
var output = formatter
|
||||||
.format(await createNgSetters(reader, new AssetId('a', inputPath)));
|
.format(await createNgSetters(reader, new AssetId('a', inputPath)));
|
||||||
expect(output, equals(expected));
|
expect(output).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should generate a single setter when multiple annotations bind to the '
|
it('should generate a single setter when multiple annotations bind to the '
|
||||||
'same property.', () async {
|
'same property.', () async {
|
||||||
var inputPath =
|
var inputPath =
|
||||||
'bind_generator/duplicate_bind_name_files/soup.ng_deps.dart';
|
'bind_generator/duplicate_bind_name_files/soup.ng_deps.dart';
|
||||||
|
@ -37,6 +37,6 @@ void allTests() {
|
||||||
|
|
||||||
var output = formatter
|
var output = formatter
|
||||||
.format(await createNgSetters(reader, new AssetId('a', inputPath)));
|
.format(await createNgSetters(reader, new AssetId('a', inputPath)));
|
||||||
expect(output, equals(expected));
|
expect(output).toEqual(expected);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import 'package:angular2/src/transform/directive_linker/linker.dart';
|
||||||
import 'package:code_transformers/tests.dart';
|
import 'package:code_transformers/tests.dart';
|
||||||
import 'package:dart_style/dart_style.dart';
|
import 'package:dart_style/dart_style.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:unittest/unittest.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
import 'package:unittest/vm_config.dart';
|
import 'package:unittest/vm_config.dart';
|
||||||
|
|
||||||
import '../common/logger.dart';
|
import '../common/logger.dart';
|
||||||
|
@ -19,7 +19,7 @@ void allTests() {
|
||||||
var reader = new TestAssetReader();
|
var reader = new TestAssetReader();
|
||||||
setLogger(new NullLogger());
|
setLogger(new NullLogger());
|
||||||
|
|
||||||
test('should ensure that dependencies are property chained.', () async {
|
it('should ensure that dependencies are property chained.', () async {
|
||||||
for (var inputPath in [
|
for (var inputPath in [
|
||||||
'bar.ng_deps.dart',
|
'bar.ng_deps.dart',
|
||||||
'foo.ng_deps.dart',
|
'foo.ng_deps.dart',
|
||||||
|
@ -30,11 +30,11 @@ void allTests() {
|
||||||
inputPath = 'directive_linker/simple_files/$inputPath';
|
inputPath = 'directive_linker/simple_files/$inputPath';
|
||||||
var actual = formatter
|
var actual = formatter
|
||||||
.format(await linkNgDeps(reader, new AssetId('a', inputPath)));
|
.format(await linkNgDeps(reader, new AssetId('a', inputPath)));
|
||||||
expect(actual, equals(expected));
|
expect(actual).toEqual(expected);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should ensure that exported dependencies are property chained.',
|
it('should ensure that exported dependencies are property chained.',
|
||||||
() async {
|
() async {
|
||||||
for (var inputPath in [
|
for (var inputPath in [
|
||||||
'bar.ng_deps.dart',
|
'bar.ng_deps.dart',
|
||||||
|
@ -46,7 +46,7 @@ void allTests() {
|
||||||
inputPath = 'directive_linker/simple_export_files/$inputPath';
|
inputPath = 'directive_linker/simple_export_files/$inputPath';
|
||||||
var actual = formatter
|
var actual = formatter
|
||||||
.format(await linkNgDeps(reader, new AssetId('a', inputPath)));
|
.format(await linkNgDeps(reader, new AssetId('a', inputPath)));
|
||||||
expect(actual, equals(expected));
|
expect(actual).toEqual(expected);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import 'package:angular2/src/transform/common/formatter.dart';
|
||||||
import 'package:code_transformers/tests.dart';
|
import 'package:code_transformers/tests.dart';
|
||||||
import 'package:dart_style/dart_style.dart';
|
import 'package:dart_style/dart_style.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:unittest/unittest.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
import 'package:unittest/vm_config.dart';
|
import 'package:unittest/vm_config.dart';
|
||||||
|
|
||||||
import '../common/read_file.dart';
|
import '../common/read_file.dart';
|
||||||
|
@ -15,12 +15,12 @@ import '../common/read_file.dart';
|
||||||
var formatter = new DartFormatter();
|
var formatter = new DartFormatter();
|
||||||
|
|
||||||
void allTests() {
|
void allTests() {
|
||||||
test('should preserve parameter annotations as const instances.', () {
|
it('should preserve parameter annotations as const instances.', () {
|
||||||
var inputPath = 'parameter_metadata/soup.dart';
|
var inputPath = 'parameter_metadata/soup.dart';
|
||||||
var expected = _readFile('parameter_metadata/expected/soup.ng_deps.dart');
|
var expected = _readFile('parameter_metadata/expected/soup.ng_deps.dart');
|
||||||
var output =
|
var output =
|
||||||
formatter.format(createNgDeps(_readFile(inputPath), inputPath));
|
formatter.format(createNgDeps(_readFile(inputPath), inputPath));
|
||||||
expect(output, equals(expected));
|
expect(output).toEqual(expected);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/src/dom/html5lib_adapter.dart';
|
||||||
import 'package:angular2/transformer.dart';
|
import 'package:angular2/transformer.dart';
|
||||||
import 'package:code_transformers/tests.dart';
|
import 'package:code_transformers/tests.dart';
|
||||||
import 'package:dart_style/dart_style.dart';
|
import 'package:dart_style/dart_style.dart';
|
||||||
import 'package:unittest/unittest.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
|
|
||||||
import '../common/read_file.dart';
|
import '../common/read_file.dart';
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ library angular2.test.transform.reflection_remover;
|
||||||
import 'package:analyzer/analyzer.dart';
|
import 'package:analyzer/analyzer.dart';
|
||||||
import 'package:angular2/src/transform/reflection_remover/codegen.dart';
|
import 'package:angular2/src/transform/reflection_remover/codegen.dart';
|
||||||
import 'package:angular2/src/transform/reflection_remover/rewriter.dart';
|
import 'package:angular2/src/transform/reflection_remover/rewriter.dart';
|
||||||
import 'package:unittest/unittest.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
|
|
||||||
import 'reflection_remover_files/expected/index.dart' as expected;
|
import 'reflection_remover_files/expected/index.dart' as expected;
|
||||||
import '../common/read_file.dart';
|
import '../common/read_file.dart';
|
||||||
|
@ -11,11 +11,11 @@ import '../common/read_file.dart';
|
||||||
void allTests() {
|
void allTests() {
|
||||||
var codegen = new Codegen('web/index.dart', 'web/index.ng_deps.dart');
|
var codegen = new Codegen('web/index.dart', 'web/index.ng_deps.dart');
|
||||||
|
|
||||||
test('should remove uses of mirrors & insert calls to generated code.', () {
|
it('should remove uses of mirrors & insert calls to generated code.', () {
|
||||||
var code =
|
var code =
|
||||||
readFile('reflection_remover/reflection_remover_files/index.dart');
|
readFile('reflection_remover/reflection_remover_files/index.dart');
|
||||||
var output =
|
var output =
|
||||||
new Rewriter(code, codegen).rewrite(parseCompilationUnit(code));
|
new Rewriter(code, codegen).rewrite(parseCompilationUnit(code));
|
||||||
expect(output, equals(expected.code));
|
expect(output).toEqual(expected.code);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import 'package:angular2/src/transform/common/asset_reader.dart';
|
||||||
import 'package:angular2/src/transform/common/formatter.dart';
|
import 'package:angular2/src/transform/common/formatter.dart';
|
||||||
import 'package:angular2/src/transform/template_compiler/generator.dart';
|
import 'package:angular2/src/transform/template_compiler/generator.dart';
|
||||||
import 'package:dart_style/dart_style.dart';
|
import 'package:dart_style/dart_style.dart';
|
||||||
import 'package:unittest/unittest.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
|
|
||||||
import '../common/read_file.dart';
|
import '../common/read_file.dart';
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ void allTests() {
|
||||||
Html5LibDomAdapter.makeCurrent();
|
Html5LibDomAdapter.makeCurrent();
|
||||||
AssetReader reader = new TestAssetReader();
|
AssetReader reader = new TestAssetReader();
|
||||||
|
|
||||||
test('should parse simple expressions in inline templates.', () async {
|
it('should parse simple expressions in inline templates.', () async {
|
||||||
var inputPath =
|
var inputPath =
|
||||||
'template_compiler/inline_expression_files/hello.ng_deps.dart';
|
'template_compiler/inline_expression_files/hello.ng_deps.dart';
|
||||||
var expected = readFile(
|
var expected = readFile(
|
||||||
|
@ -24,16 +24,16 @@ void allTests() {
|
||||||
var output = await processTemplates(reader, new AssetId('a', inputPath));
|
var output = await processTemplates(reader, new AssetId('a', inputPath));
|
||||||
output = formatter.format(output);
|
output = formatter.format(output);
|
||||||
expected = formatter.format(expected);
|
expected = formatter.format(expected);
|
||||||
expect(output, equals(expected));
|
expect(output).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should parse simple methods in inline templates.', () async {
|
it('should parse simple methods in inline templates.', () async {
|
||||||
var inputPath = 'template_compiler/inline_method_files/hello.ng_deps.dart';
|
var inputPath = 'template_compiler/inline_method_files/hello.ng_deps.dart';
|
||||||
var expected = readFile(
|
var expected = readFile(
|
||||||
'template_compiler/inline_method_files/expected/hello.ng_deps.dart');
|
'template_compiler/inline_method_files/expected/hello.ng_deps.dart');
|
||||||
var output = await processTemplates(reader, new AssetId('a', inputPath));
|
var output = await processTemplates(reader, new AssetId('a', inputPath));
|
||||||
output = formatter.format(output);
|
output = formatter.format(output);
|
||||||
expected = formatter.format(expected);
|
expected = formatter.format(expected);
|
||||||
expect(output, equals(expected));
|
expect(output).toEqual(expected);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
library angular2.test.transform;
|
library angular2.test.transform;
|
||||||
|
|
||||||
import 'package:unittest/unittest.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
|
import 'package:unittest/unittest.dart' hide expect;
|
||||||
import 'package:unittest/vm_config.dart';
|
import 'package:unittest/vm_config.dart';
|
||||||
|
|
||||||
import 'bind_generator/all_tests.dart' as bindGenerator;
|
import 'bind_generator/all_tests.dart' as bindGenerator;
|
||||||
|
@ -12,10 +13,12 @@ import 'template_compiler/all_tests.dart' as templateCompiler;
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
useVMConfiguration();
|
useVMConfiguration();
|
||||||
group('Bind Generator', bindGenerator.allTests);
|
describe('Bind Generator', bindGenerator.allTests);
|
||||||
group('Directive Linker', directiveLinker.allTests);
|
describe('Directive Linker', directiveLinker.allTests);
|
||||||
group('Directive Processor', directiveProcessor.allTests);
|
describe('Directive Processor', directiveProcessor.allTests);
|
||||||
group('Reflection Remover', reflectionRemover.allTests);
|
describe('Reflection Remover', reflectionRemover.allTests);
|
||||||
group('Template Compiler', templateCompiler.allTests);
|
describe('Template Compiler', templateCompiler.allTests);
|
||||||
|
// NOTE(kegluneq): These use `code_transformers#testPhases`, which is not
|
||||||
|
// designed to work with `guinness`.
|
||||||
group('Transformer Pipeline', integration.allTests);
|
group('Transformer Pipeline', integration.allTests);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue