Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
Prepare for Angular's 3.0.0-beta. (#47)
Browse files Browse the repository at this point in the history
* Prepare for Angular beta.

* Fix pubspec.
  • Loading branch information
matanlurey authored Mar 29, 2017
1 parent 10d452c commit f5eb9ae
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.0.0-beta

- Prepare to support `angular2: 3.0.0-beta`.
- Replace all uses of generic comment with proper syntax.
- Fixed a bug where `activeTest` was never set (and therefore disposed).
- Fixed a bug where `pub`, not `pub.bat`, is run in windows.

## 1.0.0-alpha+6

- Address breaking changes in `angular2`: `3.0.0-alpha+1`.
Expand Down
4 changes: 3 additions & 1 deletion bin/angular_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'package:angular_test/src/bin/logging.dart';
import 'package:args/args.dart';
import 'package:path/path.dart' as p;

final _pubBin = Platform.isWindows ? 'pub.bat' : 'pub';

/// Runs all tests using `pub run test` in the specified directory.
///
/// Tests that require AoT code generation proxies through `pub serve`.
Expand All @@ -31,7 +33,7 @@ main(List<String> args) async {
}
var testsRunning = false;
// Run pub serve, and wait for significant messages.
final pubServeProcess = await Process.start('pub', const ['serve', 'test']);
final pubServeProcess = await Process.start(_pubBin, const ['serve', 'test']);
var stdoutFuture =
pubServeProcess.stdout.map(UTF8.decode).listen((message) async {
if (message.contains('Serving angular_testing')) {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import 'package:angular2/platform/browser_static.dart';
/// If [beforeChangeDetection] is specified, allows interacting with instance of
/// component created _before_ the initial change detection occurs; for example
/// setting up properties or state.
Future<ComponentRef> bootstrapForTest/*<E>*/(
Future<ComponentRef> bootstrapForTest<E>(
Type appComponentType,
Element hostElement, {
void beforeChangeDetection(component/*=E*/),
void beforeChangeDetection(E componentInstance),
List addProviders: const [],
}) {
if (appComponentType == null) {
Expand Down Expand Up @@ -65,12 +65,12 @@ Future<ComponentRef> bootstrapForTest/*<E>*/(
});
}

Future<ComponentRef> _runAndLoadComponent/*<E>*/(
Future<ComponentRef> _runAndLoadComponent<E>(
ApplicationRefImpl appRef,
Type appComponentType,
Element hostElement,
Injector appInjector, {
void beforeChangeDetection(component/*=E*/),
void beforeChangeDetection(E componentInstance),
}) async {
final DynamicComponentLoader loader = appInjector.get(DynamicComponentLoader);
final componentRef = await loader.load(
Expand Down
20 changes: 10 additions & 10 deletions lib/src/frontend/bed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import 'package:angular_test/src/frontend/stabilizer.dart';
NgTestFixture activeTest;

/// Returns a new [List] merging iterables [a] and [b].
List/*<E>*/ _concat/*<E>*/(Iterable/*<E>*/ a, Iterable/*<E>*/ b) {
return new List/*<E>*/ .from(a)..addAll(b);
List<E> _concat<E>(Iterable<E> a, Iterable<E> b) {
return new List<E>.from(a)..addAll(b);
}

/// If any [NgTestFixture] is currently executing, calls `dispose` on it.
Expand All @@ -33,22 +33,22 @@ Future<Null> disposeAnyRunningTest() async => activeTest?.dispose();
/// An alternative method for [NgTestBed.create] that allows a dynamic [type].
///
/// This is for compatibility reasons only and should not be used otherwise.
Future<NgTestFixture/*<T>*/ > createDynamicFixture/*<T>*/(
NgTestBed/*<T>*/ bed,
Future<NgTestFixture<T>> createDynamicFixture<T>(
NgTestBed<T> bed,
Type type, {
void beforeChangeDetection(T instance),
void beforeChangeDetection(T componentInstance),
}) {
return bed._createDynamic(type, beforeChangeDetection: beforeChangeDetection);
}

/// An alternative factory for [NgTestBed] that allows not typing `T`.
///
/// This is for compatibility reasons only and should not be used otherwise.
NgTestBed/*<T>*/ createDynamicTestBed/*<T>*/({
NgTestBed<T> createDynamicTestBed<T>({
Element host,
bool watchAngularLifecycle: true,
}) {
return new NgTestBed/*<T>*/ ._allowDynamicType(
return new NgTestBed<T>._allowDynamicType(
host: host,
watchAngularLifecycle: watchAngularLifecycle,
);
Expand Down Expand Up @@ -197,12 +197,12 @@ class NgTestBed<T> {
).then((componentRef) async {
_checkForActiveTest();
final allStabilizers = new NgTestStabilizer.all(
_stabilizers.map/*<NgTestStabilizer>*/((s) {
return componentRef.injector.get(s);
_stabilizers.map<NgTestStabilizer>((s) {
return componentRef.injector.get(s) as NgTestStabilizer;
}),
);
await allStabilizers.stabilize();
return new NgTestFixture(
return activeTest = new NgTestFixture(
componentRef.injector.get(ApplicationRef),
componentRef,
allStabilizers,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/frontend/fixture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import 'package:pageloader/html.dart';
/// Inject a service for [tokenOrType] from [fixture].
///
/// This is for compatibility reasons only and should not be used otherwise.
/*=T*/ injectFromFixture/*<T>*/(NgTestFixture fixture, tokenOrType) {
T injectFromFixture<T>(NgTestFixture fixture, tokenOrType) {
return fixture._rootComponentRef.injector.get(tokenOrType);
}

/// Returns the component instance backing [fixture].
///
/// This is for compatibility reasons only and should not be used otherwise.
/*=T*/ componentOfFixture/*<T>*/(NgTestFixture/*<T>*/ fixture) {
T componentOfFixture<T>(NgTestFixture<T> fixture) {
return fixture._rootComponentRef.instance;
}

Expand Down Expand Up @@ -54,9 +54,9 @@ class NgTestFixture<T> {
}

/// Return a page object representing [pageObjectType] from the DOM.
Future/*<T>*/ resolvePageObject/*<T>*/(Type pageObjectType) async {
Future<T> resolvePageObject<T>(Type pageObjectType) async {
await update();
return _pageLoader.getInstance/*<T>*/(pageObjectType);
return _pageLoader.getInstance<T>(pageObjectType);
}

/// A page loader instance representing this test fixture.
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: angular_test
author: Dart Team <[email protected]>
homepage: https://github.com/dart-lang/angular_test
description: Testing infrastructure for AngularDart
version: 1.0.0-alpha+6
version: 1.0.0-beta

environment:
sdk: '>=1.22.0 <2.0.0'
Expand All @@ -11,7 +11,7 @@ executables:
angular_test:

dependencies:
angular2: '3.0.0-alpha+1'
angular2: '^3.0.0-alpha+1'
ansicolor: '^0.0.9'
pageloader: '^2.2.5'

Expand Down

0 comments on commit f5eb9ae

Please sign in to comment.