提交 48bc0dca 编写于 作者: B Benjamin Pasero

editors - add test for new close() method

上级 2f9b7807
......@@ -449,6 +449,10 @@ suite('EditorGroupsService', () => {
assert.equal(editorCloseCounter1, 1);
assert.equal(editorWillCloseCounter, 1);
assert.ok(inputInactive.gotClosed);
assert.equal(inputInactive.gotClosed?.group, group.id);
assert.equal(inputInactive.gotClosed?.openedInOtherGroups, false);
assert.equal(group.activeEditor, input);
assert.equal(editorStickyCounter, 0);
......@@ -482,10 +486,44 @@ suite('EditorGroupsService', () => {
assert.equal(group.getEditorByIndex(1), inputInactive);
await group.closeEditors([input, inputInactive]);
assert.ok(input.gotClosed);
assert.equal(input.gotClosed?.group, group.id);
assert.equal(input.gotClosed?.openedInOtherGroups, false);
assert.ok(inputInactive.gotClosed);
assert.equal(inputInactive.gotClosed?.group, group.id);
assert.equal(inputInactive.gotClosed?.openedInOtherGroups, false);
assert.equal(group.isEmpty, true);
part.dispose();
});
test('closeEditors (one, opened in multiple groups)', async () => {
const [part] = createPart();
const group = part.activeGroup;
assert.equal(group.isEmpty, true);
const rightGroup = part.addGroup(group, GroupDirection.RIGHT);
const input = new TestFileEditorInput(URI.file('foo/bar'), TEST_EDITOR_INPUT_ID);
const inputInactive = new TestFileEditorInput(URI.file('foo/bar/inactive'), TEST_EDITOR_INPUT_ID);
await group.openEditors([{ editor: input, options: { pinned: true } }, { editor: inputInactive }]);
await rightGroup.openEditors([{ editor: input, options: { pinned: true } }, { editor: inputInactive }]);
await rightGroup.closeEditor(input);
assert.ok(input.gotClosed);
assert.equal(input.gotClosed?.group, rightGroup.id);
assert.equal(input.gotClosed?.openedInOtherGroups, true);
await group.closeEditor(input);
assert.ok(input.gotClosed);
assert.equal(input.gotClosed?.group, group.id);
assert.equal(input.gotClosed?.openedInOtherGroups, false);
});
test('closeEditors (except one)', async () => {
const [part] = createPart();
const group = part.activeGroup;
......
......@@ -1060,6 +1060,7 @@ export class TestFileEditorInput extends EditorInput implements IFileEditorInput
gotSaved = false;
gotSavedAs = false;
gotReverted = false;
gotClosed: { group: GroupIdentifier, openedInOtherGroups: boolean } | undefined = undefined;
dirty = false;
private fails = false;
......@@ -1106,6 +1107,10 @@ export class TestFileEditorInput extends EditorInput implements IFileEditorInput
return false;
}
isResolved(): boolean { return false; }
close(group: GroupIdentifier, openedInOtherGroups: boolean): void {
this.gotClosed = { group, openedInOtherGroups };
super.close(group, openedInOtherGroups);
}
dispose(): void {
super.dispose();
this.gotDisposed = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册