forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
52 lines (46 loc) · 1.77 KB
/
Copy pathutils.js
File metadata and controls
52 lines (46 loc) · 1.77 KB
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
var assert = require('chai').assert
var utils = require('../lib/utils')
describe('Utility functions', function () {
describe('pathBasename', function () {
it('should return bar as relative path for /foo/bar', function () {
assert.equal(utils.pathBasename('/foo/bar'), 'bar')
})
it('should return empty as relative path for /foo/', function () {
assert.equal(utils.pathBasename('/foo/'), '')
})
it('should return empty as relative path for /', function () {
assert.equal(utils.pathBasename('/'), '')
})
it('should return empty as relative path for empty path', function () {
assert.equal(utils.pathBasename(''), '')
})
it('should return empty as relative path for undefined path', function () {
assert.equal(utils.pathBasename(undefined), '')
})
})
describe('uriToFilename', function () {
it('should decode hex-encoded space', function () {
assert.equal(utils.uriToFilename('uri%20', 'base/'), 'base/uri ')
})
it('should decode hex-encoded at sign', function () {
assert.equal(utils.uriToFilename('film%4011', 'base/'), 'base/film@11')
})
it('should decode hex-encoded single quote', function () {
assert.equal(utils.uriToFilename('quote%27', 'base/'), 'base/quote\'')
})
})
describe('stripLineEndings()', () => {
it('should pass through falsy string arguments', () => {
assert.equal(utils.stripLineEndings(''), '')
assert.equal(utils.stripLineEndings(null), null)
assert.equal(utils.stripLineEndings(undefined), undefined)
})
it('should remove line-endings characters', () => {
let str = '123\n456'
assert.equal(utils.stripLineEndings(str), '123456')
str = `123
456`
assert.equal(utils.stripLineEndings(str), '123456')
})
})
})