test(ivy): test listing lazy routes to different root directories (#28542)

PR Close #28542
This commit is contained in:
George Kalpakas
2019-02-11 13:01:01 +02:00
committed by Miško Hevery
parent 188f20fb16
commit cdabda1fc0
2 changed files with 141 additions and 6 deletions

View File

@ -75,13 +75,22 @@ function createTestSupportFor(basePath: string) {
shouldNotExist
};
function write(fileName: string, content: string) {
const dir = path.dirname(fileName);
if (dir != '.') {
const newDir = path.resolve(basePath, dir);
if (!fs.existsSync(newDir)) fs.mkdirSync(newDir);
function ensureDirExists(absolutePathToDir: string) {
if (fs.existsSync(absolutePathToDir)) {
if (!fs.statSync(absolutePathToDir).isDirectory()) {
throw new Error(`'${absolutePathToDir}' exists and is not a directory.`);
}
} else {
const parentDir = path.dirname(absolutePathToDir);
ensureDirExists(parentDir);
fs.mkdirSync(absolutePathToDir);
}
fs.writeFileSync(path.resolve(basePath, fileName), content, {encoding: 'utf-8'});
}
function write(fileName: string, content: string) {
const absolutePathToFile = path.resolve(basePath, fileName);
ensureDirExists(path.dirname(absolutePathToFile));
fs.writeFileSync(absolutePathToFile, content);
}
function writeFiles(...mockDirs: {[fileName: string]: string}[]) {