Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit ea49db1

Browse files
committed
tests: update tests to work with version 10
1 parent b77598a commit ea49db1

File tree

5 files changed

+53
-18
lines changed

5 files changed

+53
-18
lines changed

modules/common/schematics/add/index.spec.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8+
import { JsonParseMode, parseJson } from '@angular-devkit/core';
89
import { Tree } from '@angular-devkit/schematics';
910
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
1011

@@ -75,8 +76,12 @@ describe('Add Schematic Rule', () => {
7576
const tree = await schematicRunner
7677
.callRule(addUniversalCommonRule(defaultOptions), appTree).toPromise();
7778

78-
const contents = JSON.parse(tree.read('/projects/test-app/tsconfig.server.json')!.toString());
79-
expect(contents.files).toEqual([
79+
const { files } = parseJson(
80+
tree.read('/projects/test-app/tsconfig.server.json')!.toString(),
81+
JsonParseMode.Loose,
82+
) as any;
83+
84+
expect(files).toEqual([
8085
'src/main.server.ts',
8186
'server.ts',
8287
]);
@@ -89,9 +94,12 @@ describe('Add Schematic Rule', () => {
8994

9095
const tree = await schematicRunner
9196
.callRule(addUniversalCommonRule(defaultOptions), appTree).toPromise();
97+
const { files } = parseJson(
98+
tree.read('/projects/test-app/tsconfig.server.json')!.toString(),
99+
JsonParseMode.Loose,
100+
) as any;
92101

93-
const contents = JSON.parse(tree.read('/projects/test-app/tsconfig.server.json')!.toString());
94-
expect(contents.files).toEqual([
102+
expect(files).toEqual([
95103
'src/main.server.ts',
96104
'server.ts',
97105
]);

modules/express-engine/schematics/install/index.spec.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8+
9+
import { JsonParseMode, parseJson } from '@angular-devkit/core';
810
import { Tree } from '@angular-devkit/schematics';
911
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
1012

@@ -57,8 +59,12 @@ describe('Universal Schematic', () => {
5759
.runSchematicAsync('ng-add', defaultOptions, appTree)
5860
.toPromise();
5961

60-
const contents = JSON.parse(tree.readContent('/projects/test-app/tsconfig.server.json'));
61-
expect(contents.files).toEqual([
62+
const { files } = parseJson(
63+
tree.readContent('/projects/test-app/tsconfig.server.json'),
64+
JsonParseMode.Loose,
65+
) as any;
66+
67+
expect(files).toEqual([
6268
'src/main.server.ts',
6369
'server.ts',
6470
]);

modules/express-engine/schematics/migrations/update-9/index.spec.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import { JsonParseMode, parseJson } from '@angular-devkit/core';
910
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
1011
import { createTestApp } from '../../testing/test-app';
1112

@@ -60,8 +61,12 @@ describe('Migration to version 9', () => {
6061
const newTree =
6162
await schematicRunner.runSchematicAsync('update-9', {}, tree.branch()).toPromise();
6263

63-
const contents = JSON.parse(newTree.readContent('/projects/test-app/tsconfig.server.json'));
64-
expect(contents.files).toEqual([
64+
const { files } = parseJson(
65+
newTree.readContent('/projects/test-app/tsconfig.server.json'),
66+
JsonParseMode.Loose,
67+
) as any;
68+
69+
expect(files).toEqual([
6570
'src/main.server.ts',
6671
'server.ts',
6772
]);
@@ -131,9 +136,12 @@ describe('Migration to version 9', () => {
131136
const newTree =
132137
await schematicRunner.runSchematicAsync('update-9', {}, tree.branch()).toPromise();
133138

134-
const contents =
135-
JSON.parse(newTree.readContent('/projects/test-app-two/tsconfig.server.json'));
136-
expect(contents.files).toEqual([
139+
const { files } = parseJson(
140+
newTree.readContent('/projects/test-app-two/tsconfig.server.json'),
141+
JsonParseMode.Loose,
142+
) as any;
143+
144+
expect(files).toEqual([
137145
'src/main.server.ts',
138146
'server.ts',
139147
]);

modules/hapi-engine/schematics/install/index.spec.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8+
import { JsonParseMode, parseJson } from '@angular-devkit/core';
89
import { Tree } from '@angular-devkit/schematics';
910
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
1011

@@ -57,8 +58,12 @@ describe('Universal Schematic', () => {
5758
.runSchematicAsync('ng-add', defaultOptions, appTree)
5859
.toPromise();
5960

60-
const contents = JSON.parse(tree.readContent('/projects/test-app/tsconfig.server.json'));
61-
expect(contents.files).toEqual([
61+
const { files } = parseJson(
62+
tree.readContent('/projects/test-app/tsconfig.server.json'),
63+
JsonParseMode.Loose,
64+
) as any;
65+
66+
expect(files).toEqual([
6267
'src/main.server.ts',
6368
'server.ts',
6469
]);

modules/hapi-engine/schematics/migrations/update-9/index.spec.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import { JsonParseMode, parseJson } from '@angular-devkit/core';
910
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
1011
import { createTestApp } from '../../testing/test-app';
1112

@@ -60,8 +61,12 @@ describe('Migration to version 9', () => {
6061
const newTree =
6162
await schematicRunner.runSchematicAsync('update-9', {}, tree.branch()).toPromise();
6263

63-
const contents = JSON.parse(newTree.readContent('/projects/test-app/tsconfig.server.json'));
64-
expect(contents.files).toEqual([
64+
const { files } = parseJson(
65+
newTree.readContent('/projects/test-app/tsconfig.server.json'),
66+
JsonParseMode.Loose,
67+
) as any;
68+
69+
expect(files).toEqual([
6570
'src/main.server.ts',
6671
'server.ts',
6772
]);
@@ -131,9 +136,12 @@ describe('Migration to version 9', () => {
131136
const newTree =
132137
await schematicRunner.runSchematicAsync('update-9', {}, tree.branch()).toPromise();
133138

134-
const contents =
135-
JSON.parse(newTree.readContent('/projects/test-app-two/tsconfig.server.json'));
136-
expect(contents.files).toEqual([
139+
const { files } = parseJson(
140+
newTree.readContent('/projects/test-app-two/tsconfig.server.json'),
141+
JsonParseMode.Loose,
142+
) as any;
143+
144+
expect(files).toEqual([
137145
'src/main.server.ts',
138146
'server.ts',
139147
]);

0 commit comments

Comments
 (0)