Skip to content

Commit 23f86dd

Browse files
committed
Fix tests
1 parent 4f9e704 commit 23f86dd

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

packages/application/src/shell.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
180180
yield* this._main.widgets;
181181
return;
182182
default:
183-
throw new Error(`Invalid area: ${area}`);
183+
console.error(`This shell has no area called "${area}"`);
184+
return;
184185
}
185186
}
186187

packages/application/test/shell.spec.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { NotebookShell, INotebookShell } from '@jupyter-notebook/application';
55

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

8-
import { toArray } from '@lumino/algorithm';
9-
108
import { Widget } from '@lumino/widgets';
119

1210
describe('Shell', () => {
@@ -31,15 +29,15 @@ describe('Shell', () => {
3129
it('should add widgets to existing areas', () => {
3230
const widget = new Widget();
3331
shell.add(widget, 'main');
34-
const widgets = toArray(shell.widgets('main'));
32+
const widgets = Array.from(shell.widgets('main'));
3533
expect(widgets).toEqual([widget]);
3634
});
3735

38-
it('should throw an exception if the area does not exist', () => {
36+
it('should be empty and console.error if area does not exist', () => {
37+
const spy = jest.spyOn(console, 'error');
3938
const jupyterFrontEndShell = shell as JupyterFrontEnd.IShell;
40-
expect(() => {
41-
jupyterFrontEndShell.widgets('left');
42-
}).toThrow('Invalid area: left');
39+
expect(Array.from(jupyterFrontEndShell.widgets('left'))).toHaveLength(0);
40+
expect(spy).toHaveBeenCalled();
4341
});
4442
});
4543

@@ -62,15 +60,15 @@ describe('Shell', () => {
6260
const widget = new Widget();
6361
widget.id = 'foo';
6462
shell.add(widget, 'top');
65-
const widgets = toArray(shell.widgets('top'));
63+
const widgets = Array.from(shell.widgets('top'));
6664
expect(widgets.length).toBeGreaterThan(0);
6765
});
6866

6967
it('should accept options', () => {
7068
const widget = new Widget();
7169
widget.id = 'foo';
7270
shell.add(widget, 'top', { rank: 10 });
73-
const widgets = toArray(shell.widgets('top'));
71+
const widgets = Array.from(shell.widgets('top'));
7472
expect(widgets.length).toBeGreaterThan(0);
7573
});
7674
});
@@ -80,7 +78,7 @@ describe('Shell', () => {
8078
const widget = new Widget();
8179
widget.id = 'foo';
8280
shell.add(widget, 'main');
83-
const widgets = toArray(shell.widgets('main'));
81+
const widgets = Array.from(shell.widgets('main'));
8482
expect(widgets.length).toBeGreaterThan(0);
8583
});
8684
});

0 commit comments

Comments
 (0)