Skip to content

Commit c589c0f

Browse files
committed
Port test-path-dirname.
1 parent fc1c3f3 commit c589c0f

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

test/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
require('./test-path-basename');
2+
require('./test-path-dirname');

test/test-path-dirname.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use strict';
2+
var tape = require('tape');
3+
var path = require('../');
4+
5+
tape('path.posix.dirname', function (t) {
6+
t.strictEqual(path.posix.dirname('/a/b/'), '/a');
7+
t.strictEqual(path.posix.dirname('/a/b'), '/a');
8+
t.strictEqual(path.posix.dirname('/a'), '/');
9+
t.strictEqual(path.posix.dirname(''), '.');
10+
t.strictEqual(path.posix.dirname('/'), '/');
11+
t.strictEqual(path.posix.dirname('////'), '/');
12+
t.strictEqual(path.posix.dirname('//a'), '//');
13+
t.strictEqual(path.posix.dirname('foo'), '.');
14+
t.end();
15+
});
16+
17+
tape('path.win32.dirname', { skip: true }, function (t) {
18+
t.strictEqual(path.win32.dirname('c:\\'), 'c:\\');
19+
t.strictEqual(path.win32.dirname('c:\\foo'), 'c:\\');
20+
t.strictEqual(path.win32.dirname('c:\\foo\\'), 'c:\\');
21+
t.strictEqual(path.win32.dirname('c:\\foo\\bar'), 'c:\\foo');
22+
t.strictEqual(path.win32.dirname('c:\\foo\\bar\\'), 'c:\\foo');
23+
t.strictEqual(path.win32.dirname('c:\\foo\\bar\\baz'), 'c:\\foo\\bar');
24+
t.strictEqual(path.win32.dirname('\\'), '\\');
25+
t.strictEqual(path.win32.dirname('\\foo'), '\\');
26+
t.strictEqual(path.win32.dirname('\\foo\\'), '\\');
27+
t.strictEqual(path.win32.dirname('\\foo\\bar'), '\\foo');
28+
t.strictEqual(path.win32.dirname('\\foo\\bar\\'), '\\foo');
29+
t.strictEqual(path.win32.dirname('\\foo\\bar\\baz'), '\\foo\\bar');
30+
t.strictEqual(path.win32.dirname('c:'), 'c:');
31+
t.strictEqual(path.win32.dirname('c:foo'), 'c:');
32+
t.strictEqual(path.win32.dirname('c:foo\\'), 'c:');
33+
t.strictEqual(path.win32.dirname('c:foo\\bar'), 'c:foo');
34+
t.strictEqual(path.win32.dirname('c:foo\\bar\\'), 'c:foo');
35+
t.strictEqual(path.win32.dirname('c:foo\\bar\\baz'), 'c:foo\\bar');
36+
t.strictEqual(path.win32.dirname('file:stream'), '.');
37+
t.strictEqual(path.win32.dirname('dir\\file:stream'), 'dir');
38+
t.strictEqual(path.win32.dirname('\\\\unc\\share'),
39+
'\\\\unc\\share');
40+
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo'),
41+
'\\\\unc\\share\\');
42+
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\'),
43+
'\\\\unc\\share\\');
44+
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar'),
45+
'\\\\unc\\share\\foo');
46+
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar\\'),
47+
'\\\\unc\\share\\foo');
48+
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar\\baz'),
49+
'\\\\unc\\share\\foo\\bar');
50+
t.strictEqual(path.win32.dirname('/a/b/'), '/a');
51+
t.strictEqual(path.win32.dirname('/a/b'), '/a');
52+
t.strictEqual(path.win32.dirname('/a'), '/');
53+
t.strictEqual(path.win32.dirname(''), '.');
54+
t.strictEqual(path.win32.dirname('/'), '/');
55+
t.strictEqual(path.win32.dirname('////'), '/');
56+
t.strictEqual(path.win32.dirname('foo'), '.');
57+
t.end();
58+
});

0 commit comments

Comments
 (0)