BREAKING CHANGE(package): change scope

This commit is contained in:
2018-07-21 23:26:11 +02:00
parent 09d424e972
commit 53905df003
30 changed files with 1185 additions and 636 deletions

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,76 +0,0 @@
"use strict";
require("typings-test");
const smartchai_1 = require("smartchai");
const smartpath = require("../dist/index.js");
describe('smartpath', function () {
describe('class Smartpath', function () {
let mySmartpath;
it('expect create a valid instance', function () {
mySmartpath = new smartpath.Smartpath('/some/path/to/some.file');
smartchai_1.expect(mySmartpath).to.be.instanceof(smartpath.Smartpath);
smartchai_1.expect(mySmartpath.pathLevelsBackwards).to.be.of.length(5);
});
});
describe('.check', function () {
let filePathString = './somedir/somefile.json';
let dirPathString = './somedir/anotherdir';
let dirPathString2 = './somedir/another.dir/';
describe('.isFile', function () {
it('expect be true for a file path', function () {
smartchai_1.expect(smartpath.check.isFile(filePathString)).to.be.true;
});
it('expect be false for a directory path', function () {
smartchai_1.expect(smartpath.check.isFile(dirPathString)).to.be.false;
smartchai_1.expect(smartpath.check.isFile(dirPathString2)).to.be.false;
});
});
describe('.isDir', function () {
it('expect be true for a directory path', function () {
smartchai_1.expect(smartpath.check.isDir(dirPathString)).to.be.true;
smartchai_1.expect(smartpath.check.isDir(dirPathString2)).to.be.true;
});
it('expect be false for a file path', function () {
smartchai_1.expect(smartpath.check.isDir(filePathString)).to.be.false;
});
});
});
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('expect make a string absolute', function () {
smartchai_1.expect(smartpath.transform.toAbsolute(relativeString)).startWith('/');
smartchai_1.expect(smartpath.transform.toAbsolute(relativeString)).endWith(relativeString);
smartchai_1.expect(smartpath.transform.toAbsolute(relativeString, baseString)).equal('/basedir/somedir/somefile.txt');
});
it('expect make an array of relative Strings an Array of absolute Strings', function () {
let absoluteArray = smartpath.transform.toAbsolute(relativeArray, baseString);
smartchai_1.expect(absoluteArray[2]).to.startWith('/');
smartchai_1.expect(absoluteArray[2]).endWith(relativeString2);
});
});
});
describe('.get', function () {
describe('.type()', function () {
it("expect return 'url' for an URL", function () {
smartchai_1.expect(smartpath.get.type('https://push.rocks/some/url')).equal('url');
smartchai_1.expect(smartpath.get.type('https://push.rocks/some/url')).not.equal('local');
});
it("expect return 'path' for a Path", function () {
smartchai_1.expect(smartpath.get.type('/some/absolute/path/')).equal('local');
smartchai_1.expect(smartpath.get.type('./some/relative/path/')).not.equal('url');
});
});
describe('.get()', function () {
it('expect a absolute path for an home relative URL', function () {
console.log(smartpath.get.home('~/test'));
});
it('expect return the home directory path when no argument is specified', function () {
console.log(smartpath.get.home());
});
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQix5Q0FBa0M7QUFDbEMsOENBQTZDO0FBRTdDLFFBQVEsQ0FBQyxXQUFXLEVBQUU7SUFDcEIsUUFBUSxDQUFDLGlCQUFpQixFQUFFO1FBQzFCLElBQUksV0FBZ0MsQ0FBQTtRQUNwQyxFQUFFLENBQUMsZ0NBQWdDLEVBQUU7WUFDbkMsV0FBVyxHQUFHLElBQUksU0FBUyxDQUFDLFNBQVMsQ0FBQyx5QkFBeUIsQ0FBQyxDQUFBO1lBQ2hFLGtCQUFNLENBQUMsV0FBVyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFBO1lBQ3pELGtCQUFNLENBQUMsV0FBVyxDQUFDLG1CQUFtQixDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsTUFBTSxD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M,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAChF,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,iCAAiC,EAAC;gBACjC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACjE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,QAAQ,EAAC;YACd,EAAE,CAAC,iDAAiD,EAAC;gBACjD,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,qEAAqE,EAAC;gBACrE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -1,92 +1,66 @@
import 'typings-test'
import { expect } from 'smartchai'
import * as smartpath from '../dist/index.js'
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartpath from '../ts/index';
describe('smartpath', function () {
describe('class Smartpath', function () {
let mySmartpath: smartpath.Smartpath
it('expect create a valid instance', function () {
mySmartpath = new smartpath.Smartpath('/some/path/to/some.file')
expect(mySmartpath).to.be.instanceof(smartpath.Smartpath)
expect(mySmartpath.pathLevelsBackwards).to.be.of.length(5)
})
})
describe('.check', function () {
let filePathString = './somedir/somefile.json'
let dirPathString = './somedir/anotherdir'
let dirPathString2 = './somedir/another.dir/'
describe('.isFile', function () {
it('expect be true for a file path', function () {
expect(
smartpath.check.isFile(filePathString)
).to.be.true
})
it('expect be false for a directory path', function () {
expect(
smartpath.check.isFile(dirPathString)
).to.be.false
expect(
smartpath.check.isFile(dirPathString2)
).to.be.false
})
})
describe('.isDir', function () {
it('expect be true for a directory path', function () {
let mySmartpath: smartpath.Smartpath;
tap.test('expect create a valid instance', async () => {
mySmartpath = new smartpath.Smartpath('/some/path/to/some.file');
expect(mySmartpath).to.be.instanceof(smartpath.Smartpath);
expect(mySmartpath.pathLevelsBackwards).to.be.of.length(5);
});
expect(
smartpath.check.isDir(dirPathString)
).to.be.true
let filePathString = './somedir/somefile.json';
let dirPathString = './somedir/anotherdir';
let dirPathString2 = './somedir/another.dir/';
expect(
smartpath.check.isDir(dirPathString2)
).to.be.true
tap.test('expect be true for a file path', async () => {
expect(smartpath.check.isFile(filePathString)).to.be.true;
});
tap.test('expect be false for a directory path', async () => {
expect(smartpath.check.isFile(dirPathString)).to.be.false;
expect(smartpath.check.isFile(dirPathString2)).to.be.false;
});
})
tap.test('expect be true for a directory path', async () => {
expect(smartpath.check.isDir(dirPathString)).to.be.true;
it('expect be false for a file path', function () {
expect(
smartpath.check.isDir(filePathString)
).to.be.false
})
})
})
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('expect make a string absolute', function () {
expect(smartpath.transform.toAbsolute(relativeString)).startWith('/')
expect(smartpath.transform.toAbsolute(relativeString)).endWith(relativeString)
expect(smartpath.transform.toAbsolute(relativeString, baseString)).equal('/basedir/somedir/somefile.txt')
})
it('expect make an array of relative Strings an Array of absolute Strings', function () {
let absoluteArray = smartpath.transform.toAbsolute(relativeArray, baseString)
expect(absoluteArray[ 2 ]).to.startWith('/')
expect(absoluteArray[ 2 ]).endWith(relativeString2)
expect(smartpath.check.isDir(dirPathString2)).to.be.true;
});
})
})
})
describe('.get', function () {
describe('.type()', function () {
it("expect return 'url' for an URL", function () {
expect(smartpath.get.type('https://push.rocks/some/url')).equal('url')
expect(smartpath.get.type('https://push.rocks/some/url')).not.equal('local')
})
it("expect return 'path' for a Path", function () {
expect(smartpath.get.type('/some/absolute/path/')).equal('local')
expect(smartpath.get.type('./some/relative/path/')).not.equal('url')
})
})
describe('.get()', function () {
it('expect a absolute path for an home relative URL', function () {
console.log(smartpath.get.home('~/test'))
})
it('expect return the home directory path when no argument is specified', function () {
console.log(smartpath.get.home())
})
})
})
})
tap.test('expect be false for a file path', async () => {
expect(smartpath.check.isDir(filePathString)).to.be.false;
});
let baseString = '/basedir';
let relativeString = 'somedir/somefile.txt';
let relativeString2 = 'anotherdir/anotherfile.txt';
let relativeArray = [relativeString, relativeString, relativeString2];
tap.test('expect make a string absolute', async () => {
expect(smartpath.transform.toAbsolute(relativeString)).startWith('/');
expect(smartpath.transform.toAbsolute(relativeString)).endWith(relativeString);
expect(smartpath.transform.toAbsolute(relativeString, baseString)).equal(
'/basedir/somedir/somefile.txt'
);
});
tap.test('expect make an array of relative Strings an Array of absolute Strings', async () => {
let absoluteArray = smartpath.transform.toAbsolute(relativeArray, baseString);
expect(absoluteArray[2]).to.startWith('/');
expect(absoluteArray[2]).endWith(relativeString2);
});
tap.test("expect return 'url' for an URL", async () => {
expect(smartpath.get.type('https://push.rocks/some/url')).equal('url');
expect(smartpath.get.type('https://push.rocks/some/url')).not.equal('local');
});
tap.test("expect return 'path' for a Path", async () => {
expect(smartpath.get.type('/some/absolute/path/')).equal('local');
expect(smartpath.get.type('./some/relative/path/')).not.equal('url');
});
tap.test('expect a absolute path for an home relative URL', async () => {
console.log(smartpath.get.home('~/test'));
});
tap.test('expect return the home directory path when no argument is specified', async () => {
console.log(smartpath.get.home());
});
tap.start();