This commit is contained in:
2016-03-14 03:50:14 +01:00
parent 0ad455a483
commit 641218e841
24 changed files with 309 additions and 294 deletions

5
test/test.d.ts vendored
View File

@ -1,5 +0,0 @@
/// <reference path="ts/typings/main.d.ts" />
declare var smartfile: any;
declare var beautylog: any;
declare var should: any;
declare var vinyl: any;

View File

@ -1,7 +1,5 @@
#!/usr/bin/env node
/// <reference path="typings/main.d.ts" />
var smartfile = require("../index.js");
/// <reference path="../ts/typings/main.d.ts" />
var smartfile = require("../dist/index.js");
var beautylog = require("beautylog");
var should = require("should");
var vinyl = require("vinyl");
@ -17,6 +15,9 @@ describe("smartfile", function () {
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 () {
var testData = smartfile.readFileToObject("./test/mytest.txt");
});
it("should read an " + ".json".blue + " file to an object", function () {
var testData = smartfile.readFileToObject("./test/mytest.json");
testData.should.have.property("key1", "this works");
@ -44,4 +45,16 @@ describe("smartfile", function () {
});
});
});
describe("copy", function () {
it("should copy a directory", function () {
smartfile.copy("./test/testfolder/", "./test/assets/");
});
it("should copy a file", function () {
smartfile.copy("./test/mytest.yaml", "./test/assets/");
});
it("should copy a file and rename it", function () {
smartfile.copy("./test/mytest.yaml", "./test/assets/mytestRenamed.yaml");
});
});
});
//# sourceMappingURL=test.js.map

1
test/test.js.map Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC5C,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7B,QAAQ,CAAC,WAAW,EAAC;IACjB,QAAQ,CAAC,mBAAmB,CAAC,MAAM,EAAC;QAChC,E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D,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,oBAAoB,EAAC;YACpB,SAAS,CAAC,IAAI,CAAC,oBAAoB,EAAC,gBAAgB,CAAC,CAAA;QACzD,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,kCAAkC,EAAC;YAClC,SAAS,CAAC,IAAI,CAAC,oBAAoB,EAAC,kCAAkC,CAAC,CAAA;QAC3E,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

66
test/test.ts Normal file
View File

@ -0,0 +1,66 @@
/// <reference path="../ts/typings/main.d.ts" />
var smartfile = require("../dist/index.js");
var beautylog = require("beautylog");
var should = require("should");
var vinyl = require("vinyl");
describe("smartfile",function(){
describe(".readFileToString".yellow,function(){
it("should read a file to a string",function(){
should.equal(
smartfile.readFileToString("./test/mytest.txt"),
"Some TestString &&%$"
);
});
});
describe(".readFileToObject".yellow,function(){
it("should read an " + ".yaml".blue + " file to an object",function(){
var testData = smartfile.readFileToObject("./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(){
var testData = smartfile.readFileToObject("./test/mytest.txt");
});
it("should read an " + ".json".blue + " file to an object",function(){
var testData = smartfile.readFileToObject("./test/mytest.json");
testData.should.have.property("key1","this works");
testData.should.have.property("key2","this works too");
});
});
describe(".readFileToVinyl".yellow,function(){
it("should read an " + ".json OR .yaml".blue + " file to an " + "vinyl file object".cyan,function(){
var testData = smartfile.readFileToVinyl("./test/mytest.json");
(vinyl.isVinyl(testData)).should.be.true();
});
});
describe(".checks".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();
});
});
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();
});
})
});
describe("copy",function(){
it("should copy a directory",function(){
smartfile.copy("./test/testfolder/","./test/assets/")
});
it("should copy a file",function(){
smartfile.copy("./test/mytest.yaml","./test/assets/")
});
it("should copy a file and rename it",function(){
smartfile.copy("./test/mytest.yaml","./test/assets/mytestRenamed.yaml")
});
});
});

View File

View File