-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
124 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import { URI } from 'vs/base/common/uri'; | ||
import { FileAccess, Schemas } from 'vs/base/common/network'; | ||
import { isEqual } from 'vs/base/common/resources'; | ||
import { isWeb } from 'vs/base/common/platform'; | ||
|
||
suite('network', () => { | ||
|
||
(isWeb ? test.skip : test)('FileAccess: URI (native)', () => { | ||
|
||
// asCodeUri() & asFileUri(): simple, without authority | ||
let originalFileUri = URI.file('network.test.ts'); | ||
let browserUri = FileAccess.asBrowserUri(originalFileUri); | ||
assert.ok(browserUri.authority.length > 0); | ||
let fileUri = FileAccess.asFileUri(browserUri); | ||
assert.equal(fileUri.authority.length, 0); | ||
assert(isEqual(originalFileUri, fileUri)); | ||
|
||
// asCodeUri() & asFileUri(): with authority | ||
originalFileUri = URI.file('network.test.ts').with({ authority: 'test-authority' }); | ||
browserUri = FileAccess.asBrowserUri(originalFileUri); | ||
assert.equal(browserUri.authority, originalFileUri.authority); | ||
fileUri = FileAccess.asFileUri(browserUri); | ||
assert(isEqual(originalFileUri, fileUri)); | ||
}); | ||
|
||
(isWeb ? test.skip : test)('FileAccess: moduleId (native)', () => { | ||
const browserUri = FileAccess.asBrowserUri('vs/base/test/node/network.test', require); | ||
assert.equal(browserUri.scheme, Schemas.vscodeFileResource); | ||
|
||
const fileUri = FileAccess.asFileUri('vs/base/test/node/network.test', require); | ||
assert.equal(fileUri.scheme, Schemas.file); | ||
}); | ||
|
||
(isWeb ? test.skip : test)('FileAccess: query and fragment is dropped (native)', () => { | ||
let originalFileUri = URI.file('network.test.ts').with({ query: 'foo=bar', fragment: 'something' }); | ||
let browserUri = FileAccess.asBrowserUri(originalFileUri); | ||
assert.equal(browserUri.query, ''); | ||
assert.equal(browserUri.fragment, ''); | ||
}); | ||
|
||
(isWeb ? test.skip : test)('FileAccess: query and fragment is kept if URI is already of same scheme (native)', () => { | ||
let originalFileUri = URI.file('network.test.ts').with({ query: 'foo=bar', fragment: 'something' }); | ||
let browserUri = FileAccess.asBrowserUri(originalFileUri.with({ scheme: Schemas.vscodeFileResource })); | ||
assert.equal(browserUri.query, 'foo=bar'); | ||
assert.equal(browserUri.fragment, 'something'); | ||
|
||
let fileUri = FileAccess.asFileUri(originalFileUri); | ||
assert.equal(fileUri.query, 'foo=bar'); | ||
assert.equal(fileUri.fragment, 'something'); | ||
}); | ||
|
||
(isWeb ? test.skip : test)('FileAccess: web', () => { | ||
const originalHttpsUri = URI.file('network.test.ts').with({ scheme: 'https' }); | ||
const browserUri = FileAccess.asBrowserUri(originalHttpsUri); | ||
assert.equal(originalHttpsUri.toString(), browserUri.toString()); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters