Skip to content

Commit d65c188

Browse files
build(ngrx.io): update to Angular 16 (#3871)
1 parent 985d80c commit d65c188

14 files changed

+2968
-2528
lines changed

projects/ngrx.io/package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,33 @@
7575
},
7676
"private": true,
7777
"dependencies": {
78-
"@angular/animations": "15.0.4",
79-
"@angular/cdk": "15.0.3",
80-
"@angular/common": "15.0.4",
81-
"@angular/core": "15.0.4",
82-
"@angular/elements": "15.0.4",
78+
"@angular/animations": "16.0.0",
79+
"@angular/cdk": "16.0.0",
80+
"@angular/common": "16.0.0",
81+
"@angular/core": "16.0.0",
82+
"@angular/elements": "16.0.0",
8383
"@angular/fire": "^7.5.0",
84-
"@angular/forms": "15.0.4",
85-
"@angular/material": "15.0.3",
86-
"@angular/platform-browser": "15.0.4",
87-
"@angular/platform-browser-dynamic": "15.0.4",
88-
"@angular/router": "15.0.4",
89-
"@angular/service-worker": "15.0.4",
84+
"@angular/forms": "16.0.0",
85+
"@angular/material": "16.0.0",
86+
"@angular/platform-browser": "16.0.0",
87+
"@angular/platform-browser-dynamic": "16.0.0",
88+
"@angular/router": "16.0.0",
89+
"@angular/service-worker": "16.0.0",
9090
"@webcomponents/custom-elements": "^1.2.0",
9191
"rxjs": "~7.5.0",
9292
"tslib": "^2.3.0",
9393
"webpack": "^4.0.0",
94-
"zone.js": "~0.12.0"
94+
"zone.js": "~0.13.0"
9595
},
9696
"devDependencies": {
97-
"@angular-devkit/build-angular": "15.0.4",
98-
"@angular/cli": "15.0.4",
99-
"@angular/compiler": "15.0.4",
100-
"@angular/compiler-cli": "15.0.4",
101-
"@angular/language-service": "15.0.4",
97+
"@angular-devkit/build-angular": "16.0.0",
98+
"@angular/cli": "16.0.0",
99+
"@angular/compiler": "16.0.0",
100+
"@angular/compiler-cli": "16.0.0",
101+
"@angular/language-service": "16.0.0",
102102
"@types/jasmine": "~3.6.0",
103103
"@types/jasminewd2": "^2.0.4",
104-
"@types/node": "18.7.1",
104+
"@types/node": "18.16.3",
105105
"archiver": "^1.3.0",
106106
"canonical-path": "^0.0.2",
107107
"chalk": "^2.1.0",
@@ -148,9 +148,9 @@
148148
"semver": "^5.3.0",
149149
"shelljs": "^0.7.7",
150150
"tree-kill": "^1.1.0",
151-
"ts-node": "^3.3.0",
151+
"ts-node": "10.9.1",
152152
"tslint": "~6.1.0",
153-
"typescript": "~4.8.2",
153+
"typescript": "~5.0.4",
154154
"uglify-js": "^3.0.15",
155155
"unist-util-filter": "^0.2.1",
156156
"unist-util-source": "^1.0.1",

projects/ngrx.io/src/app/custom-elements/resource/resource-list.component.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReflectiveInjector } from '@angular/core';
1+
import { TestBed } from '@angular/core/testing';
22
import { PlatformLocation } from '@angular/common';
33

44
import { of } from 'rxjs';
@@ -12,17 +12,18 @@ import { Category } from './resource.model';
1212
// Let e2e tests verify how it displays.
1313
describe('ResourceListComponent', () => {
1414

15-
let injector: ReflectiveInjector;
1615
let location: TestPlatformLocation;
1716

1817
beforeEach(() => {
19-
injector = ReflectiveInjector.resolveAndCreate([
20-
ResourceListComponent,
21-
{provide: PlatformLocation, useClass: TestPlatformLocation },
22-
{provide: ResourceService, useClass: TestResourceService }
23-
]);
24-
25-
location = injector.get(PlatformLocation);
18+
TestBed.configureTestingModule({
19+
providers: [
20+
ResourceListComponent,
21+
{ provide: PlatformLocation, useClass: TestPlatformLocation },
22+
{ provide: ResourceService, useClass: TestResourceService },
23+
],
24+
});
25+
26+
location = TestBed.inject(PlatformLocation);
2627
});
2728

2829
it('should set the location w/o leading slashes', () => {
@@ -63,7 +64,7 @@ describe('ResourceListComponent', () => {
6364

6465
/// / Test Helpers ////
6566
function getComponent(): ResourceListComponent {
66-
return injector.get(ResourceListComponent);
67+
return TestBed.inject(ResourceListComponent);
6768
}
6869

6970
class TestPlatformLocation {

projects/ngrx.io/src/app/search/search.service.spec.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { ReflectiveInjector, NgZone } from '@angular/core';
2-
import { fakeAsync, tick } from '@angular/core/testing';
1+
import { NgZone } from '@angular/core';
2+
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
33
import { of } from 'rxjs';
44
import { SearchService } from './search.service';
55
import { WebWorkerClient } from 'app/shared/web-worker';
66

77
describe('SearchService', () => {
88

9-
let injector: ReflectiveInjector;
109
let service: SearchService;
1110
let sendMessageSpy: jasmine.Spy;
1211
let mockWorker: WebWorkerClient;
@@ -16,11 +15,16 @@ describe('SearchService', () => {
1615
mockWorker = { sendMessage: sendMessageSpy } as any;
1716
spyOn(WebWorkerClient, 'create').and.returnValue(mockWorker);
1817

19-
injector = ReflectiveInjector.resolveAndCreate([
20-
SearchService,
21-
{ provide: NgZone, useFactory: () => new NgZone({ enableLongStackTrace: false }) }
22-
]);
23-
service = injector.get(SearchService);
18+
TestBed.configureTestingModule({
19+
providers: [
20+
SearchService,
21+
{
22+
provide: NgZone,
23+
useFactory: () => new NgZone({ enableLongStackTrace: false }),
24+
},
25+
],
26+
});
27+
service = TestBed.inject(SearchService);
2428
});
2529

2630
describe('initWorker', () => {
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
import { ReflectiveInjector } from '@angular/core';
1+
import { TestBed } from '@angular/core/testing';
22
import { environment } from 'environments/environment';
33
import { LocationService } from 'app/shared/location.service';
44
import { MockLocationService } from 'testing/location.service';
55
import { Deployment } from './deployment.service';
66

77
describe('Deployment service', () => {
88
describe('mode', () => {
9+
beforeEach(() => {
10+
TestBed.configureTestingModule({
11+
providers: [
12+
Deployment,
13+
{ provide: LocationService, useFactory: () => new MockLocationService('') },
14+
],
15+
});
16+
});
17+
918
it('should get the mode from the environment', () => {
1019
environment.mode = 'foo';
11-
const deployment = getInjector().get(Deployment);
20+
const deployment = TestBed.inject(Deployment);
1221
expect(deployment.mode).toEqual('foo');
1322
});
1423

1524
it('should get the mode from the `mode` query parameter if available', () => {
16-
const injector = getInjector();
17-
18-
const locationService: MockLocationService = injector.get(
25+
const locationService: MockLocationService = TestBed.inject(
1926
LocationService
20-
);
27+
) as unknown as MockLocationService;
2128
locationService.search.and.returnValue({ mode: 'bar' });
2229

23-
const deployment = injector.get(Deployment);
30+
const deployment = TestBed.inject(Deployment);
2431
expect(deployment.mode).toEqual('bar');
2532
});
2633
});
2734
});
28-
29-
function getInjector() {
30-
return ReflectiveInjector.resolveAndCreate([
31-
Deployment,
32-
{ provide: LocationService, useFactory: () => new MockLocationService('') },
33-
]);
34-
}

projects/ngrx.io/src/app/shared/ga.service.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
import { ReflectiveInjector } from '@angular/core';
1+
import { TestBed } from '@angular/core/testing';
22

33
import { GaService } from 'app/shared/ga.service';
44
import { WindowToken } from 'app/shared/window';
55

66
describe('GaService', () => {
77
let gaService: GaService;
8-
let injector: ReflectiveInjector;
98
let gaSpy: jasmine.Spy;
109
let mockWindow: any;
1110

1211
beforeEach(() => {
1312
gaSpy = jasmine.createSpy('ga');
1413
mockWindow = { ga: gaSpy };
15-
injector = ReflectiveInjector.resolveAndCreate([
16-
GaService,
17-
{ provide: WindowToken, useFactory: () => mockWindow },
18-
]);
19-
gaService = injector.get(GaService);
14+
TestBed.configureTestingModule({
15+
providers: [
16+
GaService,
17+
{ provide: WindowToken, useFactory: () => mockWindow },
18+
],
19+
});
20+
gaService = TestBed.inject(GaService);
2021
});
2122

2223
it('should initialize ga with "create" when constructed', () => {

projects/ngrx.io/src/app/shared/location.service.spec.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReflectiveInjector } from '@angular/core';
1+
import { TestBed } from '@angular/core/testing';
22
import { Location, LocationStrategy, PlatformLocation } from '@angular/common';
33
import { MockLocationStrategy } from '@angular/common/testing';
44
import { Subject } from 'rxjs';
@@ -8,24 +8,25 @@ import { SwUpdatesService } from 'app/sw-updates/sw-updates.service';
88
import { LocationService } from './location.service';
99

1010
describe('LocationService', () => {
11-
let injector: ReflectiveInjector;
1211
let location: MockLocationStrategy;
1312
let service: LocationService;
1413
let swUpdates: MockSwUpdatesService;
1514

1615
beforeEach(() => {
17-
injector = ReflectiveInjector.resolveAndCreate([
18-
LocationService,
19-
Location,
20-
{ provide: GaService, useClass: TestGaService },
21-
{ provide: LocationStrategy, useClass: MockLocationStrategy },
22-
{ provide: PlatformLocation, useClass: MockPlatformLocation },
23-
{ provide: SwUpdatesService, useClass: MockSwUpdatesService },
24-
]);
25-
26-
location = injector.get(LocationStrategy);
27-
service = injector.get(LocationService);
28-
swUpdates = injector.get(SwUpdatesService);
16+
TestBed.configureTestingModule({
17+
providers: [
18+
LocationService,
19+
Location,
20+
{ provide: GaService, useClass: TestGaService },
21+
{ provide: LocationStrategy, useClass: MockLocationStrategy },
22+
{ provide: PlatformLocation, useClass: MockPlatformLocation },
23+
{ provide: SwUpdatesService, useClass: MockSwUpdatesService },
24+
],
25+
});
26+
27+
location = TestBed.inject(LocationStrategy) as MockLocationStrategy;
28+
service = TestBed.inject(LocationService);
29+
swUpdates = TestBed.inject(SwUpdatesService) as unknown as MockSwUpdatesService;
2930
});
3031

3132
describe('currentUrl', () => {
@@ -340,7 +341,7 @@ describe('LocationService', () => {
340341
let platformLocation: MockPlatformLocation;
341342

342343
beforeEach(() => {
343-
platformLocation = injector.get(PlatformLocation);
344+
platformLocation = TestBed.inject(PlatformLocation) as unknown as MockPlatformLocation;
344345
});
345346

346347
it('should call replaceState on PlatformLocation', () => {
@@ -558,7 +559,7 @@ describe('LocationService', () => {
558559
let gaLocationChanged: jasmine.Spy;
559560

560561
beforeEach(() => {
561-
const gaService = injector.get(GaService);
562+
const gaService = TestBed.inject(GaService) as unknown as TestGaService;
562563
gaLocationChanged = gaService.locationChanged;
563564
// execute currentPath observable so that gaLocationChanged is called
564565
service.currentPath.subscribe();

projects/ngrx.io/src/app/shared/location.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class LocationService {
1717
currentUrl = this.urlSubject.pipe(map(url => this.stripSlashes(url)));
1818

1919
currentPath = this.currentUrl.pipe(
20-
map(url => (url.match(/[^?#]*/) || [])[0]), // strip query and hash
20+
map(url => (url.match(/[^?#]*/) || [])[0] as string), // strip query and hash
2121
tap(path => this.gaService.locationChanged(path))
2222
);
2323

projects/ngrx.io/src/app/shared/logger.service.spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ErrorHandler, ReflectiveInjector } from '@angular/core';
1+
import { ErrorHandler } from '@angular/core';
2+
import { TestBed } from '@angular/core/testing';
23
import { Logger } from './logger.service';
34

45
describe('logger service', () => {
@@ -10,12 +11,14 @@ describe('logger service', () => {
1011
beforeEach(() => {
1112
logSpy = spyOn(console, 'log');
1213
warnSpy = spyOn(console, 'warn');
13-
const injector = ReflectiveInjector.resolveAndCreate([
14-
Logger,
15-
{ provide: ErrorHandler, useClass: MockErrorHandler },
16-
]);
17-
logger = injector.get(Logger);
18-
errorHandler = injector.get(ErrorHandler);
14+
TestBed.configureTestingModule({
15+
providers: [
16+
Logger,
17+
{ provide: ErrorHandler, useClass: MockErrorHandler },
18+
],
19+
});
20+
logger = TestBed.inject(Logger);
21+
errorHandler = TestBed.inject(ErrorHandler);
1922
});
2023

2124
describe('log', () => {

projects/ngrx.io/src/app/shared/reporting-error-handler.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorHandler, ReflectiveInjector } from '@angular/core';
1+
import { ErrorHandler, Injector } from '@angular/core';
22
import { TestBed } from '@angular/core/testing';
33
import { WindowToken } from 'app/shared/window';
44
import { AppModule } from 'app/app.module';
@@ -14,11 +14,13 @@ describe('ReportingErrorHandler service', () => {
1414
onerrorSpy = jasmine.createSpy('onerror');
1515
superHandler = spyOn(ErrorHandler.prototype, 'handleError');
1616

17-
const injector = ReflectiveInjector.resolveAndCreate([
18-
{ provide: ErrorHandler, useClass: ReportingErrorHandler },
19-
{ provide: WindowToken, useFactory: () => ({ onerror: onerrorSpy }) },
20-
]);
21-
handler = injector.get(ErrorHandler);
17+
const injector = Injector.create({
18+
providers: [
19+
{ provide: ErrorHandler, useClass: ReportingErrorHandler },
20+
{ provide: WindowToken, useFactory: () => ({ onerror: onerrorSpy }) },
21+
],
22+
});
23+
handler = injector.get(ErrorHandler) as unknown as ReportingErrorHandler;
2224
});
2325

2426
it('should be registered on the AppModule', () => {

projects/ngrx.io/src/app/shared/scroll-spy.service.spec.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { Injector, ReflectiveInjector } from '@angular/core';
21
import { fakeAsync, tick } from '@angular/core/testing';
3-
import { DOCUMENT } from '@angular/common';
42

53
import { ScrollService } from 'app/shared/scroll.service';
64
import {
@@ -154,17 +152,12 @@ describe('ScrollSpiedElementGroup', () => {
154152
});
155153

156154
describe('ScrollSpyService', () => {
157-
let injector: Injector;
158155
let scrollSpyService: ScrollSpyService;
156+
let document: Document;
159157

160158
beforeEach(() => {
161-
injector = ReflectiveInjector.resolveAndCreate([
162-
{ provide: DOCUMENT, useValue: { body: {} } },
163-
{ provide: ScrollService, useValue: { topOffset: 50 } },
164-
ScrollSpyService,
165-
]);
166-
167-
scrollSpyService = injector.get(ScrollSpyService);
159+
document = { body: {} } as Document;
160+
scrollSpyService = new ScrollSpyService(document, { topOffset: 50 } as ScrollService);
168161
});
169162

170163
describe('#spyOn()', () => {
@@ -520,7 +513,7 @@ describe('ScrollSpyService', () => {
520513
});
521514

522515
it('should first re-calibrate if the content height has changed', () => {
523-
const body = injector.get(DOCUMENT).body as any;
516+
const body = document.body as any;
524517

525518
scrollSpyService.spyOn([]);
526519
scrollSpyService.spyOn([]);

0 commit comments

Comments
 (0)