big consolidation
This commit is contained in:
78
test/test.js
78
test/test.js
File diff suppressed because one or more lines are too long
82
test/test.ts
82
test/test.ts
@ -1,5 +1,5 @@
|
||||
import "typings-test";
|
||||
import * as smartfile from "../dist/index.js";
|
||||
import * as smartfile from "../dist/index";
|
||||
let beautylog = require("beautylog");
|
||||
let gulp = require("gulp");
|
||||
let gFunction = require("gulp-function");
|
||||
@ -7,33 +7,47 @@ import should = require("should");
|
||||
let vinyl = require("vinyl");
|
||||
|
||||
describe("smartfile".yellow,function(){
|
||||
describe(".checks".yellow,function(){
|
||||
|
||||
|
||||
describe(".fs".yellow,function(){
|
||||
describe(".fileExistsSync".yellow,function(){
|
||||
it("should return an accurate boolean",function(){
|
||||
(smartfile.checks.fileExistsSync("./test/mytest.json")).should.be.true();
|
||||
(smartfile.checks.fileExistsSync("./test/notthere.json")).should.be.false();
|
||||
(smartfile.fs.fileExistsSync("./test/mytest.json")).should.be.true();
|
||||
(smartfile.fs.fileExistsSync("./test/notthere.json")).should.be.false();
|
||||
});
|
||||
});
|
||||
describe(".fileExists".yellow,function(){
|
||||
it("should return a working promise",function(){
|
||||
(smartfile.checks.fileExists("./test/mytest.json")).should.be.Promise();
|
||||
(smartfile.checks.fileExists("./test/mytest.json")).should.be.fulfilled();
|
||||
(smartfile.checks.fileExists("./test/notthere.json")).should.not.be.fulfilled();
|
||||
(smartfile.fs.fileExists("./test/mytest.json")).should.be.Promise();
|
||||
(smartfile.fs.fileExists("./test/mytest.json")).should.be.fulfilled();
|
||||
(smartfile.fs.fileExists("./test/notthere.json")).should.not.be.fulfilled();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
describe(".fsaction".yellow,function(){
|
||||
});
|
||||
describe(".foldersSync()",function(){
|
||||
it("should get the file type from a string",function(){
|
||||
smartfile.fs.foldersSync("./test/").should.containDeep([ "testfolder"]);
|
||||
smartfile.fs.foldersSync("./test/").should.not.containDeep([ "notExistentFolder"]);
|
||||
});
|
||||
});
|
||||
describe(".folders()",function(){
|
||||
it("should get the file type from a string",function(done){
|
||||
smartfile.fs.folders("./test/")
|
||||
.then(function(folderArrayArg){
|
||||
folderArrayArg.should.containDeep([ "testfolder"]);
|
||||
folderArrayArg.should.not.containDeep([ "notExistentFolder"]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".copy()".yellow,function(){
|
||||
it("should copy a directory",function(){
|
||||
smartfile.fsaction.copy("./test/testfolder/","./test/temp/")
|
||||
smartfile.fs.copy("./test/testfolder/","./test/temp/")
|
||||
});
|
||||
it("should copy a file",function(){
|
||||
smartfile.fsaction.copy("./test/mytest.yaml","./test/temp/")
|
||||
smartfile.fs.copy("./test/mytest.yaml","./test/temp/")
|
||||
});
|
||||
it("should copy a file and rename it",function(){
|
||||
smartfile.fsaction.copy("./test/mytest.yaml","./test/temp/mytestRenamed.yaml")
|
||||
smartfile.fs.copy("./test/mytest.yaml","./test/temp/mytestRenamed.yaml")
|
||||
});
|
||||
});
|
||||
describe(".remove()",function(){
|
||||
@ -46,51 +60,35 @@ describe("smartfile".yellow,function(){
|
||||
});
|
||||
});
|
||||
|
||||
describe(".get",function(){
|
||||
describe(".interpreter",function(){
|
||||
describe(".filetype()",function(){
|
||||
it("should get the file type from a string",function(){
|
||||
smartfile.get.filetype("./somefolder/data.json").should.equal("json");
|
||||
});
|
||||
});
|
||||
describe(".foldersSync()",function(){
|
||||
it("should get the file type from a string",function(){
|
||||
smartfile.get.foldersSync("./test/").should.containDeep([ "testfolder"]);
|
||||
smartfile.get.foldersSync("./test/").should.not.containDeep([ "notExistentFolder"]);
|
||||
});
|
||||
});
|
||||
describe(".folders()",function(){
|
||||
it("should get the file type from a string",function(done){
|
||||
smartfile.get.folders("./test/")
|
||||
.then(function(folderArrayArg){
|
||||
folderArrayArg.should.containDeep([ "testfolder"]);
|
||||
folderArrayArg.should.not.containDeep([ "notExistentFolder"]);
|
||||
done();
|
||||
});
|
||||
smartfile.interpreter.filetype("./somefolder/data.json").should.equal("json");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe(".local".yellow,function(){
|
||||
describe(".fs".yellow,function(){
|
||||
describe("toGulpStreamSync() and toGulpDestSync",function(){
|
||||
it("should produce a gulp stream",function(done){
|
||||
smartfile.local.toGulpStreamSync("./test/my*")
|
||||
.pipe(smartfile.local.toGulpDestSync("./test/temp/"))
|
||||
smartfile.fs.toGulpStreamSync("./test/my*")
|
||||
.pipe(smartfile.fs.toGulpDestSync("./test/temp/"))
|
||||
.pipe(gFunction(done,"atEnd"));
|
||||
});
|
||||
});
|
||||
describe(".toObjectSync()".yellow,function(){
|
||||
it("should read an " + ".yaml".blue + " file to an object",function(){
|
||||
let testData = smartfile.local.toObjectSync("./test/mytest.yaml");
|
||||
let testData = smartfile.fs.toObjectSync("./test/mytest.yaml");
|
||||
testData.should.have.property("key1","this works");
|
||||
testData.should.have.property("key2","this works too");
|
||||
|
||||
});
|
||||
it("should state unknown file type for unknown file types",function(){
|
||||
let testData = smartfile.local.toObjectSync("./test/mytest.txt");
|
||||
let testData = smartfile.fs.toObjectSync("./test/mytest.txt");
|
||||
});
|
||||
it("should read an " + ".json".blue + " file to an object",function(){
|
||||
let testData = smartfile.local.toObjectSync("./test/mytest.json");
|
||||
let testData = smartfile.fs.toObjectSync("./test/mytest.json");
|
||||
testData.should.have.property("key1","this works");
|
||||
testData.should.have.property("key2","this works too");
|
||||
|
||||
@ -99,14 +97,14 @@ describe("smartfile".yellow,function(){
|
||||
describe(".toStringSync()".yellow,function(){
|
||||
it("should read a file to a string",function(){
|
||||
should.equal(
|
||||
smartfile.local.toStringSync("./test/mytest.txt"),
|
||||
smartfile.fs.toStringSync("./test/mytest.txt"),
|
||||
"Some TestString &&%$"
|
||||
);
|
||||
});
|
||||
});
|
||||
describe(".toVinylSync".yellow,function(){
|
||||
it("should read an " + ".json OR .yaml".blue + " file to an " + "vinyl file object".cyan,function(){
|
||||
let testData = smartfile.local.toVinylSync("./test/mytest.json");
|
||||
let testData = smartfile.fs.toVinylSync("./test/mytest.json");
|
||||
(vinyl.isVinyl(testData)).should.be.true();
|
||||
|
||||
});
|
||||
@ -179,7 +177,7 @@ describe("smartfile".yellow,function(){
|
||||
describe("toGulpStreamSync()",function(){
|
||||
it("should produce a gulp stream",function(done){
|
||||
smartfile.remote.toGulpStreamSync("mytest.txt","https://raw.githubusercontent.com/pushrocks/smartfile/master/test/")
|
||||
.pipe(smartfile.local.toGulpDestSync("./test/temp/"))
|
||||
.pipe(smartfile.fs.toGulpDestSync("./test/temp/"))
|
||||
.pipe(gFunction(done,"atEnd"));
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user