jest-preset-angular 13.1.4 → 13.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [13.1.5](https://github.com/thymikee/jest-preset-angular/compare/v13.1.3...v13.1.5) (2024-01-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fix TS5 + ESM hang; and upgrade dev dependencies to ng17 ([#2197](https://github.com/thymikee/jest-preset-angular/issues/2197)) ([90797e5](https://github.com/thymikee/jest-preset-angular/commit/90797e511f7ba511a653a88002ae28fed4bbbca1)), closes [thymikee/jest-preset-angular#2138](https://github.com/thymikee/jest-preset-angular/issues/2138) [#2138](https://github.com/thymikee/jest-preset-angular/issues/2138) [#2196](https://github.com/thymikee/jest-preset-angular/issues/2196)
7
+ * **transformers:** handle single string styles or styleUrl property ([#2186](https://github.com/thymikee/jest-preset-angular/issues/2186)) ([cf00f55](https://github.com/thymikee/jest-preset-angular/commit/cf00f55612f590bb26613e569338bc72eba4ba08))
8
+
9
+
10
+ ### Features
11
+
12
+ * drop support Angular 13 and 14 ([#2180](https://github.com/thymikee/jest-preset-angular/issues/2180)) ([b4ad1c6](https://github.com/thymikee/jest-preset-angular/commit/b4ad1c6036844d98f91a7bcd5e1f32a02d4ae549))
13
+
14
+
15
+
1
16
  ## [13.1.4](https://github.com/thymikee/jest-preset-angular/compare/v13.1.3...v13.1.4) (2023-11-11)
2
17
 
3
18
 
@@ -28,7 +28,7 @@ var ClassMemberKind;
28
28
  ClassMemberKind[ClassMemberKind["Setter"] = 2] = "Setter";
29
29
  ClassMemberKind[ClassMemberKind["Property"] = 3] = "Property";
30
30
  ClassMemberKind[ClassMemberKind["Method"] = 4] = "Method";
31
- })(ClassMemberKind = exports.ClassMemberKind || (exports.ClassMemberKind = {}));
31
+ })(ClassMemberKind || (exports.ClassMemberKind = ClassMemberKind = {}));
32
32
  var KnownDeclaration;
33
33
  (function (KnownDeclaration) {
34
34
  KnownDeclaration[KnownDeclaration["JsGlobalObject"] = 0] = "JsGlobalObject";
@@ -37,7 +37,7 @@ var KnownDeclaration;
37
37
  KnownDeclaration[KnownDeclaration["TsHelperSpreadArrays"] = 3] = "TsHelperSpreadArrays";
38
38
  KnownDeclaration[KnownDeclaration["TsHelperSpreadArray"] = 4] = "TsHelperSpreadArray";
39
39
  KnownDeclaration[KnownDeclaration["TsHelperRead"] = 5] = "TsHelperRead";
40
- })(KnownDeclaration = exports.KnownDeclaration || (exports.KnownDeclaration = {}));
40
+ })(KnownDeclaration || (exports.KnownDeclaration = KnownDeclaration = {}));
41
41
  function isConcreteDeclaration(decl) {
42
42
  return decl.kind === 0;
43
43
  }
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.combineModifiers = exports.getModifiers = exports.getDecorators = exports.updateConstructorDeclaration = exports.createSetAccessorDeclaration = exports.updateSetAccessorDeclaration = exports.createGetAccessorDeclaration = exports.updateGetAccessorDeclaration = exports.createPropertyDeclaration = exports.updatePropertyDeclaration = exports.createMethodDeclaration = exports.updateMethodDeclaration = exports.createClassDeclaration = exports.updateClassDeclaration = exports.updateImportDeclaration = exports.updateParameterDeclaration = void 0;
13
+ exports.toMutableArray = exports.combineModifiers = exports.getModifiers = exports.getDecorators = exports.updateConstructorDeclaration = exports.createSetAccessorDeclaration = exports.updateSetAccessorDeclaration = exports.createGetAccessorDeclaration = exports.updateGetAccessorDeclaration = exports.createPropertyDeclaration = exports.updatePropertyDeclaration = exports.createMethodDeclaration = exports.updateMethodDeclaration = exports.createClassDeclaration = exports.updateClassDeclaration = exports.updateImportDeclaration = exports.updateParameterDeclaration = void 0;
14
14
  const typescript_1 = __importDefault(require("typescript"));
15
15
  const IS_AFTER_TS_48 = isAfterVersion(4, 8);
16
16
  exports.updateParameterDeclaration = IS_AFTER_TS_48 ?
@@ -52,8 +52,10 @@ exports.createSetAccessorDeclaration = IS_AFTER_TS_48 ?
52
52
  exports.updateConstructorDeclaration = IS_AFTER_TS_48 ?
53
53
  typescript_1.default.factory.updateConstructorDeclaration :
54
54
  (node, modifiers, parameters, body) => typescript_1.default.factory.updateConstructorDeclaration(node, undefined, modifiers, parameters, body);
55
- exports.getDecorators = IS_AFTER_TS_48 ? typescript_1.default.getDecorators : node => node.decorators;
56
- exports.getModifiers = IS_AFTER_TS_48 ? typescript_1.default.getModifiers : node => node.modifiers;
55
+ exports.getDecorators = IS_AFTER_TS_48 ? typescript_1.default.getDecorators
56
+ : node => node.decorators;
57
+ exports.getModifiers = IS_AFTER_TS_48 ? typescript_1.default.getModifiers
58
+ : node => node.modifiers;
57
59
  function combineModifiers(decorators, modifiers) {
58
60
  const hasDecorators = decorators === null || decorators === void 0 ? void 0 : decorators.length;
59
61
  const hasModifiers = modifiers === null || modifiers === void 0 ? void 0 : modifiers.length;
@@ -92,3 +94,10 @@ function isAfterVersion(targetMajor, targetMinor) {
92
94
  }
93
95
  return major === targetMajor ? minor >= targetMinor : true;
94
96
  }
97
+ function toMutableArray(immutableArray) {
98
+ if (immutableArray) {
99
+ return [...immutableArray];
100
+ }
101
+ return undefined;
102
+ }
103
+ exports.toMutableArray = toMutableArray;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.replaceResources = void 0;
7
7
  const typescript_1 = __importDefault(require("typescript"));
8
8
  const constants_1 = require("../constants");
9
+ const ts_compatibility_1 = require("../ngtsc/ts_compatibility");
9
10
  const isAfterVersion = (targetMajor, targetMinor) => {
10
11
  const [major, minor] = typescript_1.default.versionMajorMinor.split('.').map((part) => parseInt(part));
11
12
  if (major < targetMajor) {
@@ -19,6 +20,7 @@ const isAfterVersion = (targetMajor, targetMinor) => {
19
20
  }
20
21
  };
21
22
  const IS_TS_48 = isAfterVersion(4, 8);
23
+ const IS_AFTER_TS_50 = isAfterVersion(5, 0);
22
24
  const shouldTransform = (fileName) => !fileName.endsWith('.ngfactory.ts') && !fileName.endsWith('.ngstyle.ts');
23
25
  function replaceResources({ program }) {
24
26
  return (context) => {
@@ -62,8 +64,8 @@ function visitClassDeclaration(nodeFactory, typeChecker, node, resourceImportDec
62
64
  });
63
65
  }
64
66
  else {
65
- decorators = node.decorators;
66
- modifiers = node.modifiers;
67
+ decorators = (0, ts_compatibility_1.toMutableArray)((0, ts_compatibility_1.getDecorators)(node));
68
+ modifiers = (0, ts_compatibility_1.toMutableArray)((0, ts_compatibility_1.getModifiers)(node));
67
69
  }
68
70
  if (!decorators || !decorators.length) {
69
71
  return node;
@@ -155,7 +157,13 @@ function createResourceImport(nodeFactory, url, resourceImportDeclarations, modu
155
157
  }
156
158
  else {
157
159
  const importName = nodeFactory.createIdentifier(`__NG_CLI_RESOURCE__${resourceImportDeclarations.length}`);
158
- const importDeclaration = nodeFactory.createImportDeclaration(undefined, undefined, nodeFactory.createImportClause(false, importName, undefined), urlLiteral);
160
+ let importDeclaration;
161
+ if (IS_AFTER_TS_50) {
162
+ importDeclaration = nodeFactory.createImportDeclaration(undefined, nodeFactory.createImportClause(false, importName, undefined), urlLiteral);
163
+ }
164
+ else {
165
+ importDeclaration = nodeFactory.createImportDeclaration(undefined, undefined, nodeFactory.createImportClause(false, importName, undefined), urlLiteral);
166
+ }
159
167
  resourceImportDeclarations.push(importDeclaration);
160
168
  return importName;
161
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-preset-angular",
3
- "version": "13.1.4",
3
+ "version": "13.1.5",
4
4
  "description": "Jest preset configuration for Angular projects",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -55,22 +55,22 @@
55
55
  "esbuild": ">=0.13.8"
56
56
  },
57
57
  "peerDependencies": {
58
- "@angular-devkit/build-angular": ">=13.0.0 <18.0.0",
59
- "@angular/compiler-cli": ">=13.0.0 <18.0.0",
60
- "@angular/core": ">=13.0.0 <18.0.0",
61
- "@angular/platform-browser-dynamic": ">=13.0.0 <18.0.0",
58
+ "@angular-devkit/build-angular": ">=15.0.0 <18.0.0",
59
+ "@angular/compiler-cli": ">=15.0.0 <18.0.0",
60
+ "@angular/core": ">=15.0.0 <18.0.0",
61
+ "@angular/platform-browser-dynamic": ">=15.0.0 <18.0.0",
62
62
  "jest": "^29.0.0",
63
63
  "typescript": ">=4.4"
64
64
  },
65
65
  "devDependencies": {
66
- "@angular-devkit/build-angular": "^16.0.4",
67
- "@angular/animations": "^16.0.4",
68
- "@angular/common": "^16.0.4",
69
- "@angular/compiler": "^16.0.4",
70
- "@angular/compiler-cli": "~16.0.4",
71
- "@angular/core": "^16.0.4",
72
- "@angular/platform-browser": "^16.0.4",
73
- "@angular/platform-browser-dynamic": "^16.0.4",
66
+ "@angular-devkit/build-angular": "^17.0.8",
67
+ "@angular/animations": "^17.0.8",
68
+ "@angular/common": "^17.0.8",
69
+ "@angular/compiler": "^17.0.8",
70
+ "@angular/compiler-cli": "~17.0.8",
71
+ "@angular/core": "^17.0.8",
72
+ "@angular/platform-browser": "^17.0.8",
73
+ "@angular/platform-browser-dynamic": "^17.0.8",
74
74
  "@commitlint/cli": "^17.6.7",
75
75
  "@commitlint/config-angular": "^17.6.7",
76
76
  "@jest/transform": "^29.5.0",
@@ -103,8 +103,8 @@
103
103
  "rxjs": "^7.8.1",
104
104
  "ts-node": "^10.9.1",
105
105
  "tslib": "^2.5.2",
106
- "typescript": "^4.9.5",
107
- "zone.js": "^0.13.0"
106
+ "typescript": "^5.2.0 <5.3.0",
107
+ "zone.js": "^0.14.2"
108
108
  },
109
109
  "packageManager": "yarn@3.5.1"
110
110
  }