Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: third_party/pkg/angular/test/core_dom/block_spec.dart

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/core_dom/block_spec.dart
diff --git a/third_party/pkg/angular/test/core_dom/block_spec.dart b/third_party/pkg/angular/test/core_dom/block_spec.dart
index e5a08bcc731526d7994a80063f582d714c02b87c..3c7559fc4cf8303560e3a95af3c1289e139bca1f 100644
--- a/third_party/pkg/angular/test/core_dom/block_spec.dart
+++ b/third_party/pkg/angular/test/core_dom/block_spec.dart
@@ -2,6 +2,12 @@ library block_spec;
import '../_specs.dart';
+class Log {
+ List<String> log = <String>[];
+
+ add(String msg) => log.add(msg);
+}
+
@NgDirective(children: NgAnnotation.TRANSCLUDE_CHILDREN, selector: 'foo')
class LoggerBlockDirective {
LoggerBlockDirective(BlockHole hole, BlockFactory blockFactory,
@@ -16,24 +22,43 @@ class LoggerBlockDirective {
}
}
-class ReplaceBlockDirective {
- ReplaceBlockDirective(BlockHole hole, BoundBlockFactory boundBlockFactory, Node node, Scope scope) {
- var block = boundBlockFactory(scope);
- block.insertAfter(hole);
- node.remove();
+@NgDirective(selector: 'dir-a')
+class ADirective {
+ ADirective(Log log) {
+ log.add('ADirective');
+ }
+}
+
+@NgDirective(selector: 'dir-b')
+class BDirective {
+ BDirective(Log log) {
+ log.add('BDirective');
+ }
+}
+
+@NgFilter(name:'filterA')
+class AFilter {
+ Log log;
+
+ AFilter(this.log) {
+ log.add('AFilter');
}
+
+ call(value) => value;
}
-class ShadowBlockDirective {
- ShadowBlockDirective(BlockHole hole, BoundBlockFactory boundBlockFactory, Element element, Scope scope) {
- var block = boundBlockFactory(scope);
- var shadowRoot = element.createShadowRoot();
- for (var i = 0, ii = block.elements.length; i < ii; i++) {
- shadowRoot.append(block.elements[i]);
- }
+@NgFilter(name:'filterB')
+class BFilter {
+ Log log;
+
+ BFilter(this.log) {
+ log.add('BFilter');
}
+
+ call(value) => value;
}
+
main() {
describe('Block', () {
var anchor;
@@ -201,6 +226,44 @@ main() {
});
});
+ describe('deferred', () {
+
+ it('should load directives/filters from the child injector', () {
+ Module rootModule = new Module()
+ ..type(Probe)
+ ..type(Log)
+ ..type(AFilter)
+ ..type(ADirective);
+
+ Injector rootInjector =
+ new DynamicInjector(modules: [new AngularModule(), rootModule]);
+ Log log = rootInjector.get(Log);
+ Scope rootScope = rootInjector.get(Scope);
+
+ Compiler compiler = rootInjector.get(Compiler);
+ DirectiveMap directives = rootInjector.get(DirectiveMap);
+ compiler(es('<dir-a>{{\'a\' | filterA}}</dir-a><dir-b></dir-b>'), directives)(rootInjector);
+ rootScope.apply();
+
+ expect(log.log, equals(['ADirective', 'AFilter']));
+
+
+ Module childModule = new Module()
+ ..type(BFilter)
+ ..type(BDirective);
+
+ var childInjector = forceNewDirectivesAndFilters(rootInjector, [childModule]);
+
+ DirectiveMap newDirectives = childInjector.get(DirectiveMap);
+ compiler(es('<dir-a probe="dirA"></dir-a>{{\'a\' | filterA}}'
+ '<dir-b probe="dirB"></dir-b>{{\'b\' | filterB}}'), newDirectives)(childInjector);
+ rootScope.apply();
+
+ expect(log.log, equals(['ADirective', 'AFilter', 'ADirective', 'BDirective', 'BFilter']));
+ });
+
+ });
+
//TODO: tests for attach/detach
//TODO: animation/transitions
//TODO: tests for re-usability of blocks

Powered by Google App Engine
This is Rietveld 408576698