Skip to content
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

Support JupyterLab 2.0 #137

Open
wants to merge 2 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
4 changes: 2 additions & 2 deletions __tests__/src/components/SingletonPanel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Message } from '@phosphor/messaging';
import { Message } from '@lumino/messaging';

import { Widget } from '@phosphor/widgets';
import { Widget } from '@lumino/widgets';

import { SingletonPanel } from '../../../src/components';

Expand Down
50 changes: 25 additions & 25 deletions __tests__/src/services/dataGridExtensions/columnWidth.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextRenderer, DataModel, DataGrid } from '@phosphor/datagrid';
import { TextRenderer, DataModel, DataGrid } from '@lumino/datagrid';
import {
fitColumnWidths,
FitColumnWidths
Expand Down Expand Up @@ -71,8 +71,8 @@ namespace Fixtures {

export function newGrid(model: DataModel) {
const grid = new DataGrid();
grid.model = model;
jest.spyOn(grid, 'resizeSection');
grid.dataModel = model;
jest.spyOn(grid, 'resizeColumn');
return grid;
}
}
Expand All @@ -89,9 +89,9 @@ describe('ColumnWidthestimator', () => {
const model = new Fixtures.TestDataModel([column], ['h'], column, '');
const grid = Fixtures.newGrid(model);
fitColumnWidths(grid, Fixtures.renderer, Fixtures.options);
expect(grid.resizeSection).toHaveBeenCalledTimes(2);
expect(grid.resizeSection).toHaveBeenCalledWith('column', 0, 8);
expect(grid.resizeSection).toHaveBeenCalledWith('row-header', 0, 8);
expect(grid.resizeColumn).toHaveBeenCalledTimes(2);
expect(grid.resizeColumn).toHaveBeenCalledWith('body', 0, 8);
expect(grid.resizeColumn).toHaveBeenCalledWith('row-header', 0, 8);
});

it('use the longest width in the first 100 elements', () => {
Expand All @@ -100,9 +100,9 @@ describe('ColumnWidthestimator', () => {
const model = new Fixtures.TestDataModel([column], ['h'], column, '');
const grid = Fixtures.newGrid(model);
fitColumnWidths(grid, Fixtures.renderer, Fixtures.options);
expect(grid.resizeSection).toHaveBeenCalledTimes(2);
expect(grid.resizeSection).toHaveBeenCalledWith('column', 0, 24);
expect(grid.resizeSection).toHaveBeenCalledWith('row-header', 0, 24);
expect(grid.resizeColumn).toHaveBeenCalledTimes(2);
expect(grid.resizeColumn).toHaveBeenCalledWith('body', 0, 24);
expect(grid.resizeColumn).toHaveBeenCalledWith('row-header', 0, 24);
});

it('ignore values beyond the first 100', () => {
Expand All @@ -111,28 +111,28 @@ describe('ColumnWidthestimator', () => {
const model = new Fixtures.TestDataModel([column], ['h'], column, '');
const grid = Fixtures.newGrid(model);
fitColumnWidths(grid, Fixtures.renderer, Fixtures.options);
expect(grid.resizeSection).toHaveBeenCalledTimes(2);
expect(grid.resizeSection).toHaveBeenCalledWith('column', 0, 8);
expect(grid.resizeSection).toHaveBeenCalledWith('row-header', 0, 8);
expect(grid.resizeColumn).toHaveBeenCalledTimes(2);
expect(grid.resizeColumn).toHaveBeenCalledWith('body', 0, 8);
expect(grid.resizeColumn).toHaveBeenCalledWith('row-header', 0, 8);
});

it('set a default min value', () => {
const model = new Fixtures.TestDataModel([[]], [''], [], '');
const grid = Fixtures.newGrid(model);
fitColumnWidths(grid, Fixtures.renderer, Fixtures.options);
expect(grid.resizeSection).toHaveBeenCalledTimes(2);
expect(grid.resizeSection).toHaveBeenCalledWith('column', 0, 5);
expect(grid.resizeSection).toHaveBeenCalledWith('row-header', 0, 5);
expect(grid.resizeColumn).toHaveBeenCalledTimes(2);
expect(grid.resizeColumn).toHaveBeenCalledWith('body', 0, 5);
expect(grid.resizeColumn).toHaveBeenCalledWith('row-header', 0, 5);
});

it('include the header in the column width', () => {
const column = Array.from({ length: 200 }, () => 'a');
const model = new Fixtures.TestDataModel([column], ['aaa'], column, 'aaa');
const grid = Fixtures.newGrid(model);
fitColumnWidths(grid, Fixtures.renderer, Fixtures.options);
expect(grid.resizeSection).toHaveBeenCalledTimes(2);
expect(grid.resizeSection).toHaveBeenCalledWith('column', 0, 24);
expect(grid.resizeSection).toHaveBeenCalledWith('row-header', 0, 24);
expect(grid.resizeColumn).toHaveBeenCalledTimes(2);
expect(grid.resizeColumn).toHaveBeenCalledWith('body', 0, 24);
expect(grid.resizeColumn).toHaveBeenCalledWith('row-header', 0, 24);
});

it('not use values greater than a maximum size', () => {
Expand All @@ -141,9 +141,9 @@ describe('ColumnWidthestimator', () => {
const model = new Fixtures.TestDataModel([column], ['h'], column, '');
const grid = Fixtures.newGrid(model);
fitColumnWidths(grid, Fixtures.renderer, Fixtures.options);
expect(grid.resizeSection).toHaveBeenCalledTimes(2);
expect(grid.resizeSection).toHaveBeenCalledWith('column', 0, 60);
expect(grid.resizeSection).toHaveBeenCalledWith('row-header', 0, 60);
expect(grid.resizeColumn).toHaveBeenCalledTimes(2);
expect(grid.resizeColumn).toHaveBeenCalledWith('body', 0, 60);
expect(grid.resizeColumn).toHaveBeenCalledWith('row-header', 0, 60);
});

it('work for mulitple columns', () => {
Expand All @@ -157,9 +157,9 @@ describe('ColumnWidthestimator', () => {
);
const grid = Fixtures.newGrid(model);
fitColumnWidths(grid, Fixtures.renderer, Fixtures.options);
expect(grid.resizeSection).toHaveBeenCalledTimes(3);
expect(grid.resizeSection).toHaveBeenCalledWith('column', 0, 8);
expect(grid.resizeSection).toHaveBeenCalledWith('column', 1, 16);
expect(grid.resizeSection).toHaveBeenCalledWith('row-header', 0, 8);
expect(grid.resizeColumn).toHaveBeenCalledTimes(3);
expect(grid.resizeColumn).toHaveBeenCalledWith('body', 0, 8);
expect(grid.resizeColumn).toHaveBeenCalledWith('body', 1, 16);
expect(grid.resizeColumn).toHaveBeenCalledWith('row-header', 0, 8);
});
});
18 changes: 11 additions & 7 deletions __tests__/src/services/dataGridExtensions/events.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { DataGrid, DataModel } from '@phosphor/datagrid';
import { framePromise } from '@jupyterlab/testutils';
import { DataGrid, DataModel } from '@lumino/datagrid';

import {
addMouseEventListener,
GridMouseEvent
} from '../../../../src/services/dataGridExtensions';


namespace Fixtures {
export function grid(): DataGrid {
const model = new TestDataModel();
const grid = new DataGrid();
grid.model = model;
grid.dataModel = model;
return grid;
}

Expand Down Expand Up @@ -96,9 +98,10 @@ describe('addMouseEventListener', () => {
expect(row).toEqual({ section: 'column-header', index: null });
});

it('take row resizes into account', () => {
it('take row resizes into account', async () => {
const grid = Fixtures.grid();
grid.resizeSection('row', 2, 200);
grid.resizeRow('body', 2, 200);
await framePromise();
const event = Fixtures.clickEvent({
clientX: 5,
clientY: 3 * 20 + 200 + 2
Expand Down Expand Up @@ -140,9 +143,10 @@ describe('addMouseEventListener', () => {
expect(column).toEqual({ section: 'row-header', index: null });
});

it('take column resizes into account', () => {
it('take column resizes into account', async () => {
const grid = Fixtures.grid();
grid.resizeSection('column', 2, 200);
grid.resizeColumn('body', 2, 200);
await framePromise();
const event = Fixtures.clickEvent({
clientX: 3 * 64 + 200 + 2,
clientY: 5
Expand All @@ -153,7 +157,7 @@ describe('addMouseEventListener', () => {

it('pass through the raw event', () => {
const grid = Fixtures.grid();
grid.resizeSection('column', 2, 200);
grid.resizeColumn('body', 2, 200);
const event = Fixtures.clickEvent({ clientX: 100, clientY: 60 });
const { rawEvent } = testEvent(grid, event);
expect(rawEvent).toEqual(event);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataModel } from '@phosphor/datagrid';
import { DataModel } from '@lumino/datagrid';

import { SelectionManager } from '../../../../src/services/dataGridExtensions';

Expand Down
Loading