now has better structure
This commit is contained in:
50
test/test.ts
50
test/test.ts
@@ -3,24 +3,38 @@ let should = require("should");
|
||||
let smartpath = require("../dist/index.js");
|
||||
|
||||
describe("smartpath",function(){
|
||||
describe("absolute()",function(){
|
||||
let baseString = "/basedir"
|
||||
let relativeString = "somedir/somefile.txt";
|
||||
let relativeString2 = "anotherdir/anotherfile.txt";
|
||||
let relativeArray = [relativeString,relativeString,relativeString2];
|
||||
it("should make a string absolute",function(){
|
||||
smartpath.absolute(relativeString).should.startWith("/");
|
||||
smartpath.absolute(relativeString).should.endWith(relativeString);
|
||||
smartpath.absolute(relativeString,baseString).should.equal("/basedir/somedir/somefile.txt");
|
||||
});
|
||||
it("should make an array of relative Strings an Array of absolute Strings",function(){
|
||||
let absoluteArray = smartpath.absolute(relativeArray);
|
||||
absoluteArray[2].should.startWith("/");
|
||||
absoluteArray[2].should.endWith(relativeString2);
|
||||
describe(".transform",function(){
|
||||
describe("toAbsolute()",function(){
|
||||
let baseString = "/basedir";
|
||||
let relativeString = "somedir/somefile.txt";
|
||||
let relativeString2 = "anotherdir/anotherfile.txt";
|
||||
let 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(){
|
||||
let absoluteArray = smartpath.transform.toAbsolute(relativeArray);
|
||||
absoluteArray[2].should.startWith("/");
|
||||
absoluteArray[2].should.endWith(relativeString2);
|
||||
|
||||
})
|
||||
it("should return false if neither String nor Array",function(){
|
||||
smartpath.absolute(3).should.be.false();
|
||||
})
|
||||
it("should return false if neither String nor Array",function(){
|
||||
smartpath.transform.toAbsolute(3).should.be.false();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
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");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user