build: upgrade jasmine (and related typings) to latest version (#19904)
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
This commit is contained in:

committed by
Miško Hevery

parent
1e74ea9e60
commit
00c110b055
@ -210,7 +210,7 @@ describe('bootstrap', () => {
|
||||
|
||||
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
|
||||
const router = res.injector.get(Router);
|
||||
spyOn(router, 'resetRootComponentType').and.callThrough();
|
||||
spyOn(router as any, 'resetRootComponentType').and.callThrough();
|
||||
|
||||
const appRef: ApplicationRef = res.injector.get(ApplicationRef);
|
||||
appRef.bootstrap(SecondRootCmp);
|
||||
@ -236,7 +236,7 @@ describe('bootstrap', () => {
|
||||
|
||||
platformBrowserDynamic([]).bootstrapModule(TestModule).then(res => {
|
||||
const router = res.injector.get(Router);
|
||||
spyOn(router, 'resetRootComponentType').and.callThrough();
|
||||
spyOn(router as any, 'resetRootComponentType').and.callThrough();
|
||||
|
||||
const appRef: ApplicationRef = res.injector.get(ApplicationRef);
|
||||
appRef.components[0].onDestroy(() => {
|
||||
|
@ -131,7 +131,7 @@ function checkActivatedRoute(
|
||||
if (actual === null) {
|
||||
expect(actual).toBeDefined();
|
||||
} else {
|
||||
expect(actual.component).toBe(cmp);
|
||||
expect(actual.component as any).toBe(cmp);
|
||||
expect(actual.outlet).toEqual(outlet);
|
||||
}
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ function checkActivatedRoute(
|
||||
} else {
|
||||
expect(actual.url.map(s => s.path).join('/')).toEqual(url);
|
||||
expect(actual.params).toEqual(params);
|
||||
expect(actual.component).toBe(cmp);
|
||||
expect(actual.component as any).toBe(cmp);
|
||||
expect(actual.outlet).toEqual(outlet);
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,12 @@
|
||||
import {Location} from '@angular/common';
|
||||
import {TestBed, inject} from '@angular/core/testing';
|
||||
|
||||
import {ResolveData} from '../src/config';
|
||||
import {Routes} from '../src/config';
|
||||
import {ChildActivationStart} from '../src/events';
|
||||
import {PreActivation} from '../src/pre_activation';
|
||||
import {Router} from '../src/router';
|
||||
import {ChildrenOutletContexts} from '../src/router_outlet_context';
|
||||
import {ActivatedRouteSnapshot, RouterStateSnapshot, createEmptyStateSnapshot} from '../src/router_state';
|
||||
import {RouterStateSnapshot, createEmptyStateSnapshot} from '../src/router_state';
|
||||
import {DefaultUrlSerializer} from '../src/url_tree';
|
||||
import {TreeNode} from '../src/utils/tree';
|
||||
import {RouterTestingModule} from '../testing/src/router_testing_module';
|
||||
@ -30,14 +30,17 @@ describe('Router', () => {
|
||||
|
||||
it('should copy config to avoid mutations of user-provided objects', () => {
|
||||
const r: Router = TestBed.get(Router);
|
||||
const configs = [{
|
||||
const configs: Routes = [{
|
||||
path: 'a',
|
||||
component: TestComponent,
|
||||
children: [{path: 'b', component: TestComponent}, {path: 'c', component: TestComponent}]
|
||||
}];
|
||||
const children = configs[0].children !;
|
||||
|
||||
r.resetConfig(configs);
|
||||
|
||||
let rConfigs = r.config;
|
||||
const rConfigs = r.config;
|
||||
const rChildren = rConfigs[0].children !;
|
||||
|
||||
// routes array and shallow copy
|
||||
expect(configs).not.toBe(rConfigs);
|
||||
@ -46,11 +49,11 @@ describe('Router', () => {
|
||||
expect(configs[0].component).toBe(rConfigs[0].component);
|
||||
|
||||
// children should be new array and routes shallow copied
|
||||
expect(configs[0].children).not.toBe(rConfigs[0].children);
|
||||
expect(configs[0].children[0]).not.toBe(rConfigs[0].children ![0]);
|
||||
expect(configs[0].children[0].path).toBe(rConfigs[0].children ![0].path);
|
||||
expect(configs[0].children[1]).not.toBe(rConfigs[0].children ![1]);
|
||||
expect(configs[0].children[1].path).toBe(rConfigs[0].children ![1].path);
|
||||
expect(children).not.toBe(rChildren);
|
||||
expect(children[0]).not.toBe(rChildren[0]);
|
||||
expect(children[0].path).toBe(rChildren[0].path);
|
||||
expect(children[1]).not.toBe(rChildren[1]);
|
||||
expect(children[1].path).toBe(rChildren[1].path);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -125,41 +125,41 @@ describe('RouterState & Snapshot', () => {
|
||||
}
|
||||
|
||||
it('should return false when params are different', () => {
|
||||
expect(equalParamsAndUrlSegments(createSnapshot({a: 1}, []), createSnapshot({a: 2}, [])))
|
||||
expect(equalParamsAndUrlSegments(createSnapshot({a: '1'}, []), createSnapshot({a: '2'}, [])))
|
||||
.toEqual(false);
|
||||
});
|
||||
|
||||
it('should return false when urls are different', () => {
|
||||
expect(equalParamsAndUrlSegments(
|
||||
createSnapshot({a: 1}, [new UrlSegment('a', {})]),
|
||||
createSnapshot({a: 1}, [new UrlSegment('b', {})])))
|
||||
createSnapshot({a: '1'}, [new UrlSegment('a', {})]),
|
||||
createSnapshot({a: '1'}, [new UrlSegment('b', {})])))
|
||||
.toEqual(false);
|
||||
});
|
||||
|
||||
it('should return true othewise', () => {
|
||||
expect(equalParamsAndUrlSegments(
|
||||
createSnapshot({a: 1}, [new UrlSegment('a', {})]),
|
||||
createSnapshot({a: 1}, [new UrlSegment('a', {})])))
|
||||
createSnapshot({a: '1'}, [new UrlSegment('a', {})]),
|
||||
createSnapshot({a: '1'}, [new UrlSegment('a', {})])))
|
||||
.toEqual(true);
|
||||
});
|
||||
|
||||
it('should return false when upstream params are different', () => {
|
||||
const [snapshot1, snapshot2] =
|
||||
createSnapshotPairWithParent([{a: 1}, {a: 1}], [{b: 1}, {c: 1}], ['a', 'a']);
|
||||
createSnapshotPairWithParent([{a: '1'}, {a: '1'}], [{b: '1'}, {c: '1'}], ['a', 'a']);
|
||||
|
||||
expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(false);
|
||||
});
|
||||
|
||||
it('should return false when upstream urls are different', () => {
|
||||
const [snapshot1, snapshot2] =
|
||||
createSnapshotPairWithParent([{a: 1}, {a: 1}], [{b: 1}, {b: 1}], ['a', 'b']);
|
||||
createSnapshotPairWithParent([{a: '1'}, {a: '1'}], [{b: '1'}, {b: '1'}], ['a', 'b']);
|
||||
|
||||
expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(false);
|
||||
});
|
||||
|
||||
it('should return true when upstream urls and params are equal', () => {
|
||||
const [snapshot1, snapshot2] =
|
||||
createSnapshotPairWithParent([{a: 1}, {a: 1}], [{b: 1}, {b: 1}], ['a', 'a']);
|
||||
createSnapshotPairWithParent([{a: '1'}, {a: '1'}], [{b: '1'}, {b: '1'}], ['a', 'a']);
|
||||
|
||||
expect(equalParamsAndUrlSegments(snapshot1, snapshot2)).toEqual(true);
|
||||
});
|
||||
@ -184,8 +184,8 @@ describe('RouterState & Snapshot', () => {
|
||||
}
|
||||
|
||||
it('should call change observers', () => {
|
||||
const firstPlace = createSnapshot({a: 1}, []);
|
||||
const secondPlace = createSnapshot({a: 2}, []);
|
||||
const firstPlace = createSnapshot({a: '1'}, []);
|
||||
const secondPlace = createSnapshot({a: '2'}, []);
|
||||
route.snapshot = firstPlace;
|
||||
(route as any)._futureSnapshot = secondPlace;
|
||||
|
||||
|
@ -23,7 +23,7 @@ describe('SpyNgModuleFactoryLoader', () => {
|
||||
});
|
||||
|
||||
it('should return the created promise', () => {
|
||||
const expected = Promise.resolve('returned');
|
||||
const expected: any = Promise.resolve('returned');
|
||||
const compiler: any = {compileModuleAsync: () => expected};
|
||||
|
||||
const r = new SpyNgModuleFactoryLoader(<any>compiler);
|
||||
|
Reference in New Issue
Block a user