mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 11:38:51 +01:00
stub out some lightweight unit tests for extHostEditorTabs (#144192)
This commit is contained in:
71
src/vs/workbench/api/test/browser/extHostEditorTabs.test.ts
Normal file
71
src/vs/workbench/api/test/browser/extHostEditorTabs.test.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import assert = require('assert');
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { IEditorTabDto, MainThreadEditorTabsShape, TabKind } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostEditorTabs } from 'vs/workbench/api/common/extHostEditorTabs';
|
||||
import { SingleProxyRPCProtocol } from 'vs/workbench/api/test/common/testRPCProtocol';
|
||||
|
||||
suite('ExtHostEditorTabs', function () {
|
||||
|
||||
|
||||
test('empty', function () {
|
||||
|
||||
const extHostEditorTabs = new ExtHostEditorTabs(
|
||||
SingleProxyRPCProtocol(new class extends mock<MainThreadEditorTabsShape>() {
|
||||
// override/implement $moveTab or $closeTab
|
||||
})
|
||||
);
|
||||
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.all.length, 0);
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.activeTabGroup, undefined);
|
||||
});
|
||||
|
||||
test('single tab', function () {
|
||||
|
||||
const extHostEditorTabs = new ExtHostEditorTabs(
|
||||
SingleProxyRPCProtocol(new class extends mock<MainThreadEditorTabsShape>() {
|
||||
// override/implement $moveTab or $closeTab
|
||||
})
|
||||
);
|
||||
|
||||
const tab: IEditorTabDto = {
|
||||
isActive: true,
|
||||
isDirty: true,
|
||||
isPinned: true,
|
||||
label: 'label1',
|
||||
viewColumn: 0,
|
||||
additionalResourcesAndViewIds: [],
|
||||
kind: TabKind.Other
|
||||
};
|
||||
|
||||
extHostEditorTabs.$acceptEditorTabModel([{
|
||||
isActive: true,
|
||||
viewColumn: 0,
|
||||
groupId: 12,
|
||||
tabs: [tab],
|
||||
activeTab: { ...tab }
|
||||
}]);
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.all.length, 1);
|
||||
const [first] = extHostEditorTabs.tabGroups.all;
|
||||
assert.ok(first.activeTab);
|
||||
assert.strictEqual(first.tabs.indexOf(first.activeTab), 0);
|
||||
|
||||
{
|
||||
extHostEditorTabs.$acceptEditorTabModel([{
|
||||
isActive: true,
|
||||
viewColumn: 0,
|
||||
groupId: 12,
|
||||
tabs: [tab],
|
||||
activeTab: undefined! // TODO@lramos15 unused
|
||||
}]);
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.all.length, 1);
|
||||
const [first] = extHostEditorTabs.tabGroups.all;
|
||||
assert.ok(first.activeTab);
|
||||
assert.strictEqual(first.tabs.indexOf(first.activeTab), 0);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user