2016-03-12 08:36:30 +00:00
|
|
|
/// <reference path="../ts/typings/main.d.ts" />
|
|
|
|
var should = require("should");
|
|
|
|
var smartpath = require("../dist/index.js");
|
|
|
|
describe("smartpath", function () {
|
2016-04-30 09:02:03 +00:00
|
|
|
describe(".check", function () {
|
|
|
|
var filePathString = "./somedir/somefile.json";
|
|
|
|
var dirPathString = "./somedir/anotherdir";
|
|
|
|
var dirPathString2 = "./somedir/another.dir/";
|
|
|
|
describe(".isFile", function () {
|
|
|
|
it("should be true for a file path", function () {
|
|
|
|
smartpath.check.isFile(filePathString)
|
|
|
|
.should.be.true();
|
|
|
|
});
|
|
|
|
it("should be false for a directory path", function () {
|
|
|
|
smartpath.check.isFile(dirPathString)
|
|
|
|
.should.be.false();
|
|
|
|
smartpath.check.isFile(dirPathString2)
|
|
|
|
.should.be.false();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe(".isDir", function () {
|
|
|
|
it("should be true for a directory path", function () {
|
|
|
|
smartpath.check.isDir(dirPathString)
|
|
|
|
.should.be.true();
|
|
|
|
smartpath.check.isDir(dirPathString2)
|
|
|
|
.should.be.true();
|
|
|
|
});
|
|
|
|
it("should be false for a file path", function () {
|
|
|
|
smartpath.check.isDir(filePathString)
|
|
|
|
.should.be.false();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2016-03-20 17:59:30 +00:00
|
|
|
describe(".transform", function () {
|
|
|
|
describe("toAbsolute()", function () {
|
|
|
|
var baseString = "/basedir";
|
|
|
|
var relativeString = "somedir/somefile.txt";
|
|
|
|
var relativeString2 = "anotherdir/anotherfile.txt";
|
|
|
|
var relativeArray = [relativeString, relativeString, relativeString2];
|
|
|
|
it("should make a string absolute", function () {
|
|
|
|
smartpath.transform.toAbsolute(relativeString).should.startWith("/");
|
|
|
|
smartpath.transform.toAbsolute(relativeString).should.endWith(relativeString);
|
|
|
|
smartpath.transform.toAbsolute(relativeString, baseString).should.equal("/basedir/somedir/somefile.txt");
|
|
|
|
});
|
|
|
|
it("should make an array of relative Strings an Array of absolute Strings", function () {
|
2016-03-26 11:07:17 +00:00
|
|
|
var absoluteArray = smartpath.transform.toAbsolute(relativeArray, baseString);
|
2016-03-20 17:59:30 +00:00
|
|
|
absoluteArray[2].should.startWith("/");
|
|
|
|
absoluteArray[2].should.endWith(relativeString2);
|
|
|
|
});
|
|
|
|
it("should return false if neither String nor Array", function () {
|
|
|
|
smartpath.transform.toAbsolute(3).should.be.false();
|
|
|
|
});
|
2016-03-12 08:36:30 +00:00
|
|
|
});
|
2016-03-20 17:59:30 +00:00
|
|
|
});
|
|
|
|
describe(".get", function () {
|
|
|
|
describe(".type()", function () {
|
|
|
|
it("should return 'url' for an URL", function () {
|
|
|
|
smartpath.get.type("https://push.rocks/some/url").should.equal("url");
|
|
|
|
smartpath.get.type("https://push.rocks/some/url").should.not.equal("local");
|
|
|
|
});
|
|
|
|
it("should return 'path' for a Path", function () {
|
|
|
|
smartpath.get.type("/some/absolute/path/").should.equal("local");
|
|
|
|
smartpath.get.type("./some/relative/path/").should.not.equal("url");
|
|
|
|
});
|
2016-03-12 08:36:30 +00:00
|
|
|
});
|
2016-04-04 14:25:17 +00:00
|
|
|
describe(".get()", function () {
|
|
|
|
it("should a absolute path for an home relative URL", function () {
|
|
|
|
console.log(smartpath.get.home("~/test"));
|
|
|
|
});
|
|
|
|
it("should return the home directory path when no argument is specified", function () {
|
|
|
|
console.log(smartpath.get.home());
|
|
|
|
});
|
|
|
|
});
|
2016-03-12 08:36:30 +00:00
|
|
|
});
|
|
|
|
});
|
2016-04-30 09:02:03 +00:00
|
|
|
|
2016-04-30 10:07:49 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUMv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