Skip to content

Commit 329b2ed

Browse files
Tim Blasimhevery
authored andcommitted
refactor(dart/transform tests): Use actual directive def'n instead of mock.
In the transformer unit tests, we previously used a mock directive annotation. This update substitutes the actual Angular2 directive annotations. Closes angular#706
1 parent 85211f0 commit 329b2ed

File tree

18 files changed

+53
-91
lines changed

18 files changed

+53
-91
lines changed

modules/angular2/src/transform/codegen.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ abstract class _TransformVisitor extends ToSourceVisitor {
224224
}
225225
}
226226

227+
@override
228+
Object visitPrefixedIdentifier(PrefixedIdentifier node) {
229+
// We add our own prefixes in [visitSimpleIdentifier], discard any used in
230+
// the original source.
231+
_visitNode(node.identifier);
232+
return null;
233+
}
234+
227235
@override
228236
Object visitSimpleIdentifier(SimpleIdentifier node) {
229237
// Make sure the identifier is prefixed if necessary.
@@ -281,6 +289,7 @@ class _CtorTransformVisitor extends _TransformVisitor {
281289
@override
282290
Object visitDefaultFormalParameter(DefaultFormalParameter node) {
283291
_visitNode(node.parameter);
292+
// Ignore the declared default value.
284293
return null;
285294
}
286295

modules/angular2/test/transform/common.dart

Lines changed: 0 additions & 11 deletions
This file was deleted.

modules/angular2/test/transform/ctor_with_default_value_files/bar.dart

Lines changed: 0 additions & 9 deletions
This file was deleted.

modules/angular2/test/transform/ctor_with_default_value_files/expected/index.bootstrap.dart

Lines changed: 0 additions & 14 deletions
This file was deleted.

modules/angular2/test/transform/ctor_with_default_value_files/index.dart

Lines changed: 0 additions & 7 deletions
This file was deleted.

modules/angular2/test/transform/list_of_types_files/bar.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ library bar;
33
import 'package:angular2/src/core/annotations/annotations.dart';
44
import 'foo.dart';
55

6-
@Directive(context: const [MyContext])
7-
class Component {
6+
@Component(componentServices: const [MyContext])
7+
class MyComponent {
88
final MyContext c;
9-
Component(this.c);
9+
MyComponent(this.c);
1010
}

modules/angular2/test/transform/list_of_types_files/expected/index.bootstrap.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import 'index.dart' as i3;
66

77
main() {
88
reflector
9-
..registerType(i0.Component, {
10-
"factory": (i1.MyContext c) => new i0.Component(c),
9+
..registerType(i0.MyComponent, {
10+
"factory": (i1.MyContext c) => new i0.MyComponent(c),
1111
"parameters": const [const [i1.MyContext]],
12-
"annotations": const [const i2.Directive(context: const [i1.MyContext])]
12+
"annotations": const [
13+
const i2.Component(componentServices: const [i1.MyContext])
14+
]
1315
});
1416
i3.main();
1517
}

modules/angular2/test/transform/simple_annotation_files/bar.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library bar;
22

33
import 'package:angular2/src/core/annotations/annotations.dart';
44

5-
@Directive(context: 'soup')
6-
class Component {
7-
Component();
5+
@Component(selector: '[soup]')
6+
class MyComponent {
7+
MyComponent();
88
}

modules/angular2/test/transform/simple_annotation_files/expected/index.bootstrap.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import 'index.dart' as i2;
55

66
main() {
77
reflector
8-
..registerType(i0.Component, {
9-
"factory": () => new i0.Component(),
8+
..registerType(i0.MyComponent, {
9+
"factory": () => new i0.MyComponent(),
1010
"parameters": const [const []],
11-
"annotations": const [const i1.Directive(context: 'soup')]
11+
"annotations": const [const i1.Component(selector: '[soup]')]
1212
});
1313
i2.main();
1414
}

modules/angular2/test/transform/simple_annotation_files/index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ library web_foo;
33
import 'bar.dart';
44

55
void main() {
6-
new Component('Things');
6+
new MyComponent('Things');
77
}

0 commit comments

Comments
 (0)