mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
tests for fileOps.getNewestFile()
This commit is contained in:
1 parent
2695f0a443
commit
3d4fbfb3fa
3 files changed
+77
-37
No files matched your search
+37
-9
@@ -2,9 +2,9 @@ var assert = require('assert');
|
||||
var fileOps = require('./fileOps');
|
||||
|
||||
describe("fileOps.js", function(){
|
||||
describe("fileOps.getDirectories()", function(){
|
||||
describe("fileOps.getDirectoriesSync()", function(){
|
||||
it("gets an array of directory names from a path", function(){
|
||||
let directories = fileOps.getDirectories("lib/test");
|
||||
let directories = fileOps.getDirectoriesSync("lib/test");
|
||||
|
||||
// because there are no arrays for some reason
|
||||
assert(typeof directories == "object");
|
||||
@@ -13,11 +13,16 @@ describe("fileOps.js", function(){
|
||||
assert(directories[0] == "another folder" && directories[1] == "folder");
|
||||
});
|
||||
it("does not return any filenames", function(){
|
||||
let directories = fileOps.getDirectories("lib/test");
|
||||
let directories = fileOps.getDirectoriesSync("lib/test");
|
||||
|
||||
// this is a function to return directories, not files. So yeah.
|
||||
assert(!directories.includes("file.txt") && !directories.includes("another file.txt"));
|
||||
});
|
||||
it("throws when lacking first argument", function(){
|
||||
assert.throws(function(){
|
||||
let files = fileOps.getDirectoriesSync();
|
||||
}, Error);
|
||||
});
|
||||
});
|
||||
describe("fileOps.getFileNamesSync(path)", function(){
|
||||
it("gets names of files in directory", function(){
|
||||
@@ -31,13 +36,36 @@ describe("fileOps.js", function(){
|
||||
}, Error);
|
||||
});
|
||||
});
|
||||
/*describe("fileOps.getNewestFile()", function(){
|
||||
describe("fileOps.getNewestFile()", function(){
|
||||
it("gets the newest file in a directory async", function(done){
|
||||
fileOps.getNewestFile("lib/test", fileOps.getFileNames("lib/test"), function(newest){
|
||||
assert(newest);
|
||||
fileOps.getNewestFile("lib/test", fileOps.getFileNamesSync("lib/test"), function(err, newest){
|
||||
assert(newest && typeof newest.file == "string");
|
||||
done();
|
||||
})
|
||||
|
||||
});
|
||||
});
|
||||
});*/
|
||||
it("throws if callback is missing", function(){
|
||||
assert.throws(function(){
|
||||
fileOps.getNewestFile("lib/test", fileOps.getFileNamesSync("lib/test"));
|
||||
}, Error);
|
||||
});
|
||||
it("executes callback(err) if no files are provided", function(done){
|
||||
fileOps.getNewestFile("lib/test", [], function(err, newest){
|
||||
assert(err && typeof err == "object");
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("executes callback(err) if launched without a directory", function(done){
|
||||
fileOps.getNewestFile("", fileOps.getFileNamesSync("lib/test"), function(err, newest){
|
||||
assert(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("executes callback(err) when you do stupid shit", function(done){
|
||||
fileOps.getNewestFile({thisWontWork: "but not crash either"}, {lolz:"yeah..."}, function(err, newest){
|
||||
assert(err);
|
||||
// ENOENT: no such file or directory, stat 'C:\**\factorioClusterio\lib\test\undefined'
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user