-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
41 lines (34 loc) · 1.7 KB
/
Copy pathtest.js
File metadata and controls
41 lines (34 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*!
* relative-dest <https://github.com/jonschlinkert/relative-dest>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT License
*/
'use strict';
var assert = require('assert');
var relative = require('./');
it('should return the filepath when one arg is passed:', function () {
assert.equal(relative('dist/a/b/c.md'), 'dist/a/b/c.md');
assert.equal(relative('/dist/a/b/c.md'), '/dist/a/b/c.md');
assert.equal(relative('/dist/a/b/'), '/dist/a/b/');
});
it('should calculate the relative path to the given directory', function () {
assert.equal(relative('dist/a/b/c.md', 'dist/public'), '../../public');
assert.equal(relative('dist/a/b/c.md', 'assets'), '../../../assets');
assert.equal(relative('a.md', 'dist/public/css'), 'dist/public/css');
});
it('should detect when source and result path are the same', function () {
assert.equal(relative('a/b/c/', 'a/b/c/'), './');
assert.equal(relative('a/b/c/', 'a/b/c'), './');
assert.equal(relative('a/b/c', 'a/b/c'), '.');
});
it('should determine trailing slash based on source paths:', function () {
assert.equal(relative('a.md', 'dist/public/css', true), 'dist/public/css');
assert.equal(relative('a/b', 'dist/public/css', true), '../../dist/public/css');
assert.equal(relative('a/b/', 'dist/public/css', true), '../../dist/public/css/');
assert.equal(relative('a/b/a.md', 'dist/public/css', true), '../../dist/public/css');
assert.equal(relative('dist/a/', 'assets', true), '../../assets/');
assert.equal(relative('dist/a', 'assets/', true), '../../assets');
assert.equal(relative('dist/a/b/c/', 'dist/assets', true), '../../../assets/');
assert.equal(relative('dist/a/b/c/', 'dist/assets/', true), '../../../assets/');
});