Slight improvements to existing tests

This commit is contained in:
Danielv123 committed 2017-06-07 20:33:20 +02:00
1 parent 913887fd2c
commit 00dd22e59f
2 files changed
+24 -21

No files matched your search

+22 -19
View File
@@ -3,26 +3,29 @@ var fileOps = require('./fileOps');
var fs = require('fs');
// create folders for testing
if (!fs.existsSync("lib/test")){
fs.mkdirSync("lib/test");
function setupTestingEnv(){
if (!fs.existsSync("lib/test")){
fs.mkdirSync("lib/test");
}
if (!fs.existsSync("lib/test/folder")){
fs.mkdirSync("lib/test/folder");
}
if (!fs.existsSync("lib/test/another folder")){
fs.mkdirSync("lib/test/another folder");
}
if (!fs.existsSync("lib/test/file.txt")){
fs.writeFileSync("lib/test/file.txt", "contents");
}
if (!fs.existsSync("lib/test/another file.txt")){
fs.writeFileSync("lib/test/another file.txt", "more contents");
}
// we need this xfile to test a branch in fileOps.getNewestFile()s propagation
if (!fs.existsSync("lib/test/xfile.txt")){
fs.writeFileSync("lib/test/xfile.txt", "contents");
}
}
if (!fs.existsSync("lib/test/folder")){
fs.mkdirSync("lib/test/folder");
}
if (!fs.existsSync("lib/test/another folder")){
fs.mkdirSync("lib/test/another folder");
}
if (!fs.existsSync("lib/test/file.txt")){
fs.writeFileSync("lib/test/file.txt", "contents");
}
if (!fs.existsSync("lib/test/another file.txt")){
fs.writeFileSync("lib/test/another file.txt", "more contents");
}
// we need this xfile to test a branch in fileOps.getNewestFile()s propagation
if (!fs.existsSync("lib/test/xfile.txt")){
fs.writeFileSync("lib/test/xfile.txt", "contents");
}
setupTestingEnv();
setupTestingEnv(); // run twice to get branch coverage
describe("fileOps.js", function(){
describe("fileOps.getDirectoriesSync()", function(){
it("gets an array of directory names from a path", function(){