File: add-tests.patch

package info (click to toggle)
node-path-root-regex 0.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 92 kB
  • ctags: 4
  • sloc: makefile: 4; sh: 2
file content (33 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (3)
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
--- /dev/null
+++ b/test.js
@@ -0,0 +1,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'), '/');
+  });
+});