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

Commit

Permalink
tests: update tests to work with version 10
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 committed Jun 25, 2020
1 parent b77598a commit ea49db1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
16 changes: 12 additions & 4 deletions modules/common/schematics/add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { JsonParseMode, parseJson } from '@angular-devkit/core';
import { Tree } from '@angular-devkit/schematics';
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';

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

const contents = JSON.parse(tree.read('/projects/test-app/tsconfig.server.json')!.toString());
expect(contents.files).toEqual([
const { files } = parseJson(
tree.read('/projects/test-app/tsconfig.server.json')!.toString(),
JsonParseMode.Loose,
) as any;

expect(files).toEqual([
'src/main.server.ts',
'server.ts',
]);
Expand All @@ -89,9 +94,12 @@ describe('Add Schematic Rule', () => {

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

const contents = JSON.parse(tree.read('/projects/test-app/tsconfig.server.json')!.toString());
expect(contents.files).toEqual([
expect(files).toEqual([
'src/main.server.ts',
'server.ts',
]);
Expand Down
10 changes: 8 additions & 2 deletions modules/express-engine/schematics/install/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import { JsonParseMode, parseJson } from '@angular-devkit/core';
import { Tree } from '@angular-devkit/schematics';
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';

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

const contents = JSON.parse(tree.readContent('/projects/test-app/tsconfig.server.json'));
expect(contents.files).toEqual([
const { files } = parseJson(
tree.readContent('/projects/test-app/tsconfig.server.json'),
JsonParseMode.Loose,
) as any;

expect(files).toEqual([
'src/main.server.ts',
'server.ts',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

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

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

const contents = JSON.parse(newTree.readContent('/projects/test-app/tsconfig.server.json'));
expect(contents.files).toEqual([
const { files } = parseJson(
newTree.readContent('/projects/test-app/tsconfig.server.json'),
JsonParseMode.Loose,
) as any;

expect(files).toEqual([
'src/main.server.ts',
'server.ts',
]);
Expand Down Expand Up @@ -131,9 +136,12 @@ describe('Migration to version 9', () => {
const newTree =
await schematicRunner.runSchematicAsync('update-9', {}, tree.branch()).toPromise();

const contents =
JSON.parse(newTree.readContent('/projects/test-app-two/tsconfig.server.json'));
expect(contents.files).toEqual([
const { files } = parseJson(
newTree.readContent('/projects/test-app-two/tsconfig.server.json'),
JsonParseMode.Loose,
) as any;

expect(files).toEqual([
'src/main.server.ts',
'server.ts',
]);
Expand Down
9 changes: 7 additions & 2 deletions modules/hapi-engine/schematics/install/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { JsonParseMode, parseJson } from '@angular-devkit/core';
import { Tree } from '@angular-devkit/schematics';
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';

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

const contents = JSON.parse(tree.readContent('/projects/test-app/tsconfig.server.json'));
expect(contents.files).toEqual([
const { files } = parseJson(
tree.readContent('/projects/test-app/tsconfig.server.json'),
JsonParseMode.Loose,
) as any;

expect(files).toEqual([
'src/main.server.ts',
'server.ts',
]);
Expand Down
18 changes: 13 additions & 5 deletions modules/hapi-engine/schematics/migrations/update-9/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

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

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

const contents = JSON.parse(newTree.readContent('/projects/test-app/tsconfig.server.json'));
expect(contents.files).toEqual([
const { files } = parseJson(
newTree.readContent('/projects/test-app/tsconfig.server.json'),
JsonParseMode.Loose,
) as any;

expect(files).toEqual([
'src/main.server.ts',
'server.ts',
]);
Expand Down Expand Up @@ -131,9 +136,12 @@ describe('Migration to version 9', () => {
const newTree =
await schematicRunner.runSchematicAsync('update-9', {}, tree.branch()).toPromise();

const contents =
JSON.parse(newTree.readContent('/projects/test-app-two/tsconfig.server.json'));
expect(contents.files).toEqual([
const { files } = parseJson(
newTree.readContent('/projects/test-app-two/tsconfig.server.json'),
JsonParseMode.Loose,
) as any;

expect(files).toEqual([
'src/main.server.ts',
'server.ts',
]);
Expand Down

0 comments on commit ea49db1

Please sign in to comment.