Skip to content

Commit a64c57d

Browse files
committed
test: adding tests for appRoot config
1 parent 9042b9d commit a64c57d

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {ng} from '../../../utils/process';
2+
import {rename} from '../../../utils/fs';
3+
4+
export default function() {
5+
return Promise.resolve()
6+
.then(() => ng('get', 'apps.0.appRoot'))
7+
.then(({ stdout }) => {
8+
if (!stdout.match(/app/)) {
9+
throw new Error(`Expected "app", received "${JSON.stringify(stdout)}".`);
10+
}
11+
})
12+
.then(() => ng('set', 'apps.0.appRoot' , 'app1'))
13+
.then(() => ng('get', 'apps.0.appRoot'))
14+
.then(({ stdout }) => {
15+
if (!stdout.match(/app1/)) {
16+
throw new Error(`Expected "app1", received "${JSON.stringify(stdout)}".`);
17+
}
18+
})
19+
.then(() => rename('./src/app', './src/app1'))
20+
.then(() => ng('g', 'c', 'hello', '-d'))
21+
.then(({ stdout }) => {
22+
if (!stdout.match(/app1/)) {
23+
throw new Error(`Expected "app", received "${JSON.stringify(stdout)}".`);
24+
}
25+
});
26+
}

tests/e2e/utils/fs.ts

+11
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ export function createDir(path: string) {
7171
_recursiveMkDir(path);
7272
}
7373

74+
export function rename(from: string, to: string) {
75+
return new Promise((resolve, reject) => {
76+
fs.rename(from, to, (error) => {
77+
if (error) {
78+
reject(error);
79+
} else {
80+
resolve();
81+
}
82+
});
83+
});
84+
}
7485

7586
function _recursiveMkDir(path: string) {
7687
if (fs.existsSync(path)) {

0 commit comments

Comments
 (0)