test(dart/transform): Move BindGenerator tests to their own dir.
Move existing BindGenerator test to its own directory and to test that phase specificially, rather than the whole pipeline. Add another BindGenerator test.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
library angular2.test.transform.bind_generator.all_tests;
|
||||
|
||||
import 'dart:io';
|
||||
import 'package:barback/barback.dart';
|
||||
import 'package:angular2/src/transform/bind_generator/generator.dart';
|
||||
import 'package:angular2/src/transform/common/formatter.dart';
|
||||
import 'package:code_transformers/tests.dart';
|
||||
import 'package:dart_style/dart_style.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/vm_config.dart';
|
||||
|
||||
import '../common/read_file.dart';
|
||||
|
||||
var formatter = new DartFormatter();
|
||||
|
||||
void allTests() {
|
||||
var reader = new TestAssetReader();
|
||||
|
||||
test('should generate a setter for a `bind` property in an annotation.',
|
||||
() async {
|
||||
var inputPath = 'bind_generator/basic_bind_files/bar.ngDeps.dart';
|
||||
var expected = formatter.format(
|
||||
readFile('bind_generator/basic_bind_files/expected/bar.ngDeps.dart'));
|
||||
|
||||
var output = formatter
|
||||
.format(await createNgSetters(reader, new AssetId('a', inputPath)));
|
||||
expect(output, equals(expected));
|
||||
});
|
||||
|
||||
test('should generate a single setter when multiple annotations bind to the '
|
||||
'same property.', () async {
|
||||
var inputPath = 'bind_generator/duplicate_bind_name_files/soup.ngDeps.dart';
|
||||
var expected = formatter.format(readFile(
|
||||
'bind_generator/duplicate_bind_name_files/expected/soup.ngDeps.dart'));
|
||||
|
||||
var output = formatter
|
||||
.format(await createNgSetters(reader, new AssetId('a', inputPath)));
|
||||
expect(output, equals(expected));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
library bar;
|
||||
|
||||
import 'bar.dart';
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(ToolTip, {
|
||||
'factory': () => new ToolTip(),
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Decorator(
|
||||
selector: '[tool-tip]', bind: const {'text': 'tool-tip'})
|
||||
]
|
||||
});
|
||||
}
|
||||
-7
@@ -8,13 +8,6 @@ void setupReflection(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(MyComponent, {
|
||||
'factory': () => new MyComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Component(selector: 'soup', services: const [ToolTip])
|
||||
]
|
||||
})
|
||||
..registerType(ToolTip, {
|
||||
'factory': () => new ToolTip(),
|
||||
'parameters': const [],
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
library dinner.soup;
|
||||
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
import 'soup.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(SoupComponent, {
|
||||
'factory': () => new SoupComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Component(
|
||||
componentServices: const [SaladComponent],
|
||||
bind: const {'menu': 'menu'})
|
||||
]
|
||||
})
|
||||
..registerType(SaladComponent, {
|
||||
'factory': () => new SaladComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(bind: const {'menu': 'menu'})]
|
||||
})
|
||||
..registerSetters({'menu': (o, String v) => o.menu = v});
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
library dinner.soup;
|
||||
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
import 'soup.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(SoupComponent, {
|
||||
'factory': () => new SoupComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Component(
|
||||
componentServices: const [SaladComponent],
|
||||
bind: const {'menu': 'menu'})
|
||||
]
|
||||
})
|
||||
..registerType(SaladComponent, {
|
||||
'factory': () => new SaladComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(bind: const {'menu': 'menu'})]
|
||||
});
|
||||
}
|
||||
@@ -93,14 +93,6 @@ void allTests() {
|
||||
outputs: {
|
||||
'a|web/bar.ngDeps.dart': 'two_annotations_files/expected/bar.ngDeps.dart'
|
||||
}),
|
||||
new IntegrationTestConfig('should generate setters for `bind` values.',
|
||||
inputs: {
|
||||
'a|web/index.dart': 'basic_bind_files/index.dart',
|
||||
'a|web/bar.dart': 'basic_bind_files/bar.dart'
|
||||
},
|
||||
outputs: {
|
||||
'a|web/bar.ngDeps.dart': 'basic_bind_files/expected/bar.ngDeps.dart'
|
||||
}),
|
||||
new IntegrationTestConfig(
|
||||
'should ensure that dependencies are property chained.',
|
||||
inputs: {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
library bar;
|
||||
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
@Component(selector: 'soup', services: const [ToolTip])
|
||||
class MyComponent {}
|
||||
|
||||
@Decorator(selector: '[tool-tip]', bind: const {'text': 'tool-tip'})
|
||||
class ToolTip {
|
||||
String text;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
library web_foo;
|
||||
|
||||
import 'package:angular2/src/core/application.dart';
|
||||
import 'package:angular2/src/reflection/reflection_capabilities.dart';
|
||||
import 'bar.dart';
|
||||
|
||||
void main() {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
bootstrap(MyComponent);
|
||||
}
|
||||
@@ -3,12 +3,14 @@ library angular2.test.transform;
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/vm_config.dart';
|
||||
|
||||
import 'bind_generator/all_tests.dart' as bindGenerator;
|
||||
import 'directive_processor/all_tests.dart' as directiveProcessor;
|
||||
import 'integration/all_tests.dart' as integration;
|
||||
import 'reflection_remover/all_tests.dart' as reflectionRemover;
|
||||
|
||||
main() {
|
||||
useVMConfiguration();
|
||||
group('Bind Generator', bindGenerator.allTests);
|
||||
group('Directive Processor', directiveProcessor.allTests);
|
||||
group('Reflection Remover', reflectionRemover.allTests);
|
||||
group('Transformer Pipeline', integration.allTests);
|
||||
|
||||
Reference in New Issue
Block a user