-
Notifications
You must be signed in to change notification settings - Fork 12k
/
remove-default-project-option_spec.ts
51 lines (42 loc) · 1.69 KB
/
remove-default-project-option_spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* 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 { EmptyTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import { WorkspaceSchema } from '../../utility/workspace-models';
describe(`Migration to remove 'defaultProject' option.`, () => {
const schematicName = 'remove-default-project-option';
const schematicRunner = new SchematicTestRunner(
'migrations',
require.resolve('../migration-collection.json'),
);
let tree: UnitTestTree;
beforeEach(() => {
tree = new UnitTestTree(new EmptyTree());
});
it(`should remove 'defaultProject'`, async () => {
const angularConfig: WorkspaceSchema = {
version: 1,
projects: {},
defaultProject: 'foo',
};
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2));
const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise();
const { defaultProject } = JSON.parse(newTree.readContent('/angular.json'));
expect(defaultProject).toBeUndefined();
});
it(`should not error when 'defaultProject' is not defined`, async () => {
const angularConfig: WorkspaceSchema = {
version: 1,
projects: {},
};
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2));
const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise();
const { defaultProject } = JSON.parse(newTree.readContent('/angular.json'));
expect(defaultProject).toBeUndefined();
});
});