1
|
|
2
|
var sep = require('path').sep || '/';
|
3
|
var assert = require('assert');
|
4
|
var uri2path = require('../');
|
5
|
var tests = require('./tests.json');
|
6
|
|
7
|
describe('file-uri-to-path', function () {
|
8
|
|
9
|
Object.keys(tests).forEach(function (uri) {
|
10
|
|
11
|
// the test cases were generated from Windows' PathCreateFromUrlA() function.
|
12
|
// On Unix, we have to replace the path separator with the Unix one instead of
|
13
|
// the Windows one.
|
14
|
var expected = tests[uri].replace(/\\/g, sep);
|
15
|
|
16
|
it('should convert ' + JSON.stringify(uri) + ' to ' + JSON.stringify(expected),
|
17
|
function () {
|
18
|
var actual = uri2path(uri);
|
19
|
assert.equal(actual, expected);
|
20
|
});
|
21
|
|
22
|
});
|
23
|
|
24
|
});
|