feat(tests): add a test injector

fixes #614

Asynchronous test should inject an AsyncTestCompleter:

Before:

  it("async test", (done) => {
    // ...
    done();
  });

After:

  it("async test", inject([AsyncTestCompleter], (async) => {
    // ...
    async.done();
  }));

Note: inject() is currently a function and the first parameter is the
array of DI tokens to inject as the test function parameters. This
construct is linked to Traceur limitations. The planned syntax is:

  it("async test", @Inject (async: AsyncTestCompleter) => {
    // ...
    async.done();
  });
This commit is contained in:
Victor Berchet
2015-03-13 11:10:11 +01:00
parent 5926d2e2f7
commit 33b5ba863e
29 changed files with 1241 additions and 640 deletions

View File

@ -1,4 +1,15 @@
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/test_lib';
import {
afterEach,
AsyncTestCompleter,
beforeEach,
ddescribe,
describe,
expect,
iit,
inject,
it,
xit,
} from 'angular2/test_lib';
import { StringMap, ListWrapper } from 'angular2/src/facade/collection';
import { isPresent, StringWrapper } from 'angular2/src/facade/lang';
@ -17,22 +28,22 @@ export function main() {
describe('WebDriverExtension.bindTo', () => {
it('should bind the extension that matches the capabilities', (done) => {
it('should bind the extension that matches the capabilities', inject([AsyncTestCompleter], (async) => {
createExtension(['m1', 'm2', 'm3'], {'browser': 'm2'}).then( (m) => {
expect(m.id).toEqual('m2');
done();
async.done();
});
});
}));
it('should throw if there is no match', (done) => {
it('should throw if there is no match', inject([AsyncTestCompleter], (async) => {
PromiseWrapper.catchError(
createExtension(['m1'], {'browser': 'm2'}),
(err) => {
expect(isPresent(err)).toBe(true);
done();
async.done();
}
);
});
}));
});
}