Skip to content

Commit 8317591

Browse files
committed
tests 💂
1 parent 9025542 commit 8317591

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

src/vs/workbench/services/editor/test/browser/editorGroupsService.test.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as assert from 'assert';
7+
import { Event } from 'vs/base/common/event';
78
import { workbenchInstantiationService, registerTestEditor, TestFileEditorInput, TestEditorPart, ITestInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
8-
import { GroupDirection, GroupsOrder, MergeGroupMode, GroupOrientation, GroupChangeKind, GroupLocation } from 'vs/workbench/services/editor/common/editorGroupsService';
9+
import { GroupDirection, GroupsOrder, MergeGroupMode, GroupOrientation, GroupChangeKind, GroupLocation, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
910
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1011
import { EditorOptions, CloseDirection, IEditorPartOptions, EditorsOrder } from 'vs/workbench/common/editor';
1112
import { URI } from 'vs/base/common/uri';
@@ -1031,4 +1032,49 @@ suite('EditorGroupsService', () => {
10311032
editorGroupChangeListener.dispose();
10321033
part.dispose();
10331034
});
1035+
1036+
test('moveEditor with context (across groups)', async () => {
1037+
const [part] = createPart();
1038+
const group = part.activeGroup;
1039+
assert.equal(group.isEmpty, true);
1040+
1041+
const rightGroup = part.addGroup(group, GroupDirection.RIGHT);
1042+
1043+
const input = new TestFileEditorInput(URI.file('foo/bar'), TEST_EDITOR_INPUT_ID);
1044+
const inputInactive = new TestFileEditorInput(URI.file('foo/bar/inactive'), TEST_EDITOR_INPUT_ID);
1045+
let firstOpenEditorContext: OpenEditorContext | undefined;
1046+
Event.once(group.onWillOpenEditor)(e => {
1047+
firstOpenEditorContext = e.context;
1048+
});
1049+
await group.openEditors([{ editor: input, options: { pinned: true } }, { editor: inputInactive }]);
1050+
assert.equal(firstOpenEditorContext, undefined);
1051+
1052+
const waitForEditorWillOpen = new Promise<OpenEditorContext | undefined>(c => {
1053+
Event.once(rightGroup.onWillOpenEditor)(e => c(e.context));
1054+
});
1055+
1056+
group.moveEditor(inputInactive, rightGroup, { index: 0 });
1057+
const context = await waitForEditorWillOpen;
1058+
assert.equal(context, OpenEditorContext.MOVE_EDITOR);
1059+
part.dispose();
1060+
});
1061+
1062+
test('copyEditor with context (across groups)', async () => {
1063+
const [part] = createPart();
1064+
const group = part.activeGroup;
1065+
assert.equal(group.isEmpty, true);
1066+
1067+
const rightGroup = part.addGroup(group, GroupDirection.RIGHT);
1068+
const input = new TestFileEditorInput(URI.file('foo/bar'), TEST_EDITOR_INPUT_ID);
1069+
const inputInactive = new TestFileEditorInput(URI.file('foo/bar/inactive'), TEST_EDITOR_INPUT_ID);
1070+
await group.openEditors([{ editor: input, options: { pinned: true } }, { editor: inputInactive }]);
1071+
const waitForEditorWillOpen = new Promise<OpenEditorContext | undefined>(c => {
1072+
Event.once(rightGroup.onWillOpenEditor)(e => c(e.context));
1073+
});
1074+
1075+
group.copyEditor(inputInactive, rightGroup, { index: 0 });
1076+
const context = await waitForEditorWillOpen;
1077+
assert.equal(context, OpenEditorContext.COPY_EDITOR);
1078+
part.dispose();
1079+
});
10341080
});

0 commit comments

Comments
 (0)