-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathpath.test.ts
33 lines (31 loc) · 1.44 KB
/
path.test.ts
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
import { basename, dirname } from '../src/path';
describe('path', () => {
describe('basename', () => {
test('unix', () => {
expect(basename('/foo/bar/baz/asdf/quux.html')).toEqual('quux.html');
expect(basename('foo/bar/baz/asdf/quux.html')).toEqual('quux.html');
expect(basename('../baz/asdf/quux.html')).toEqual('quux.html');
expect(basename('quux.html')).toEqual('quux.html');
});
test('windows', () => {
expect(basename('c:\\foo\\bar\\baz\\asdf\\quux.html')).toEqual('quux.html');
expect(basename('\\foo\\bar\\baz\\asdf\\quux.html')).toEqual('quux.html');
expect(basename('..\\bar\\baz\\asdf\\quux.html')).toEqual('quux.html');
expect(basename('quux.html')).toEqual('quux.html');
});
});
describe('dirname', () => {
test('unix', () => {
expect(dirname('/foo/bar/baz/asdf/quux.html')).toEqual('/foo/bar/baz/asdf');
expect(dirname('foo/bar/baz/asdf/quux.html')).toEqual('foo/bar/baz/asdf');
expect(dirname('../baz/asdf/quux.html')).toEqual('../baz/asdf');
expect(dirname('/quux.html')).toEqual('/');
});
test('windows', () => {
expect(dirname('C:\\foo\\bar\\baz\\asdf\\quux.html')).toEqual('C:\\foo\\bar\\baz\\asdf');
expect(dirname('\\foo\\bar\\baz\\asdf\\quux.html')).toEqual('\\foo\\bar\\baz\\asdf');
expect(dirname('..\\bar\\baz\\asdf\\quux.html')).toEqual('..\\bar\\baz\\asdf');
expect(dirname('quux.html')).toEqual('.');
});
});
});