mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 01:25:38 -05:00
Merge from vscode 8df646d3c5477b02737fc10343fa7cf0cc3f606b
This commit is contained in:
@@ -106,6 +106,40 @@ suite('History Navigator', () => {
|
||||
assert.deepEqual(['2', '3', '1'], toArray(testObject));
|
||||
});
|
||||
|
||||
test('previous returns null if the current position is the first one', () => {
|
||||
const testObject = new HistoryNavigator(['1', '2', '3']);
|
||||
|
||||
testObject.first();
|
||||
|
||||
assert.deepEqual(testObject.previous(), null);
|
||||
});
|
||||
|
||||
test('previous returns object if the current position is not the first one', () => {
|
||||
const testObject = new HistoryNavigator(['1', '2', '3']);
|
||||
|
||||
testObject.first();
|
||||
testObject.next();
|
||||
|
||||
assert.deepEqual(testObject.previous(), '1');
|
||||
});
|
||||
|
||||
test('next returns null if the current position is the last one', () => {
|
||||
const testObject = new HistoryNavigator(['1', '2', '3']);
|
||||
|
||||
testObject.last();
|
||||
|
||||
assert.deepEqual(testObject.next(), null);
|
||||
});
|
||||
|
||||
test('next returns object if the current position is not the last one', () => {
|
||||
const testObject = new HistoryNavigator(['1', '2', '3']);
|
||||
|
||||
testObject.last();
|
||||
testObject.previous();
|
||||
|
||||
assert.deepEqual(testObject.next(), '3');
|
||||
});
|
||||
|
||||
test('clear', () => {
|
||||
const testObject = new HistoryNavigator(['a', 'b', 'c']);
|
||||
assert.equal(testObject.previous(), 'c');
|
||||
|
||||
@@ -503,4 +503,65 @@ suite('URI', () => {
|
||||
// }
|
||||
// console.profileEnd();
|
||||
});
|
||||
function assertJoined(base: string, fragment: string, expected: string, checkWithUrl: boolean = true) {
|
||||
const baseUri = URI.parse(base);
|
||||
const newUri = URI.joinPath(baseUri, fragment);
|
||||
const actual = newUri.toString(true);
|
||||
assert.equal(actual, expected);
|
||||
|
||||
if (checkWithUrl) {
|
||||
const actualUrl = new URL(fragment, base).href;
|
||||
assert.equal(actualUrl, expected, 'DIFFERENT from URL');
|
||||
}
|
||||
}
|
||||
test('URI#joinPath', function () {
|
||||
|
||||
assertJoined(('file:///foo/'), '../../bazz', 'file:///bazz');
|
||||
assertJoined(('file:///foo'), '../../bazz', 'file:///bazz');
|
||||
assertJoined(('file:///foo'), '../../bazz', 'file:///bazz');
|
||||
assertJoined(('file:///foo/bar/'), './bazz', 'file:///foo/bar/bazz');
|
||||
assertJoined(('file:///foo/bar'), './bazz', 'file:///foo/bar/bazz', false);
|
||||
assertJoined(('file:///foo/bar'), 'bazz', 'file:///foo/bar/bazz', false);
|
||||
|
||||
// "auto-path" scheme
|
||||
assertJoined(('file:'), 'bazz', 'file:///bazz');
|
||||
assertJoined(('http://domain'), 'bazz', 'http://domain/bazz');
|
||||
assertJoined(('https://domain'), 'bazz', 'https://domain/bazz');
|
||||
assertJoined(('http:'), 'bazz', 'http:/bazz', false);
|
||||
assertJoined(('https:'), 'bazz', 'https:/bazz', false);
|
||||
|
||||
// no "auto-path" scheme with and w/o paths
|
||||
assertJoined(('foo:/'), 'bazz', 'foo:/bazz');
|
||||
assertJoined(('foo://bar/'), 'bazz', 'foo://bar/bazz');
|
||||
|
||||
// no "auto-path" + no path -> error
|
||||
assert.throws(() => assertJoined(('foo:'), 'bazz', ''));
|
||||
assert.throws(() => new URL('bazz', 'foo:'));
|
||||
assert.throws(() => assertJoined(('foo://bar'), 'bazz', ''));
|
||||
assert.throws(() => new URL('bazz', 'foo://bar'));
|
||||
});
|
||||
|
||||
test('URI#joinPath (posix)', function () {
|
||||
if (isWindows) {
|
||||
this.skip();
|
||||
}
|
||||
assertJoined(('file:///c:/foo/'), '../../bazz', 'file:///bazz', false);
|
||||
assertJoined(('file://server/share/c:/'), '../../bazz', 'file://server/bazz', false);
|
||||
assertJoined(('file://server/share/c:'), '../../bazz', 'file://server/bazz', false);
|
||||
|
||||
assertJoined(('file://ser/foo/'), '../../bazz', 'file://ser/bazz');
|
||||
assertJoined(('file://ser/foo'), '../../bazz', 'file://ser/bazz');
|
||||
});
|
||||
|
||||
test('URI#joinPath (windows)', function () {
|
||||
if (!isWindows) {
|
||||
this.skip();
|
||||
}
|
||||
assertJoined(('file:///c:/foo/'), '../../bazz', 'file:///c:/bazz', false);
|
||||
assertJoined(('file://server/share/c:/'), '../../bazz', 'file://server/share/bazz', false);
|
||||
assertJoined(('file://server/share/c:'), '../../bazz', 'file://server/share/bazz', false);
|
||||
|
||||
assertJoined(('file://ser/foo/'), '../../bazz', 'file://ser/foo/bazz', false);
|
||||
assertJoined(('file://ser/foo'), '../../bazz', 'file://ser/foo/bazz', false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user