1 | var path = require('./index');
|
---|
2 | const s = path.sep;
|
---|
3 |
|
---|
4 | describe("canonical-path", function() {
|
---|
5 | describe("normalize", function() {
|
---|
6 | it("should return a normalized path only using forward slashes", function() {
|
---|
7 | expect(path.normalize('a/c/../b')).toEqual('a/b');
|
---|
8 | expect(path.normalize(`a${s}c${s}..${s}b`)).toEqual('a/b');
|
---|
9 | });
|
---|
10 | });
|
---|
11 |
|
---|
12 | describe("join", function() {
|
---|
13 | it("should join paths only using forward slashes", function() {
|
---|
14 | expect(path.join('a/b', 'c/d')).toEqual('a/b/c/d');
|
---|
15 | expect(path.join(`a${s}b`, `c${s}d`)).toEqual('a/b/c/d');
|
---|
16 | });
|
---|
17 | });
|
---|
18 |
|
---|
19 | describe("resolve", function() {
|
---|
20 | it("should return a resolved path only using forward slashes", function() {
|
---|
21 | expect(path.resolve('/a/b', 'x/../c')).toEqual(path.resolve('/') + 'a/b/c');
|
---|
22 | expect(path.resolve(`a${s}c${s}..${s}b`)).toEqual(path.resolve('') + '/a/b');
|
---|
23 | });
|
---|
24 | });
|
---|
25 |
|
---|
26 | describe("relative", function() {
|
---|
27 | it("should return a relative path only using forward slashes", function() {
|
---|
28 | expect(path.relative('a/b', 'a/d/e/f')).toEqual('../d/e/f');
|
---|
29 | expect(path.relative(`a${s}b`, `a${s}d${s}e${s}f`)).toEqual('../d/e/f');
|
---|
30 | });
|
---|
31 | });
|
---|
32 |
|
---|
33 | describe("dirname", function() {
|
---|
34 | it("should return the dirname of a path only using forward slashes", function() {
|
---|
35 | expect(path.dirname('a/b/c')).toEqual('a/b');
|
---|
36 | expect(path.dirname(`a${s}b${s}c`)).toEqual('a/b');
|
---|
37 | });
|
---|
38 | });
|
---|
39 |
|
---|
40 | describe("format", function() {
|
---|
41 | it("should return a formatted path only using forward slashes", function() {
|
---|
42 | expect(path.format({dir: 'a/b', base: 'c'})).toEqual('a/b/c');
|
---|
43 | expect(path.format({dir: `a${s}b`, base: 'c'})).toEqual('a/b/c');
|
---|
44 | });
|
---|
45 | });
|
---|
46 |
|
---|
47 | describe("canonical", function() {
|
---|
48 | it("should return a path with forward slashes", function() {
|
---|
49 | expect(path.canonical('a'+path.sep+'b'+path.sep+'c')).toEqual('a/b/c');
|
---|
50 | });
|
---|
51 | });
|
---|
52 | }); |
---|