| 
									
										
										
										
											2016-06-23 09:47:54 -07: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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-11 16:04:32 -07:00
										 |  |  | import {XHR} from '@angular/compiler'; | 
					
						
							|  |  |  | import {Component, bind} from '@angular/core'; | 
					
						
							|  |  |  | import {TestComponentBuilder, addProviders, async, fakeAsync, flushMicrotasks, inject, tick} from '@angular/core/testing'; | 
					
						
							| 
									
										
										
										
											2016-06-20 08:09:16 -07:00
										 |  |  | import {ROUTER_DIRECTIVES, Route} from '@angular/router-deprecated'; | 
					
						
							| 
									
										
										
										
											2016-04-26 20:51:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | import {PromiseWrapper} from '../src/facade/promise'; | 
					
						
							| 
									
										
										
										
											2016-05-19 14:31:21 -07:00
										 |  |  | import {XHRImpl} from '../src/xhr/xhr_impl'; | 
					
						
							| 
									
										
										
										
											2016-07-11 16:04:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Components for the tests.
 | 
					
						
							|  |  |  | class FancyService { | 
					
						
							|  |  |  |   value: string = 'real value'; | 
					
						
							|  |  |  |   getAsyncValue() { return Promise.resolve('async value'); } | 
					
						
							|  |  |  |   getTimeoutValue() { | 
					
						
							| 
									
										
										
										
											2016-07-21 17:12:00 -07:00
										 |  |  |     return new Promise( | 
					
						
							|  |  |  |         (resolve, reject) => { setTimeout(() => { resolve('timeout value'); }, 10); }); | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'external-template-comp', | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  |   templateUrl: '/base/modules/@angular/platform-browser/test/static_assets/test.html' | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  | }) | 
					
						
							|  |  |  | class ExternalTemplateComp { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({selector: 'bad-template-comp', templateUrl: 'non-existant.html'}) | 
					
						
							|  |  |  | class BadTemplateUrl { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-26 20:51:10 -07:00
										 |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'test-router-cmp', | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |   template: | 
					
						
							|  |  |  |       `<a [routerLink]="['One']">one</a> <a [routerLink]="['Two']">two</a><router-outlet></router-outlet>`, | 
					
						
							| 
									
										
										
										
											2016-04-26 20:51:10 -07:00
										 |  |  |   directives: [ROUTER_DIRECTIVES] | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | class TestRouterComponent { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  | // Tests for angular2/testing bundle specific to the browser environment.
 | 
					
						
							|  |  |  | // For general tests, see test/testing/testing_public_spec.ts.
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('test APIs for the browser', () => { | 
					
						
							|  |  |  |     describe('using the async helper', () => { | 
					
						
							|  |  |  |       var actuallyDone: boolean; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       beforeEach(() => { actuallyDone = false; }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       afterEach(() => { expect(actuallyDone).toEqual(true); }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should run async tests with XHRs', async(() => { | 
					
						
							|  |  |  |            var xhr = new XHRImpl(); | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  |            xhr.get('/base/modules/@angular/platform-browser/test/static_assets/test.html') | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  |                .then(() => { actuallyDone = true; }); | 
					
						
							|  |  |  |          }), | 
					
						
							|  |  |  |          10000);  // Long timeout here because this test makes an actual XHR.
 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     describe('using the test injector with the inject helper', () => { | 
					
						
							|  |  |  |       describe('setting up Providers', () => { | 
					
						
							| 
									
										
										
										
											2016-07-11 16:04:32 -07:00
										 |  |  |         beforeEach(() => addProviders([{provide: FancyService, useValue: new FancyService()}])); | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         it('provides a real XHR instance', | 
					
						
							| 
									
										
										
										
											2016-07-11 16:04:32 -07:00
										 |  |  |            inject([XHR], (xhr: XHR) => { expect(xhr instanceof XHRImpl).toBeTruthy(); })); | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |         it('should allow the use of fakeAsync', | 
					
						
							|  |  |  |            fakeAsync(inject([FancyService], (service: any /** TODO #9100 */) => { | 
					
						
							| 
									
										
										
										
											2016-06-08 15:45:15 -07:00
										 |  |  |              var value: any /** TODO #9100 */; | 
					
						
							|  |  |  |              service.getAsyncValue().then(function(val: any /** TODO #9100 */) { value = val; }); | 
					
						
							| 
									
										
										
										
											2016-04-18 16:04:35 -07:00
										 |  |  |              tick(); | 
					
						
							|  |  |  |              expect(value).toEqual('async value'); | 
					
						
							|  |  |  |            }))); | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     describe('errors', () => { | 
					
						
							|  |  |  |       var originalJasmineIt: any; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       var patchJasmineIt = () => { | 
					
						
							|  |  |  |         var deferred = PromiseWrapper.completer(); | 
					
						
							|  |  |  |         originalJasmineIt = jasmine.getEnv().it; | 
					
						
							| 
									
										
										
										
											2016-06-08 15:45:15 -07:00
										 |  |  |         jasmine.getEnv().it = (description: string, fn: any /** TODO #9100 */) => { | 
					
						
							| 
									
										
										
										
											2016-07-21 17:12:00 -07:00
										 |  |  |           var done = () => { deferred.resolve(); }; | 
					
						
							|  |  |  |           (<any>done).fail = (err: any /** TODO #9100 */) => { deferred.reject(err); }; | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  |           fn(done); | 
					
						
							|  |  |  |           return null; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |         return deferred.promise; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       var restoreJasmineIt = () => { jasmine.getEnv().it = originalJasmineIt; }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 15:45:15 -07:00
										 |  |  |       it('should fail when an XHR fails', (done: any /** TODO #9100 */) => { | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  |         var itPromise = patchJasmineIt(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it('should fail with an error from a promise', | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |            async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { | 
					
						
							|  |  |  |              return tcb.createAsync(BadTemplateUrl); | 
					
						
							|  |  |  |            }))); | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |         itPromise.then( | 
					
						
							|  |  |  |             () => { done.fail('Expected test to fail, but it did not'); }, | 
					
						
							|  |  |  |             (err) => { | 
					
						
							| 
									
										
										
										
											2016-06-20 17:54:12 -07:00
										 |  |  |               expect(err.message) | 
					
						
							|  |  |  |                   .toEqual('Uncaught (in promise): Failed to load non-existant.html'); | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |               done(); | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  |         restoreJasmineIt(); | 
					
						
							|  |  |  |       }, 10000); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     describe('test component builder', function() { | 
					
						
							|  |  |  |       it('should allow an external templateUrl', | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |          async(inject( | 
					
						
							|  |  |  |              [TestComponentBuilder], | 
					
						
							|  |  |  |              (tcb: TestComponentBuilder) => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                tcb.createAsync(ExternalTemplateComp).then((componentFixture) => { | 
					
						
							|  |  |  |                  componentFixture.detectChanges(); | 
					
						
							| 
									
										
										
										
											2016-07-11 16:04:32 -07:00
										 |  |  |                  expect(componentFixture.debugElement.nativeElement.textContent) | 
					
						
							|  |  |  |                      .toEqual('from external template\n'); | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  |                }); | 
					
						
							|  |  |  |              })), | 
					
						
							| 
									
										
											  
											
												feat(tests): manage asynchronous tests using zones
Instead of using injectAsync and returning a promise, use the `async` function
to wrap tests. This will run the test inside a zone which does not complete
the test until all asynchronous tasks have been completed.
`async` may be used with the `inject` function, or separately.
BREAKING CHANGE:
`injectAsync` is now deprecated. Instead, use the `async` function
to wrap any asynchronous tests.
Before:
```
it('should wait for returned promises', injectAsync([FancyService], (service) => {
  return service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
}));
it('should wait for returned promises', injectAsync([], () => {
  return somePromise.then(() => { expect(true).toEqual(true); });
}));
```
After:
```
it('should wait for returned promises', async(inject([FancyService], (service) => {
  service.getAsyncValue().then((value) => { expect(value).toEqual('async value'); });
})));
// Note that if there is no injection, we no longer need `inject` OR `injectAsync`.
it('should wait for returned promises', async(() => {
  somePromise.then() => { expect(true).toEqual(true); });
}));
```
Closes #7735
											
										 
											2016-03-23 10:59:38 -07:00
										 |  |  |          10000);  // Long timeout here because this test makes an actual XHR, and is slow on Edge.
 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |