With these changes, the types are a little stricter now and also not
compatible with Protractor's jasmine-like syntax. So, we have to also
use `@types/jasminewd2` for e2e tests (but not for non-e2e tests).
I also had to "augment" `@types/jasminewd2`, because the latest
typings from [DefinitelyTyped][1] do not reflect the fact that the
`jasminewd2` version (v2.1.0) currently used by Protractor supports
passing a `done` callback to a spec.
[1]: 566e039485/types/jasminewd2/index.d.ts (L9-L15)
Fixes #23952
Closes #24733
PR Close #19904
		
	
			
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
/**
 | 
						|
 * @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
 | 
						|
 */
 | 
						|
 | 
						|
import {fakeAsync, tick} from '@angular/core/testing';
 | 
						|
import {SpyNgModuleFactoryLoader} from '../testing/src/router_testing_module';
 | 
						|
 | 
						|
describe('SpyNgModuleFactoryLoader', () => {
 | 
						|
  it('should invoke the compiler when the setter is called', () => {
 | 
						|
    const expected = Promise.resolve('returned');
 | 
						|
    const compiler: any = {compileModuleAsync: () => {}};
 | 
						|
    spyOn(compiler, 'compileModuleAsync').and.returnValue(expected);
 | 
						|
 | 
						|
    const r = new SpyNgModuleFactoryLoader(<any>compiler);
 | 
						|
    r.stubbedModules = {'one': 'someModule'};
 | 
						|
 | 
						|
    expect(compiler.compileModuleAsync).toHaveBeenCalledWith('someModule');
 | 
						|
    expect(r.stubbedModules['one']).toBe(expected);
 | 
						|
  });
 | 
						|
 | 
						|
  it('should return the created promise', () => {
 | 
						|
    const expected: any = Promise.resolve('returned');
 | 
						|
    const compiler: any = {compileModuleAsync: () => expected};
 | 
						|
 | 
						|
    const r = new SpyNgModuleFactoryLoader(<any>compiler);
 | 
						|
    r.stubbedModules = {'one': 'someModule'};
 | 
						|
 | 
						|
    expect(r.load('one')).toBe(expected);
 | 
						|
  });
 | 
						|
 | 
						|
  it('should return a rejected promise when given an invalid path', fakeAsync(() => {
 | 
						|
       const r = new SpyNgModuleFactoryLoader(<any>null);
 | 
						|
 | 
						|
       let error: any = null;
 | 
						|
       r.load('two').catch((e: any) => error = e);
 | 
						|
 | 
						|
       tick();
 | 
						|
 | 
						|
       expect(error).toEqual(new Error('Cannot find module two'));
 | 
						|
     }));
 | 
						|
});
 |