27 lines
4.3 KiB
JavaScript
27 lines
4.3 KiB
JavaScript
|
/// <reference path="../ts/typings/main.d.ts" />
|
||
|
var should = require("should");
|
||
|
var smartpath = require("../dist/index.js");
|
||
|
describe("smartpath", function () {
|
||
|
describe("absolute()", 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.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 () {
|
||
|
var absoluteArray = smartpath.absolute(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();
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUMvQixJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUU1QyxRQUFRLENBQUMsV0FBVyxFQUFDO0lBQ2pCLFFBQVEsQ0FBQyxZQUFZLEVBQUM7UUFDbEIsSUFBSSxVQUFVLEdBQUcsVUFBVSxDQUFBO1FBQzNCLElBQUksY0FBYyxHQUFHLHNCQUFzQixDQUFDO1FBQzVDLElBQUksZUFBZSxHQUFHLDRCQUE0QixDQUFDO1FBQ25ELElBQUksYUF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