source: trip-planner-front/node_modules/commondir/test/dirs.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[6a3a178]1var test = require('tape');
2var commondir = require('../');
3
4test('common', function (t) {
5 t.equal(
6 commondir([ '/foo', '//foo/bar', '/foo//bar/baz' ]),
7 '/foo'
8 );
9 t.equal(
10 commondir([ '/a/b/c', '/a/b', '/a/b/c/d/e' ]),
11 '/a/b'
12 );
13 t.equal(
14 commondir([ '/x/y/z/w', '/xy/z', '/x/y/z' ]),
15 '/'
16 );
17 t.equal(
18 commondir([ 'X:\\foo', 'X:\\\\foo\\bar', 'X://foo/bar/baz' ]),
19 'X:/foo'
20 );
21 t.equal(
22 commondir([ 'X:\\a\\b\\c', 'X:\\a\\b', 'X:\\a\\b\\c\\d\\e' ]),
23 'X:/a/b'
24 );
25 t.equal(
26 commondir([ 'X:\\x\\y\\z\\w', '\\\\xy\\z', '\\x\\y\\z' ]),
27 '/'
28 );
29 t.throws(function () {
30 commondir([ '/x/y/z/w', 'qrs', '/x/y/z' ]);
31 });
32 t.end();
33});
34
35test('base', function (t) {
36 t.equal(
37 commondir('/foo/bar', [ 'baz', './quux', '../bar/bazzy' ]),
38 '/foo/bar'
39 );
40 t.equal(
41 commondir('/a/b', [ 'c', '../b/.', '../../a/b/e' ]),
42 '/a/b'
43 );
44 t.equal(
45 commondir('/a/b/c', [ '..', '../d', '../../a/z/e' ]),
46 '/a'
47 );
48 t.equal(
49 commondir('/foo/bar', [ 'baz', '.\\quux', '..\\bar\\bazzy' ]),
50 '/foo/bar'
51 );
52 // Tests including X:\ basedirs must wait until path.resolve supports
53 // Windows-style paths, starting in Node.js v0.5.X
54 t.end();
55});
Note: See TracBrowser for help on using the repository browser.