chore(test): add config for `pub serve` testing.

Closes #5580

Closes #5580
This commit is contained in:
Kevin Moore 2015-12-03 12:00:10 -08:00 committed by Jeremy Elbourn
parent 1710272b3c
commit 1edb17b8d0
3 changed files with 14 additions and 5 deletions

View File

@ -54,7 +54,6 @@ void setUpProviders(Iterable<Provider> providerFactory()) {
}); });
} }
dynamic _runInjectableFunction(Function fn) { dynamic _runInjectableFunction(Function fn) {
var params = reflector.parameters(fn); var params = reflector.parameters(fn);
List<dynamic> tokens = <dynamic>[]; List<dynamic> tokens = <dynamic>[];
@ -111,8 +110,10 @@ void ngTest(String description, Function fn,
}, testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform); }, testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform);
} }
final _providersExpando = new Expando<List<Provider>>('Providers for the current test'); final _providersExpando =
final _injectorExpando = new Expando<Injector>('Angular Injector for the current test'); new Expando<List<Provider>>('Providers for the current test');
final _injectorExpando =
new Expando<Injector>('Angular Injector for the current test');
List get _currentTestProviders { List get _currentTestProviders {
if (_providersExpando[_currentTest] == null) { if (_providersExpando[_currentTest] == null) {
@ -120,6 +121,7 @@ List get _currentTestProviders {
} }
return _providersExpando[_currentTest]; return _providersExpando[_currentTest];
} }
Injector get _currentInjector => _injectorExpando[_currentTest]; Injector get _currentInjector => _injectorExpando[_currentTest];
void set _currentInjector(Injector newInjector) { void set _currentInjector(Injector newInjector) {
_injectorExpando[_currentTest] = newInjector; _injectorExpando[_currentTest] = newInjector;

View File

@ -6,3 +6,8 @@ dependencies:
path: ../../dist/dart/angular2 path: ../../dist/dart/angular2
dev_dependencies: dev_dependencies:
test: '^0.12.6' test: '^0.12.6'
transformers:
# Allows testing with `pub serve`
# See https://github.com/dart-lang/test#testing-with-barback
- test/pub_serve:
$include: test/**_test.dart

View File

@ -41,7 +41,8 @@ void main() {
expect(string.split(','), equals(['foo', 'bar', 'baz'])); expect(string.split(','), equals(['foo', 'bar', 'baz']));
}); });
ngTest('can grab injected values', (@Inject(MyToken) token, TestService testService) { ngTest('can grab injected values',
(@Inject(MyToken) token, TestService testService) {
expect(token, equals('my string')); expect(token, equals('my string'));
expect(testService.status, equals('not ready')); expect(testService.status, equals('not ready'));
}); });
@ -56,7 +57,8 @@ void main() {
}); });
}); });
ngTest('create a component using the TestComponentBuilder', (TestComponentBuilder tcb) async { ngTest('create a component using the TestComponentBuilder',
(TestComponentBuilder tcb) async {
var rootTC = await tcb var rootTC = await tcb
.overrideTemplate(TestComponent, TEMPLATE) .overrideTemplate(TestComponent, TEMPLATE)
.createAsync(TestComponent); .createAsync(TestComponent);