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

Side by Side Diff: third_party/pkg/angular/lib/mock/test_injection.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular.mock; 1 library angular.mock.test_injection;
2 2
3 import 'package:angular/application_factory.dart';
4 import 'package:angular/mock/module.dart';
5 import 'package:di/di.dart';
6 import 'package:di/dynamic_injector.dart';
7
3 _SpecInjector _currentSpecInjector = null; 8 _SpecInjector _currentSpecInjector = null;
4 9
5 class _SpecInjector { 10 class _SpecInjector {
6 DynamicInjector moduleInjector; 11 DynamicInjector moduleInjector;
7 DynamicInjector injector; 12 DynamicInjector injector;
8 dynamic injectiorCreateLocation; 13 dynamic injectiorCreateLocation;
9 final modules = <Module>[]; 14 final modules = <Module>[];
10 final initFns = <Function>[]; 15 final initFns = <Function>[];
11 16
12 _SpecInjector() { 17 _SpecInjector() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 injectiorCreateLocation = null; 66 injectiorCreateLocation = null;
62 } 67 }
63 } 68 }
64 69
65 /** 70 /**
66 * Allows the injection of instances into a test. See [module] on how to install new 71 * Allows the injection of instances into a test. See [module] on how to install new
67 * types into injector. 72 * types into injector.
68 * 73 *
69 * NOTE: Calling inject creates an injector, which prevents any more calls to [m odule]. 74 * NOTE: Calling inject creates an injector, which prevents any more calls to [m odule].
70 * 75 *
76 * NOTE: [inject] will never return the result of [fn]. If you need to return a [Future]
77 * for unittest to consume, take a look at [async], [clockTick], and [microLeap] instead.
78 *
71 * Typical usage: 79 * Typical usage:
72 * 80 *
73 * test('wrap whole test', inject((TestBed tb) { 81 * test('wrap whole test', inject((TestBed tb) {
74 * tb.compile(...); 82 * tb.compile(...);
75 * }); 83 * }));
76 * 84 *
77 * test('wrap part of a test', () { 85 * test('wrap part of a test', () {
78 * module((Module module) { 86 * module((Module module) {
79 * module.type(Foo); 87 * module.type(Foo);
80 * }); 88 * });
81 * inject((TestBed tb) { 89 * inject((TestBed tb) {
82 * tb.compile(...); 90 * tb.compile(...);
83 * }); 91 * });
84 * }); 92 * });
85 * 93 *
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 : _currentSpecInjector.module(fnOrModule, stack); 128 : _currentSpecInjector.module(fnOrModule, stack);
121 } 129 }
122 } 130 }
123 131
124 /** 132 /**
125 * Call this method in your test harness [setUp] method to setup the injector. 133 * Call this method in your test harness [setUp] method to setup the injector.
126 */ 134 */
127 void setUpInjector() { 135 void setUpInjector() {
128 _currentSpecInjector = new _SpecInjector(); 136 _currentSpecInjector = new _SpecInjector();
129 _currentSpecInjector.module((Module m) { 137 _currentSpecInjector.module((Module m) {
130 m..install(new AngularModule())..install(new AngularMockModule()); 138 m
139 ..install(applicationFactory().ngModule)
140 ..install(new AngularMockModule());
131 }); 141 });
132 } 142 }
133 143
134 /** 144 /**
135 * Call this method in your test harness [tearDown] method to cleanup the inject or. 145 * Call this method in your test harness [tearDown] method to cleanup the inject or.
136 */ 146 */
137 void tearDownInjector() { 147 void tearDownInjector() {
138 _currentSpecInjector = null; 148 _currentSpecInjector = null;
139 } 149 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/mock/test_bed.dart ('k') | third_party/pkg/angular/lib/mock/zone.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698