1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const os = require("os");
|
19 | const path = require("path");
|
20 | const chai = require("chai");
|
21 | const file_uri_1 = require("./file-uri");
|
22 | const os_1 = require("../common/os");
|
23 | const expect = chai.expect;
|
24 | describe('file-uri', () => {
|
25 | const filePaths = ['with.txt', 'with spaces.txt', 'with:colon.txt', 'with_Ö.txt'].map(filePath => path.join(os.tmpdir(), 'file-uri-folder', filePath));
|
26 | it('create -> fsPath -> create should be symmetric', () => {
|
27 | const orderedPaths = filePaths.map(filePath => filePath.toLowerCase()).sort();
|
28 | expect(orderedPaths.map(filePath => file_uri_1.FileUri.create(filePath)).map(uri => file_uri_1.FileUri.fsPath(uri).toLowerCase()).sort()).to.be.deep.equal(orderedPaths);
|
29 | });
|
30 | it('fsPath -> create -> fsPath should be symmetric', () => {
|
31 | filePaths.forEach(filePath => {
|
32 | const expectedUri = file_uri_1.FileUri.create(filePath);
|
33 | const convertedPath = file_uri_1.FileUri.fsPath(expectedUri);
|
34 | const actualUri = file_uri_1.FileUri.create(convertedPath);
|
35 | expect(actualUri.toString()).to.be.equal(expectedUri.toString());
|
36 | });
|
37 | });
|
38 | it('from /', () => {
|
39 | const uri = file_uri_1.FileUri.create('/');
|
40 | expect(uri.toString(true)).to.be.equal('file:///');
|
41 | });
|
42 | it('from //', () => {
|
43 | const uri = file_uri_1.FileUri.create('//');
|
44 | expect(uri.toString(true)).to.be.equal('file:///');
|
45 | });
|
46 | it('from c:', () => {
|
47 | const uri = file_uri_1.FileUri.create('c:');
|
48 | expect(uri.toString(true)).to.be.equal('file:///c:');
|
49 | });
|
50 | it('from /c:', () => {
|
51 | const uri = file_uri_1.FileUri.create('/c:');
|
52 | expect(uri.toString(true)).to.be.equal('file:///c:');
|
53 | });
|
54 | it('from /c:/', () => {
|
55 | const uri = file_uri_1.FileUri.create('/c:/');
|
56 | expect(uri.toString(true)).to.be.equal('file:///c:/');
|
57 | });
|
58 | it('from file:///c%3A', function () {
|
59 | if (!os_1.isWindows) {
|
60 | this.skip();
|
61 | return;
|
62 | }
|
63 | const fsPath = file_uri_1.FileUri.fsPath('file:///c%3A');
|
64 | expect(fsPath).to.be.equal('c:\\');
|
65 | });
|
66 | });
|
67 |
|
\ | No newline at end of file |