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
34 lines (32 loc) · 1.27 KB
/
utils.js
File metadata and controls
34 lines (32 loc) · 1.27 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
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\'')
})
})
})