-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
30 lines (26 loc) · 1.1 KB
/
test.js
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
'use strict';
require('mocha');
var assert = require('assert');
var isRelative = require('./');
describe('isRelative', function() {
it('should throw an error when the value is not a string.', function() {
assert.throws(function() {
isRelative();
}, 'isRelative expects a string.');
});
it('should return true if the path appears to be relative', function() {
assert.equal(isRelative('test/fixtures'), true);
assert.equal(isRelative('test/fixtures/'), true);
assert.equal(isRelative('test/fixtures/foo.txt'), true);
assert.equal(isRelative('./test/fixtures/foo.txt'), true);
assert.equal(isRelative('./test/fixtures/foo.txt'), true);
});
it('should return false if the path does not appear to be relative', function() {
assert.equal(isRelative('/test/fixtures'), false);
assert.equal(isRelative('/test/fixtures/'), false);
assert.equal(isRelative('/test/fixtures/baz.md'), false);
assert.equal(isRelative('e://test/fixtures/'), false);
assert.equal(isRelative('e:/test/fixtures/'), false);
assert.equal(isRelative('\\test\\fixtures\\'), false);
});
});