-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
remove-default-collection.spec.ts
52 lines (42 loc) · 1.59 KB
/
remove-default-collection.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
52
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
import type { Tree } from '../../generators/tree';
import removeDefaultCollection from './remove-default-collection';
import {
readWorkspaceConfiguration,
updateWorkspaceConfiguration,
} from '../../generators/utils/project-configuration';
describe('remove-default-collection', () => {
let tree: Tree;
beforeEach(() => {
tree = createTreeWithEmptyWorkspace(2);
});
it('should remove default collection from nx.json', async () => {
const config = readWorkspaceConfiguration(tree);
config.cli = {
defaultCollection: 'default-collection',
defaultProjectName: 'default-project',
};
updateWorkspaceConfiguration(tree, config);
await removeDefaultCollection(tree);
expect(readWorkspaceConfiguration(tree).cli).toEqual({
defaultProjectName: 'default-project',
});
});
it('should remove cli entirely if defaultCollection was the only setting', async () => {
const config = readWorkspaceConfiguration(tree);
config.cli = {
defaultCollection: 'default-collection',
};
updateWorkspaceConfiguration(tree, config);
await removeDefaultCollection(tree);
expect(
readWorkspaceConfiguration(tree).cli?.defaultCollection
).toBeUndefined();
});
it('should not error when "cli" is not defined', async () => {
const config = readWorkspaceConfiguration(tree);
delete config.cli;
updateWorkspaceConfiguration(tree, config);
await expect(removeDefaultCollection(tree)).resolves.not.toThrow();
});
});