2016-05-24 15:06:59 +03:00
|
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
2015-02-18 23:02:48 +03:00
|
|
|
|
2015-10-06 19:31:03 +03:00
|
|
|
describe('Unit: Util: ghost-paths', function () {
|
2015-02-18 23:02:48 +03:00
|
|
|
describe('join', function () {
|
2016-04-08 18:00:16 +03:00
|
|
|
let {join} = ghostPaths().url;
|
2015-02-18 23:02:48 +03:00
|
|
|
|
|
|
|
it('should join two or more paths, normalizing slashes', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let path;
|
2015-02-18 23:02:48 +03:00
|
|
|
|
|
|
|
path = join('/one/', '/two/');
|
|
|
|
expect(path).to.equal('/one/two/');
|
|
|
|
|
|
|
|
path = join('/one', '/two/');
|
|
|
|
expect(path).to.equal('/one/two/');
|
|
|
|
|
|
|
|
path = join('/one/', 'two/');
|
|
|
|
expect(path).to.equal('/one/two/');
|
|
|
|
|
|
|
|
path = join('/one/', 'two/', '/three/');
|
|
|
|
expect(path).to.equal('/one/two/three/');
|
|
|
|
|
|
|
|
path = join('/one/', 'two', 'three/');
|
|
|
|
expect(path).to.equal('/one/two/three/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not change the slash at the beginning', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let path;
|
2015-02-18 23:02:48 +03:00
|
|
|
|
|
|
|
path = join('one/');
|
|
|
|
expect(path).to.equal('one/');
|
|
|
|
path = join('one/', 'two');
|
|
|
|
expect(path).to.equal('one/two/');
|
|
|
|
path = join('/one/', 'two');
|
|
|
|
expect(path).to.equal('/one/two/');
|
|
|
|
path = join('one/', 'two', 'three');
|
|
|
|
expect(path).to.equal('one/two/three/');
|
|
|
|
path = join('/one/', 'two', 'three');
|
|
|
|
expect(path).to.equal('/one/two/three/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should always return a slash at the end', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let path;
|
2015-02-18 23:02:48 +03:00
|
|
|
|
|
|
|
path = join();
|
|
|
|
expect(path).to.equal('/');
|
|
|
|
path = join('');
|
|
|
|
expect(path).to.equal('/');
|
|
|
|
path = join('one');
|
|
|
|
expect(path).to.equal('one/');
|
|
|
|
path = join('one/');
|
|
|
|
expect(path).to.equal('one/');
|
|
|
|
path = join('one', 'two');
|
|
|
|
expect(path).to.equal('one/two/');
|
|
|
|
path = join('one', 'two/');
|
|
|
|
expect(path).to.equal('one/two/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|