1 | "use strict"; |
||
2 | |||
3 | /* ------------------------------------------------------------------------ */ |
||
4 | |||
5 | require ('chai').should () |
||
6 | |||
7 | /* ------------------------------------------------------------------------ */ |
||
8 | |||
9 | describe ('path', () => { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
10 | |||
11 | const path = require ('../impl/path') |
||
12 | |||
13 | it ('resolves', () => { |
||
14 | |||
15 | path.resolve ('./foo/bar/../qux').should.equal (process.cwd () + '/foo/qux') |
||
16 | }) |
||
17 | |||
18 | it ('normalizes', () => { |
||
19 | |||
20 | path.normalize ('./foo/./bar/.././.././qux.map./').should.equal ('qux.map./') |
||
21 | |||
22 | path.normalize ('/a/b').should.equal ('/a/b') |
||
23 | path.normalize ('http://foo/bar').should.equal ('http://foo/bar') |
||
24 | }) |
||
25 | |||
26 | it ('computes relative location', () => { |
||
27 | |||
28 | path.relativeToFile ('/foo/bar.js', './qux.map') |
||
29 | .should.equal ('/foo/qux.map') |
||
30 | |||
31 | path.relativeToFile ('/foo/bar/baz.js', './../.././qux.map') |
||
32 | .should.equal ('/qux.map') |
||
33 | |||
34 | path.relativeToFile ('/foo/bar', 'webpack:something') |
||
35 | .should.equal ('webpack:something') |
||
36 | |||
37 | path.relativeToFile ('/foo/bar', 'web/pack:something') |
||
38 | .should.equal ('/foo/web/pack:something') |
||
39 | }) |
||
40 | |||
41 | it ('works with data URIs', () => { |
||
42 | |||
43 | path.relativeToFile ('/foo/bar.js', 'data:application/json;charset=utf-8;base64,eyJ2ZXJza==') |
||
44 | .should.equal ( 'data:application/json;charset=utf-8;base64,eyJ2ZXJza==') |
||
45 | |||
46 | path.relativeToFile ('data:application/json;charset=utf-8;base64,eyJ2ZXJza==', 'foo.js') |
||
47 | .should.equal ( 'foo.js') |
||
48 | }) |
||
49 | }) |