angular-cli/packages/schematics/angular/migrations/update-16/remove-default-project-option_spec.ts
Alan Agius d58428d3db feat(@angular/cli): remove deprecated defaultProject from workspace configuration
The deprecated 'defaultProject' workspace option has been removed

BREAKING CHANGE: The deprecated `defaultProject` workspace option has been removed. The project to use will be determined from the current working directory.
2023-02-17 16:10:21 +00:00

51 lines
1.6 KiB
TypeScript

/**
* @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';
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 = {
version: 1,
projects: {},
defaultProject: 'foo',
};
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2));
const newTree = await schematicRunner.runSchematic(schematicName, {}, tree);
const { defaultProject } = JSON.parse(newTree.readContent('/angular.json'));
expect(defaultProject).toBeUndefined();
});
it(`should not error when 'defaultProject' is not defined`, async () => {
const angularConfig = {
version: 1,
projects: {},
};
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2));
const newTree = await schematicRunner.runSchematic(schematicName, {}, tree);
const { defaultProject } = JSON.parse(newTree.readContent('/angular.json'));
expect(defaultProject).toBeUndefined();
});
});