forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
path.spec.ts
95 lines (61 loc) · 2.16 KB
/
path.spec.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import {
expect
} from 'chai';
import {
PathExt
} from '@jupyterlab/coreutils';
const TESTPATH = 'foo/test/simple/test-path.js';
describe('@jupyterlab/coreutils', () => {
describe('PathExt', () => {
describe('.join()', () => {
it('should join the arguments and normalize the path', () => {
let path = PathExt.join('foo', '../../../bar');
expect(path).to.equal('../../bar');
});
});
describe('.basename()', () => {
it('should return the last portion of a path', () => {
expect(PathExt.basename(TESTPATH)).to.equal('test-path.js');
});
});
describe('.dirname()', () => {
it('should get the directory name of a path', () => {
expect(PathExt.dirname(TESTPATH)).to.equal('foo/test/simple');
});
});
describe('.extname()', () => {
it('should get the file extension of the path', () => {
expect(PathExt.extname(TESTPATH)).to.equal('.js');
});
it('should only take the last occurance of a dot', () => {
expect(PathExt.extname('foo.tar.gz')).to.equal('.gz');
});
});
describe('.normalize()', () => {
it('should normalize a string path', () => {
let path = PathExt.normalize('./fixtures///b/../b/c.js');
expect(path).to.equal('fixtures/b/c.js');
});
});
describe('.resolve()', () => {
it('should resolve a sequence of paths to an absolute path on the server', () => {
let path = PathExt.resolve('var/lib', '../', 'file/');
expect(path).to.equal('var/file');
});
});
describe('.relative()', () => {
it('should solve the relative path', () => {
let path = PathExt.relative('var/lib', 'var/apache');
expect(path).to.equal('../apache');
});
});
describe('.normalizeExtension()', () => {
it('should normalize a file extension to be of type `.foo`', () => {
expect(PathExt.normalizeExtension('foo')).to.equal('.foo');
expect(PathExt.normalizeExtension('.bar')).to.equal('.bar');
});
});
});
});