-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
30 lines (25 loc) · 964 Bytes
/
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 regex = require('./');
function match(str) {
var m = regex().exec(str);
return m ? m[0] : null;
}
describe('path-root-regex', function() {
it('should export a function', function() {
assert.equal(typeof regex, 'function');
});
it('should return a regex when called', function() {
assert(regex() instanceof RegExp);
});
it('should match the root of a filepath', function() {
assert.equal(match('\\\\server\\share\\abc'), '\\\\server\\share\\');
assert.equal(match('\\\\server foo\\some folder\\base-file.js'), '\\\\server foo\\some folder\\');
assert.equal(match('\\\\?\\UNC\\server\\share'), '\\\\?\\UNC\\');
assert.equal(match('foo/bar/baz.js'), '');
assert.equal(match('c:\\foo\\bar\\baz.js'), 'c:\\');
assert.equal(match('\\\\slslslsl\\admin$\\system32'), '\\\\slslslsl\\admin$\\');
assert.equal(match('/foo/bar/baz.js'), '/');
});
});