Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Sep 6, 2022
1 parent 1965c5d commit 12648b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion packages/application/src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
yield* this._main.widgets;
return;
default:
throw new Error(`Invalid area: ${area}`);
console.error(`This shell has no area called "${area}"`);
return;
}
}

Expand Down
18 changes: 8 additions & 10 deletions packages/application/test/shell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { NotebookShell, INotebookShell } from '@jupyter-notebook/application';

import { JupyterFrontEnd } from '@jupyterlab/application';

import { toArray } from '@lumino/algorithm';

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

describe('Shell', () => {
Expand All @@ -31,15 +29,15 @@ describe('Shell', () => {
it('should add widgets to existing areas', () => {
const widget = new Widget();
shell.add(widget, 'main');
const widgets = toArray(shell.widgets('main'));
const widgets = Array.from(shell.widgets('main'));
expect(widgets).toEqual([widget]);
});

it('should throw an exception if the area does not exist', () => {
it('should be empty and console.error if area does not exist', () => {
const spy = jest.spyOn(console, 'error');
const jupyterFrontEndShell = shell as JupyterFrontEnd.IShell;
expect(() => {
jupyterFrontEndShell.widgets('left');
}).toThrow('Invalid area: left');
expect(Array.from(jupyterFrontEndShell.widgets('left'))).toHaveLength(0);
expect(spy).toHaveBeenCalled();
});
});

Expand All @@ -62,15 +60,15 @@ describe('Shell', () => {
const widget = new Widget();
widget.id = 'foo';
shell.add(widget, 'top');
const widgets = toArray(shell.widgets('top'));
const widgets = Array.from(shell.widgets('top'));
expect(widgets.length).toBeGreaterThan(0);
});

it('should accept options', () => {
const widget = new Widget();
widget.id = 'foo';
shell.add(widget, 'top', { rank: 10 });
const widgets = toArray(shell.widgets('top'));
const widgets = Array.from(shell.widgets('top'));
expect(widgets.length).toBeGreaterThan(0);
});
});
Expand All @@ -80,7 +78,7 @@ describe('Shell', () => {
const widget = new Widget();
widget.id = 'foo';
shell.add(widget, 'main');
const widgets = toArray(shell.widgets('main'));
const widgets = Array.from(shell.widgets('main'));
expect(widgets.length).toBeGreaterThan(0);
});
});
Expand Down

0 comments on commit 12648b7

Please sign in to comment.