2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2015-10-08 18:33:17 -04:00
|
|
|
/**
|
refactor(testing): remove wrapping of Jasmine functions (#9564)
Instead, the async function now determines whether it should return a promise
or instead call a done function parameter. Importing Jasmine functions
from `@angular/core/testing` is no longer necessary and is now deprecated.
Additionally, beforeEachProviders is also deprecated, as it is specific
to the testing framework. Instead, use the new addProviders method directly.
Before:
```js
import {beforeEachProviders, it, describe, inject} from 'angular2/testing/core';
describe('my code', () => {
beforeEachProviders(() => [MyService]);
it('does stuff', inject([MyService], (service) => {
// actual test
});
});
```
After:
```js
import {addProviders, inject} from 'angular2/testing/core';
describe('my code', () => {
beforeEach(() => {
addProviders([MyService]);
});
it('does stuff', inject([MyService], (service) => {
// actual test
});
});
```
2016-06-24 20:48:35 -04:00
|
|
|
* Public Test Library for unit testing Angular2 Applications. Assumes that you are running
|
|
|
|
* with Jasmine, Mocha, or a similar framework which exports a beforeEach function and
|
|
|
|
* allows tests to be asynchronous by either returning a promise or using a 'done' parameter.
|
2015-10-08 18:33:17 -04:00
|
|
|
*/
|
|
|
|
|
2016-08-02 07:45:15 -04:00
|
|
|
import {resetFakeAsyncZone} from './fake_async';
|
2016-08-15 22:37:42 -04:00
|
|
|
import {TestBed} from './test_bed';
|
2015-10-08 18:33:17 -04:00
|
|
|
|
2016-06-15 12:37:33 -04:00
|
|
|
declare var global: any;
|
2015-10-08 18:33:17 -04:00
|
|
|
|
2016-11-12 08:08:58 -05:00
|
|
|
const _global = <any>(typeof window === 'undefined' ? global : window);
|
2015-10-08 18:33:17 -04:00
|
|
|
|
2016-08-02 07:45:15 -04:00
|
|
|
// Reset the test providers and the fake async zone before each test.
|
refactor(testing): remove wrapping of Jasmine functions (#9564)
Instead, the async function now determines whether it should return a promise
or instead call a done function parameter. Importing Jasmine functions
from `@angular/core/testing` is no longer necessary and is now deprecated.
Additionally, beforeEachProviders is also deprecated, as it is specific
to the testing framework. Instead, use the new addProviders method directly.
Before:
```js
import {beforeEachProviders, it, describe, inject} from 'angular2/testing/core';
describe('my code', () => {
beforeEachProviders(() => [MyService]);
it('does stuff', inject([MyService], (service) => {
// actual test
});
});
```
After:
```js
import {addProviders, inject} from 'angular2/testing/core';
describe('my code', () => {
beforeEach(() => {
addProviders([MyService]);
});
it('does stuff', inject([MyService], (service) => {
// actual test
});
});
```
2016-06-24 20:48:35 -04:00
|
|
|
if (_global.beforeEach) {
|
2016-08-02 07:45:15 -04:00
|
|
|
_global.beforeEach(() => {
|
|
|
|
TestBed.resetTestingModule();
|
|
|
|
resetFakeAsyncZone();
|
|
|
|
});
|
2015-10-08 18:33:17 -04:00
|
|
|
}
|
|
|
|
|
2016-08-16 00:40:37 -04:00
|
|
|
// TODO(juliemr): remove this, only used because we need to export something to have compilation
|
|
|
|
// work.
|
|
|
|
export var __core_private_testing_placeholder__ = '';
|