Skip to content

Commit

Permalink
feat: upgrade to Angular 15
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `ngx-speculoos` is now based on Angular 15.x. If you want to use it with an older version of Angular, then stick to a previous version of `ngx-speculoos`.
  • Loading branch information
jnizet committed Nov 18, 2022
1 parent f54fe8a commit 8662e7d
Show file tree
Hide file tree
Showing 12 changed files with 1,072 additions and 1,744 deletions.
9 changes: 7 additions & 2 deletions angular.json
Expand Up @@ -58,7 +58,9 @@
"outputPath": "dist/demo",
"index": "projects/demo/src/index.html",
"main": "projects/demo/src/main.ts",
"polyfills": "projects/demo/src/polyfills.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "projects/demo/tsconfig.app.json",
"assets": [
"projects/demo/src/favicon.ico",
Expand Down Expand Up @@ -122,7 +124,10 @@
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/demo/src/test.ts",
"polyfills": "projects/demo/src/polyfills.ts",
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "projects/demo/tsconfig.spec.json",
"karmaConfig": "projects/demo/karma.conf.js",
"styles": [
Expand Down
30 changes: 15 additions & 15 deletions package.json
Expand Up @@ -17,26 +17,26 @@
},
"private": true,
"dependencies": {
"@angular/common": "14.2.11",
"@angular/compiler": "14.2.11",
"@angular/core": "14.2.11",
"@angular/forms": "14.2.11",
"@angular/platform-browser": "14.2.11",
"@angular/platform-browser-dynamic": "14.2.11",
"@angular/router": "14.2.11",
"@angular/common": "15.0.0",
"@angular/compiler": "15.0.0",
"@angular/core": "15.0.0",
"@angular/forms": "15.0.0",
"@angular/platform-browser": "15.0.0",
"@angular/platform-browser-dynamic": "15.0.0",
"@angular/router": "15.0.0",
"rxjs": "7.5.7",
"tslib": "2.4.1",
"zone.js": "0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "14.2.10",
"@angular-eslint/builder": "14.3.0",
"@angular-eslint/eslint-plugin": "14.3.0",
"@angular-eslint/eslint-plugin-template": "14.3.0",
"@angular-eslint/schematics": "14.3.0",
"@angular-eslint/template-parser": "14.3.0",
"@angular/cli": "14.2.10",
"@angular/compiler-cli": "14.2.11",
"@angular-devkit/build-angular": "15.0.0",
"@angular-eslint/builder": "14.2.0",
"@angular-eslint/eslint-plugin": "14.2.0",
"@angular-eslint/eslint-plugin-template": "14.2.0",
"@angular-eslint/schematics": "14.2.0",
"@angular-eslint/template-parser": "14.2.0",
"@angular/cli": "15.0.0",
"@angular/compiler-cli": "15.0.0",
"@compodoc/compodoc": "1.1.19",
"@types/jasmine": "4.3.0",
"@typescript-eslint/eslint-plugin": "5.43.0",
Expand Down
50 changes: 0 additions & 50 deletions projects/demo/src/polyfills.ts

This file was deleted.

15 changes: 0 additions & 15 deletions projects/demo/src/test.ts
Expand Up @@ -4,20 +4,5 @@ import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

declare const require: {
context(
path: string,
deep?: boolean,
filter?: RegExp
): {
keys(): Array<string>;
<T>(id: string): T;
};
};

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
2 changes: 1 addition & 1 deletion projects/demo/tsconfig.app.json
Expand Up @@ -4,7 +4,7 @@
"outDir": "../../out-tsc/app",
"types": []
},
"files": ["src/main.ts", "src/polyfills.ts"],
"files": ["src/main.ts"],
"angularCompilerOptions": {
"strictTemplates": true
}
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/tsconfig.spec.json
Expand Up @@ -5,6 +5,6 @@
"strictNullChecks": false,
"types": ["jasmine", "node"]
},
"files": ["src/test.ts", "src/polyfills.ts"],
"files": ["src/test.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
6 changes: 3 additions & 3 deletions projects/ngx-speculoos/package.json
Expand Up @@ -3,9 +3,9 @@
"version": "8.0.1",
"description": "Helps writing Angular unit tests",
"peerDependencies": {
"@angular/core": "^14.0.0",
"@angular/platform-browser": "^14.0.0",
"@angular/router": "^14.0.0",
"@angular/core": "^15.0.0",
"@angular/platform-browser": "^15.0.0",
"@angular/router": "^15.0.0",
"rxjs": "^7.5.0"
},
"license": "MIT",
Expand Down
10 changes: 9 additions & 1 deletion projects/ngx-speculoos/src/lib/route.ts
Expand Up @@ -195,6 +195,7 @@ class ActivatedRouteSnapshotStub extends ActivatedRouteSnapshot {
private _firstChild: ActivatedRouteSnapshot | null = null;
private _children: Array<ActivatedRouteSnapshot> = [];
private _pathFromRoot: Array<ActivatedRouteSnapshot> = [];
private _title: string | undefined;

get parent(): ActivatedRouteSnapshot | null {
return this._parent;
Expand Down Expand Up @@ -236,6 +237,14 @@ class ActivatedRouteSnapshotStub extends ActivatedRouteSnapshot {
this._pathFromRoot = value;
}

get title(): string | undefined {
return this._title;
}

set title(value: string | undefined) {
this._title = value;
}

get paramMap(): ParamMap {
return convertToParamMap(this.params);
}
Expand Down Expand Up @@ -303,7 +312,6 @@ export class ActivatedRouteStub extends ActivatedRoute {
snapshot.params = options?.params ?? {};
snapshot.queryParams = options?.queryParams ?? {};
snapshot.data = options?.data ?? {};
// @ts-expect-error the title is readonly, but we need to overwrite it here
snapshot.title = options?.title;
snapshot.fragment = options?.fragment ?? null;
snapshot.url = options?.url ?? [];
Expand Down
15 changes: 0 additions & 15 deletions projects/ngx-speculoos/src/test.ts
Expand Up @@ -5,20 +5,5 @@ import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

declare const require: {
context(
path: string,
deep?: boolean,
filter?: RegExp
): {
keys(): Array<string>;
<T>(id: string): T;
};
};

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
1 change: 0 additions & 1 deletion projects/ngx-speculoos/tsconfig.lib.json
Expand Up @@ -3,7 +3,6 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Expand Up @@ -14,7 +14,7 @@
"moduleResolution": "node",
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2017",
"target": "ES2022",
"typeRoots": [
"node_modules/@types"
],
Expand All @@ -26,6 +26,7 @@
"ngx-speculoos": [
"dist/ngx-speculoos"
]
}
},
"useDefineForClassFields": false
}
}

0 comments on commit 8662e7d

Please sign in to comment.