-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
remove-roots.spec.ts
66 lines (52 loc) · 1.72 KB
/
remove-roots.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { Tree } from '../../generators/tree';
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
import { addProjectConfiguration } from '../../generators/utils/project-configuration';
import { readJson, updateJson, writeJson } from '../../generators/utils/json';
import removeRoots from './remove-roots';
describe('remove-roots >', () => {
let tree: Tree;
describe('projects with project.json configs', () => {
beforeEach(() => {
tree = createTreeWithEmptyWorkspace(2);
});
it('should remove the root property', async () => {
addProjectConfiguration(tree, 'proj1', {
root: 'proj1',
});
updateJson(tree, 'proj1/project.json', (config) => ({
...config,
root: 'proj1',
}));
await removeRoots(tree);
expect(readJson(tree, 'proj1/project.json').root).toBeUndefined();
});
});
describe('projects with workspace.json configs', () => {
beforeEach(() => {
tree = createTreeWithEmptyWorkspace(1);
});
it('should remove the root property', async () => {
addProjectConfiguration(tree, 'proj1', {
root: 'proj1',
});
await removeRoots(tree);
expect(readJson(tree, 'workspace.json').projects.proj1.root).toEqual(
'proj1'
);
});
});
describe('projects with package.json configs', () => {
beforeEach(() => {
tree = createTreeWithEmptyWorkspace(2);
});
it('should remove the root property', async () => {
writeJson(tree, 'proj1/package.json', {
name: 'proj1',
});
await removeRoots(tree);
expect(readJson(tree, 'proj1/package.json')).toEqual({
name: 'proj1',
});
});
});
});