Skip to content

765 pinninghiding panels and putting a tab bar to any side of the page #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 38 additions & 52 deletions packages/dockview-core/src/__tests__/dnd/groupDragHandler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import { fireEvent } from '@testing-library/dom';
import { GroupDragHandler } from '../../dnd/groupDragHandler';
import { DockviewGroupPanel } from '../../dockview/dockviewGroupPanel';
import {
GroupDragHandler,
GroupDragHandlerOptions,
} from '../../dnd/groupDragHandler';
import { LocalSelectionTransfer, PanelTransfer } from '../../dnd/dataTransfer';
import { DockviewComponent } from '../../dockview/dockviewComponent';
import { fromPartial } from '@total-typescript/shoehorn';

describe('groupDragHandler', () => {
test('that the dnd transfer object is setup and torndown', () => {
const element = document.createElement('div');

const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
const partial: Partial<DockviewGroupPanel> = {
id: 'test_group_id',
api: { location: { type: 'grid' } } as any,
};
return partial as DockviewGroupPanel;
});
const group = new groupMock();

const cut = new GroupDragHandler(
element,
{ id: 'test_accessor_id' } as DockviewComponent,
group
'accessor_id',
fromPartial<GroupDragHandlerOptions>({
id: 'test_group_id',
isCancelled: () => false,
})
);

fireEvent.dragStart(element, new Event('dragstart'));
Expand All @@ -35,7 +31,7 @@ describe('groupDragHandler', () => {
PanelTransfer.prototype
)![0];
expect(transferObject).toBeTruthy();
expect(transferObject.viewId).toBe('test_accessor_id');
expect(transferObject.viewId).toBe('accessor_id');
expect(transferObject.groupId).toBe('test_group_id');
expect(transferObject.panelId).toBeNull();

Expand All @@ -48,66 +44,56 @@ describe('groupDragHandler', () => {

cut.dispose();
});
test('that the event is cancelled when floating and shiftKey=true', () => {
const element = document.createElement('div');
// test('that the event is cancelled when floating and shiftKey=true', () => {
// const element = document.createElement('div');

const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
const partial: Partial<DockviewGroupPanel> = {
api: { location: { type: 'floating' } } as any,
};
return partial as DockviewGroupPanel;
});
const group = new groupMock();
// const cut = new GroupDragHandler(
// element,
// 'accessor_id',
// fromPartial<GroupDragHandlerOptions>({
// isCancelled: () => false,
// id: 'test_group_id',
// })
// );

const cut = new GroupDragHandler(
element,
{ id: 'accessor_id' } as DockviewComponent,
group
);

const event = new KeyboardEvent('dragstart', { shiftKey: false });
// const event = new KeyboardEvent('dragstart', { shiftKey: false });

const spy = jest.spyOn(event, 'preventDefault');
fireEvent(element, event);
expect(spy).toBeCalledTimes(1);
// const spy = jest.spyOn(event, 'preventDefault');
// fireEvent(element, event);
// expect(spy).toHaveBeenCalledTimes(1);

const event2 = new KeyboardEvent('dragstart', { shiftKey: true });
// const event2 = new KeyboardEvent('dragstart', { shiftKey: true });

const spy2 = jest.spyOn(event2, 'preventDefault');
fireEvent(element, event);
expect(spy2).toBeCalledTimes(0);
// const spy2 = jest.spyOn(event2, 'preventDefault');
// fireEvent(element, event);
// expect(spy2).toHaveBeenCalledTimes(0);

cut.dispose();
});
// cut.dispose();
// });

test('that the event is never cancelled when the group is not floating', () => {
const element = document.createElement('div');

const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
const partial: Partial<DockviewGroupPanel> = {
api: { location: { type: 'grid' } } as any,
};
return partial as DockviewGroupPanel;
});
const group = new groupMock();

const cut = new GroupDragHandler(
element,
{ id: 'accessor_id' } as DockviewComponent,
group
'accessor_id',
fromPartial<GroupDragHandlerOptions>({
isCancelled: () => false,
id: 'test_group_id',
})
);

const event = new KeyboardEvent('dragstart', { shiftKey: false });

const spy = jest.spyOn(event, 'preventDefault');
fireEvent(element, event);
expect(spy).toBeCalledTimes(0);
expect(spy).toHaveBeenCalledTimes(0);

const event2 = new KeyboardEvent('dragstart', { shiftKey: true });

const spy2 = jest.spyOn(event2, 'preventDefault');
fireEvent(element, event);
expect(spy2).toBeCalledTimes(0);
expect(spy2).toHaveBeenCalledTimes(0);

cut.dispose();
});
Expand Down
Loading
Loading