Browse Source

wip notebook updates

Steven Silvester 6 years ago
parent
commit
18c9f0a5e9

+ 2 - 0
tests/convert-to-chai.js

@@ -43,5 +43,7 @@ glob.sync(path.join(target, 'src', '*.ts*')).forEach(function(filePath) {
   src = src.split('to.be.a(').join('to.be.an.instanceof(');
   src = src.split('to.be.an(').join('to.be.an.instanceof(');
   src = src.split(').to.be.empty()').join('.length).to.equal(0)');
+  src = src.split('let ').join('const ');
+  src = src.split('const called').join('let called');
   fs.writeFileSync(filePath, src, 'utf8');
 });

+ 2 - 1
tests/test-notebook/package.json

@@ -28,10 +28,11 @@
     "@phosphor/coreutils": "^1.3.0",
     "@phosphor/messaging": "^1.2.2",
     "@phosphor/widgets": "^1.6.0",
-    "expect.js": "~0.3.1",
+    "chai": "~4.1.2",
     "simulate-event": "~1.4.0"
   },
   "devDependencies": {
+    "@types/chai": "~4.0.10",
     "karma": "~2.0.4",
     "karma-chrome-launcher": "~2.2.0",
     "puppeteer": "^1.5.0",

File diff suppressed because it is too large
+ 234 - 234
tests/test-notebook/src/actions.spec.ts


+ 86 - 80
tests/test-notebook/src/celltools.spec.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import expect = require('expect.js');
+import { expect } from 'chai';
 
 import { Message } from '@phosphor/messaging';
 
@@ -121,39 +121,43 @@ describe('@jupyterlab/notebook', () => {
     describe('CellTools', () => {
       describe('#constructor()', () => {
         it('should create a celltools object', () => {
-          expect(celltools).to.be.a(CellTools);
+          expect(celltools).to.be.an.instanceof(CellTools);
         });
       });
 
       describe('#activeCell', () => {
         it('should be the active cell', () => {
-          expect(celltools.activeCell).to.be(panel1.content.activeCell);
+          expect(celltools.activeCell).to.equal(panel1.content.activeCell);
           tabpanel.currentIndex = 0;
           simulate(panel0.node, 'focus');
-          expect(celltools.activeCell).to.be(panel0.content.activeCell);
+          expect(celltools.activeCell).to.equal(panel0.content.activeCell);
         });
       });
 
       describe('#selectedCells', () => {
         it('should be the currently selected cells', () => {
-          expect(celltools.selectedCells).to.eql([panel1.content.activeCell]);
+          expect(celltools.selectedCells).to.deep.equal([
+            panel1.content.activeCell
+          ]);
           tabpanel.currentIndex = 0;
           simulate(panel0.node, 'focus');
-          expect(celltools.selectedCells).to.eql([panel0.content.activeCell]);
+          expect(celltools.selectedCells).to.deep.equal([
+            panel0.content.activeCell
+          ]);
           panel0.content.select(panel0.content.widgets[1]);
-          expect(celltools.selectedCells.length).to.be(2);
+          expect(celltools.selectedCells.length).to.equal(2);
         });
       });
 
       describe('#addItem()', () => {
         it('should add a cell tool item', () => {
-          let tool = new CellTools.Tool();
+          const tool = new CellTools.Tool();
           celltools.addItem({ tool });
           tool.dispose();
         });
 
         it('should accept a rank', () => {
-          let tool = new CellTools.Tool();
+          const tool = new CellTools.Tool();
           celltools.addItem({ tool, rank: 100 });
           tool.dispose();
         });
@@ -163,22 +167,22 @@ describe('@jupyterlab/notebook', () => {
     describe('CellTools.Tool', () => {
       describe('#constructor', () => {
         it('should create a new base tool', () => {
-          let tool = new CellTools.Tool();
-          expect(tool).to.be.a(CellTools.Tool);
+          const tool = new CellTools.Tool();
+          expect(tool).to.be.an.instanceof(CellTools.Tool);
         });
       });
 
       describe('#parent', () => {
         it('should be the celltools object used by the tool', () => {
-          let tool = new CellTools.Tool({});
+          const tool = new CellTools.Tool({});
           celltools.addItem({ tool });
-          expect(tool.parent).to.be(celltools);
+          expect(tool.parent).to.equal(celltools);
         });
       });
 
       describe('#onActiveCellChanged()', () => {
         it('should be called when the active cell changes', () => {
-          let tool = new LogTool({});
+          const tool = new LogTool({});
           celltools.addItem({ tool });
           tool.methods = [];
           simulate(panel0.node, 'focus');
@@ -188,10 +192,10 @@ describe('@jupyterlab/notebook', () => {
 
       describe('#onSelectionChanged()', () => {
         it('should be called when the selection changes', () => {
-          let tool = new LogTool({});
+          const tool = new LogTool({});
           celltools.addItem({ tool });
           tool.methods = [];
-          let current = tracker.currentWidget;
+          const current = tracker.currentWidget;
           current.content.select(current.content.widgets[1]);
           expect(tool.methods).to.contain('onSelectionChanged');
         });
@@ -199,10 +203,10 @@ describe('@jupyterlab/notebook', () => {
 
       describe('#onMetadataChanged()', () => {
         it('should be called when the metadata changes', () => {
-          let tool = new LogTool({});
+          const tool = new LogTool({});
           celltools.addItem({ tool });
           tool.methods = [];
-          let metadata = celltools.activeCell.model.metadata;
+          const metadata = celltools.activeCell.model.metadata;
           metadata.set('foo', 1);
           metadata.set('foo', 2);
           expect(tool.methods).to.contain('onMetadataChanged');
@@ -212,49 +216,49 @@ describe('@jupyterlab/notebook', () => {
 
     describe('CellTools.ActiveCellTool', () => {
       it('should create a new active cell tool', () => {
-        let tool = new CellTools.ActiveCellTool();
+        const tool = new CellTools.ActiveCellTool();
         celltools.addItem({ tool });
-        expect(tool).to.be.a(CellTools.ActiveCellTool);
+        expect(tool).to.be.an.instanceof(CellTools.ActiveCellTool);
       });
 
       it('should handle a change to the active cell', () => {
-        let tool = new CellTools.ActiveCellTool();
+        const tool = new CellTools.ActiveCellTool();
         celltools.addItem({ tool });
-        let widget = tracker.currentWidget;
+        const widget = tracker.currentWidget;
         widget.content.activeCellIndex++;
         widget.content.activeCell.model.metadata.set('bar', 1);
-        expect(tool.node.querySelector('.jp-InputArea-editor')).to.be.ok();
+        expect(tool.node.querySelector('.jp-InputArea-editor')).to.be.ok;
       });
     });
 
     describe('CellTools.MetadataEditorTool', () => {
-      let editorServices = new CodeMirrorEditorFactory();
+      const editorServices = new CodeMirrorEditorFactory();
       const editorFactory = editorServices.newInlineEditor.bind(editorServices);
 
       it('should create a new metadata editor tool', () => {
-        let tool = new CellTools.MetadataEditorTool({ editorFactory });
-        expect(tool).to.be.a(CellTools.MetadataEditorTool);
+        const tool = new CellTools.MetadataEditorTool({ editorFactory });
+        expect(tool).to.be.an.instanceof(CellTools.MetadataEditorTool);
       });
 
       it('should handle a change to the active cell', () => {
-        let tool = new CellTools.MetadataEditorTool({ editorFactory });
+        const tool = new CellTools.MetadataEditorTool({ editorFactory });
         celltools.addItem({ tool });
-        let model = tool.editor.model;
-        expect(JSON.stringify(model.value.text)).to.ok();
-        let widget = tracker.currentWidget;
+        const model = tool.editor.model;
+        expect(JSON.stringify(model.value.text)).to.be.ok;
+        const widget = tracker.currentWidget;
         widget.content.activeCellIndex++;
         widget.content.activeCell.model.metadata.set('bar', 1);
         expect(JSON.stringify(model.value.text)).to.contain('bar');
       });
 
       it('should handle a change to the metadata', () => {
-        let tool = new CellTools.MetadataEditorTool({ editorFactory });
+        const tool = new CellTools.MetadataEditorTool({ editorFactory });
         celltools.addItem({ tool });
-        let model = tool.editor.model;
-        let previous = model.value.text;
-        let metadata = celltools.activeCell.model.metadata;
+        const model = tool.editor.model;
+        const previous = model.value.text;
+        const metadata = celltools.activeCell.model.metadata;
         metadata.set('foo', 1);
-        expect(model.value.text).to.not.be(previous);
+        expect(model.value.text).to.not.equal(previous);
       });
     });
 
@@ -280,165 +284,167 @@ describe('@jupyterlab/notebook', () => {
 
       describe('#constructor()', () => {
         it('should create a new key selector', () => {
-          expect(tool).to.be.a(CellTools.KeySelector);
+          expect(tool).to.be.an.instanceof(CellTools.KeySelector);
         });
       });
 
       describe('#key', () => {
         it('should be the key used by the selector', () => {
-          expect(tool.key).to.be('foo');
+          expect(tool.key).to.equal('foo');
         });
       });
 
       describe('#selectNode', () => {
         it('should be the select node', () => {
-          expect(tool.selectNode.localName).to.be('select');
+          expect(tool.selectNode.localName).to.equal('select');
         });
       });
 
       describe('#handleEvent()', () => {
         context('change', () => {
           it('should update the metadata', () => {
-            let select = tool.selectNode;
+            const select = tool.selectNode;
             simulate(select, 'focus');
             select.selectedIndex = 1;
             simulate(select, 'change');
             expect(tool.events).to.contain('change');
-            let metadata = celltools.activeCell.model.metadata;
-            expect(metadata.get('foo')).to.eql([1, 2, 'a']);
+            const metadata = celltools.activeCell.model.metadata;
+            expect(metadata.get('foo')).to.deep.equal([1, 2, 'a']);
           });
         });
 
         context('focus', () => {
           it('should add the focused class to the wrapper node', () => {
-            let select = tool.selectNode;
+            const select = tool.selectNode;
             simulate(select, 'focus');
-            let selector = '.jp-mod-focused';
-            expect(tool.node.querySelector(selector)).to.be.ok();
+            const selector = '.jp-mod-focused';
+            expect(tool.node.querySelector(selector)).to.be.ok;
           });
         });
 
         context('blur', () => {
           it('should remove the focused class from the wrapper node', () => {
-            let select = tool.selectNode;
+            const select = tool.selectNode;
             simulate(select, 'focus');
             simulate(select, 'blur');
-            let selector = '.jp-mod-focused';
-            expect(tool.node.querySelector(selector)).to.not.be.ok();
+            const selector = '.jp-mod-focused';
+            expect(tool.node.querySelector(selector)).to.not.be.ok;
           });
         });
       });
 
       describe('#onAfterAttach()', () => {
         it('should add event listeners', () => {
-          let select = tool.selectNode;
+          const select = tool.selectNode;
           expect(tool.methods).to.contain('onAfterAttach');
           simulate(select, 'focus');
           simulate(select, 'blur');
           select.selectedIndex = 0;
           simulate(select, 'change');
-          expect(tool.events).to.eql(['change']);
+          expect(tool.events).to.deep.equal(['change']);
         });
       });
 
       describe('#onBeforeDetach()', () => {
         it('should remove event listeners', () => {
-          let select = tool.selectNode;
+          const select = tool.selectNode;
           celltools.dispose();
           expect(tool.methods).to.contain('onBeforeDetach');
           simulate(select, 'focus');
           simulate(select, 'blur');
           simulate(select, 'change');
-          expect(tool.events).to.eql([]);
+          expect(tool.events).to.deep.equal([]);
         });
       });
 
       describe('#onValueChanged()', () => {
         it('should update the metadata', () => {
-          let select = tool.selectNode;
+          const select = tool.selectNode;
           simulate(select, 'focus');
           select.selectedIndex = 1;
           simulate(select, 'change');
           expect(tool.methods).to.contain('onValueChanged');
-          let metadata = celltools.activeCell.model.metadata;
-          expect(metadata.get('foo')).to.eql([1, 2, 'a']);
+          const metadata = celltools.activeCell.model.metadata;
+          expect(metadata.get('foo')).to.deep.equal([1, 2, 'a']);
         });
       });
 
       describe('#onActiveCellChanged()', () => {
         it('should update the select value', () => {
-          let cell = panel0.content.model.cells.get(1);
+          const cell = panel0.content.model.cells.get(1);
           cell.metadata.set('foo', 1);
           panel0.content.activeCellIndex = 1;
           expect(tool.methods).to.contain('onActiveCellChanged');
-          expect(tool.selectNode.value).to.be('1');
+          expect(tool.selectNode.value).to.equal('1');
         });
       });
 
       describe('#onMetadataChanged()', () => {
         it('should update the select value', () => {
-          let metadata = celltools.activeCell.model.metadata;
+          const metadata = celltools.activeCell.model.metadata;
           metadata.set('foo', 1);
           expect(tool.methods).to.contain('onMetadataChanged');
-          expect(tool.selectNode.value).to.be('1');
+          expect(tool.selectNode.value).to.equal('1');
         });
       });
     });
 
     describe('CellTools.createSlideShowSelector()', () => {
       it('should create a slide show selector', () => {
-        let tool = CellTools.createSlideShowSelector();
+        const tool = CellTools.createSlideShowSelector();
         tool.selectNode.selectedIndex = -1;
         celltools.addItem({ tool });
         simulate(panel0.node, 'focus');
         tabpanel.currentIndex = 2;
-        expect(tool).to.be.a(CellTools.KeySelector);
-        expect(tool.key).to.be('slideshow');
-        let select = tool.selectNode;
-        expect(select.value).to.be('');
-        let metadata = celltools.activeCell.model.metadata;
-        expect(metadata.get('slideshow')).to.be(void 0);
+        expect(tool).to.be.an.instanceof(CellTools.KeySelector);
+        expect(tool.key).to.equal('slideshow');
+        const select = tool.selectNode;
+        expect(select.value).to.equal('');
+        const metadata = celltools.activeCell.model.metadata;
+        expect(metadata.get('slideshow')).to.be.undefined;
         simulate(select, 'focus');
         tool.selectNode.selectedIndex = 1;
         simulate(select, 'change');
-        expect(metadata.get('slideshow')).to.eql({ slide_type: 'slide' });
+        expect(metadata.get('slideshow')).to.deep.equal({
+          slide_type: 'slide'
+        });
       });
     });
 
     describe('CellTools.createNBConvertSelector()', () => {
       it('should create a raw mimetype selector', () => {
-        let tool = CellTools.createNBConvertSelector();
+        const tool = CellTools.createNBConvertSelector();
         tool.selectNode.selectedIndex = -1;
         celltools.addItem({ tool });
         simulate(panel0.node, 'focus');
         NotebookActions.changeCellType(panel0.content, 'raw');
         tabpanel.currentIndex = 2;
-        expect(tool).to.be.a(CellTools.KeySelector);
-        expect(tool.key).to.be('raw_mimetype');
-        let select = tool.selectNode;
-        expect(select.value).to.be('');
+        expect(tool).to.be.an.instanceof(CellTools.KeySelector);
+        expect(tool.key).to.equal('raw_mimetype');
+        const select = tool.selectNode;
+        expect(select.value).to.equal('');
 
-        let metadata = celltools.activeCell.model.metadata;
-        expect(metadata.get('raw_mimetype')).to.be(void 0);
+        const metadata = celltools.activeCell.model.metadata;
+        expect(metadata.get('raw_mimetype')).to.be.undefined;
         simulate(select, 'focus');
         tool.selectNode.selectedIndex = 2;
         simulate(select, 'change');
-        expect(metadata.get('raw_mimetype')).to.be('text/restructuredtext');
+        expect(metadata.get('raw_mimetype')).to.equal('text/restructuredtext');
       });
 
       it('should have no effect on a code cell', () => {
-        let tool = CellTools.createNBConvertSelector();
+        const tool = CellTools.createNBConvertSelector();
         tool.selectNode.selectedIndex = -1;
         celltools.addItem({ tool });
         simulate(panel0.node, 'focus');
         NotebookActions.changeCellType(panel0.content, 'code');
 
         tabpanel.currentIndex = 2;
-        expect(tool).to.be.a(CellTools.KeySelector);
-        expect(tool.key).to.be('raw_mimetype');
-        let select = tool.selectNode;
-        expect(select.disabled).to.be(true);
-        expect(select.value).to.be('');
+        expect(tool).to.be.an.instanceof(CellTools.KeySelector);
+        expect(tool.key).to.equal('raw_mimetype');
+        const select = tool.selectNode;
+        expect(select.disabled).to.equal(true);
+        expect(select.value).to.equal('');
       });
     });
   });

+ 45 - 45
tests/test-notebook/src/default-toolbar.spec.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import expect = require('expect.js');
+import { expect } from 'chai';
 
 import { toArray } from '@phosphor/algorithm';
 
@@ -49,7 +49,7 @@ describe('@jupyterlab/notebook', () => {
 
     describe('#createSaveButton()', () => {
       it('should save when clicked', done => {
-        let button = ToolbarItems.createSaveButton(panel);
+        const button = ToolbarItems.createSaveButton(panel);
         Widget.attach(button, document.body);
         context.fileChanged.connect(() => {
           button.dispose();
@@ -59,83 +59,83 @@ describe('@jupyterlab/notebook', () => {
       });
 
       it("should have the `'jp-SaveIcon'` class", () => {
-        let button = ToolbarItems.createSaveButton(panel);
-        expect(button.hasClass('jp-SaveIcon')).to.be(true);
+        const button = ToolbarItems.createSaveButton(panel);
+        expect(button.hasClass('jp-SaveIcon')).to.equal(true);
       });
     });
 
     describe('#createInsertButton()', () => {
       it('should insert below when clicked', () => {
-        let button = ToolbarItems.createInsertButton(panel);
+        const button = ToolbarItems.createInsertButton(panel);
         Widget.attach(button, document.body);
         button.node.click();
-        expect(panel.content.activeCellIndex).to.be(1);
-        expect(panel.content.activeCell).to.be.a(CodeCell);
+        expect(panel.content.activeCellIndex).to.equal(1);
+        expect(panel.content.activeCell).to.be.an.instanceof(CodeCell);
         button.dispose();
       });
 
       it("should have the `'jp-AddIcon'` class", () => {
-        let button = ToolbarItems.createInsertButton(panel);
-        expect(button.hasClass('jp-AddIcon')).to.be(true);
+        const button = ToolbarItems.createInsertButton(panel);
+        expect(button.hasClass('jp-AddIcon')).to.equal(true);
       });
     });
 
     describe('#createCutButton()', () => {
       it('should cut when clicked', () => {
-        let button = ToolbarItems.createCutButton(panel);
-        let count = panel.content.widgets.length;
+        const button = ToolbarItems.createCutButton(panel);
+        const count = panel.content.widgets.length;
         Widget.attach(button, document.body);
         button.node.click();
-        expect(panel.content.widgets.length).to.be(count - 1);
-        expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
+        expect(panel.content.widgets.length).to.equal(count - 1);
+        expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.equal(true);
         button.dispose();
       });
 
       it("should have the `'jp-CutIcon'` class", () => {
-        let button = ToolbarItems.createCutButton(panel);
-        expect(button.hasClass('jp-CutIcon')).to.be(true);
+        const button = ToolbarItems.createCutButton(panel);
+        expect(button.hasClass('jp-CutIcon')).to.equal(true);
       });
     });
 
     describe('#createCopyButton()', () => {
       it('should copy when clicked', () => {
-        let button = ToolbarItems.createCopyButton(panel);
-        let count = panel.content.widgets.length;
+        const button = ToolbarItems.createCopyButton(panel);
+        const count = panel.content.widgets.length;
         Widget.attach(button, document.body);
         button.node.click();
-        expect(panel.content.widgets.length).to.be(count);
-        expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
+        expect(panel.content.widgets.length).to.equal(count);
+        expect(NBTestUtils.clipboard.hasData(JUPYTER_CELL_MIME)).to.equal(true);
         button.dispose();
       });
 
       it("should have the `'jp-CopyIcon'` class", () => {
-        let button = ToolbarItems.createCopyButton(panel);
-        expect(button.hasClass('jp-CopyIcon')).to.be(true);
+        const button = ToolbarItems.createCopyButton(panel);
+        expect(button.hasClass('jp-CopyIcon')).to.equal(true);
       });
     });
 
     describe('#createPasteButton()', () => {
       it('should paste when clicked', async () => {
-        let button = ToolbarItems.createPasteButton(panel);
-        let count = panel.content.widgets.length;
+        const button = ToolbarItems.createPasteButton(panel);
+        const count = panel.content.widgets.length;
         Widget.attach(button, document.body);
         NotebookActions.copy(panel.content);
         button.node.click();
         await sleep();
-        expect(panel.content.widgets.length).to.be(count + 1);
+        expect(panel.content.widgets.length).to.equal(count + 1);
         button.dispose();
       });
 
       it("should have the `'jp-PasteIcon'` class", () => {
-        let button = ToolbarItems.createPasteButton(panel);
-        expect(button.hasClass('jp-PasteIcon')).to.be(true);
+        const button = ToolbarItems.createPasteButton(panel);
+        expect(button.hasClass('jp-PasteIcon')).to.equal(true);
       });
     });
 
     describe('#createRunButton()', () => {
       it('should run and advance when clicked', async () => {
-        let button = ToolbarItems.createRunButton(panel);
-        let widget = panel.content;
+        const button = ToolbarItems.createRunButton(panel);
+        const widget = panel.content;
 
         // Clear and select the first two cells.
         const codeCell = widget.widgets[0] as CodeCell;
@@ -153,7 +153,7 @@ describe('@jupyterlab/notebook', () => {
         context.session.statusChanged.connect((sender, status) => {
           // Find the right status idle message
           if (status === 'idle' && codeCell.model.outputs.length > 0) {
-            expect(mdCell.rendered).to.be(true);
+            expect(mdCell.rendered).to.equal(true);
             expect(widget.activeCellIndex).to.equal(2);
             button.dispose();
             p.resolve(0);
@@ -164,49 +164,49 @@ describe('@jupyterlab/notebook', () => {
       });
 
       it("should have the `'jp-RunIcon'` class", () => {
-        let button = ToolbarItems.createRunButton(panel);
-        expect(button.hasClass('jp-RunIcon')).to.be(true);
+        const button = ToolbarItems.createRunButton(panel);
+        expect(button.hasClass('jp-RunIcon')).to.equal(true);
       });
     });
 
     describe('#createCellTypeItem()', () => {
       it('should track the cell type of the current cell', () => {
-        let item = ToolbarItems.createCellTypeItem(panel);
-        let node = item.node.getElementsByTagName(
+        const item = ToolbarItems.createCellTypeItem(panel);
+        const node = item.node.getElementsByTagName(
           'select'
         )[0] as HTMLSelectElement;
-        expect(node.value).to.be('code');
+        expect(node.value).to.equal('code');
         panel.content.activeCellIndex++;
-        expect(node.value).to.be('markdown');
+        expect(node.value).to.equal('markdown');
       });
 
       it("should display `'-'` if multiple cell types are selected", () => {
-        let item = ToolbarItems.createCellTypeItem(panel);
-        let node = item.node.getElementsByTagName(
+        const item = ToolbarItems.createCellTypeItem(panel);
+        const node = item.node.getElementsByTagName(
           'select'
         )[0] as HTMLSelectElement;
-        expect(node.value).to.be('code');
+        expect(node.value).to.equal('code');
         panel.content.select(panel.content.widgets[1]);
-        expect(node.value).to.be('-');
+        expect(node.value).to.equal('-');
       });
 
       it('should display the active cell type if multiple cells of the same type are selected', () => {
-        let item = ToolbarItems.createCellTypeItem(panel);
-        let node = item.node.getElementsByTagName(
+        const item = ToolbarItems.createCellTypeItem(panel);
+        const node = item.node.getElementsByTagName(
           'select'
         )[0] as HTMLSelectElement;
-        expect(node.value).to.be('code');
-        let cell = panel.model.contentFactory.createCodeCell({});
+        expect(node.value).to.equal('code');
+        const cell = panel.model.contentFactory.createCodeCell({});
         panel.model.cells.insert(1, cell);
         panel.content.select(panel.content.widgets[1]);
-        expect(node.value).to.be('code');
+        expect(node.value).to.equal('code');
       });
     });
 
     describe('#populateDefaults()', () => {
       it('should add the default items to the panel toolbar', () => {
         ToolbarItems.populateDefaults(panel);
-        expect(toArray(panel.toolbar.names())).to.eql([
+        expect(toArray(panel.toolbar.names())).to.deep.equal([
           'save',
           'insert',
           'cut',

+ 152 - 150
tests/test-notebook/src/model.spec.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import expect = require('expect.js');
+import { expect } from 'chai';
 
 import { ArrayExt, toArray } from '@phosphor/algorithm';
 
@@ -19,28 +19,28 @@ describe('@jupyterlab/notebook', () => {
   describe('NotebookModel', () => {
     describe('#constructor()', () => {
       it('should create a notebook model', () => {
-        let model = new NotebookModel();
-        expect(model).to.be.a(NotebookModel);
+        const model = new NotebookModel();
+        expect(model).to.be.an.instanceof(NotebookModel);
       });
 
       it('should accept an optional language preference', () => {
-        let model = new NotebookModel({ languagePreference: 'python' });
-        let lang = model.metadata.get(
+        const model = new NotebookModel({ languagePreference: 'python' });
+        const lang = model.metadata.get(
           'language_info'
         ) as nbformat.ILanguageInfoMetadata;
-        expect(lang.name).to.be('python');
+        expect(lang.name).to.equal('python');
       });
 
       it('should add a single code cell by default', () => {
-        let model = new NotebookModel();
-        expect(model.cells.length).to.be(1);
-        expect(model.cells.get(0)).to.be.a(CodeCellModel);
+        const model = new NotebookModel();
+        expect(model.cells.length).to.equal(1);
+        expect(model.cells.get(0)).to.be.an.instanceof(CodeCellModel);
       });
 
       it('should accept an optional factory', () => {
-        let contentFactory = new NotebookModel.ContentFactory({});
-        let model = new NotebookModel({ contentFactory });
-        expect(model.contentFactory.codeCellContentFactory).to.be(
+        const contentFactory = new NotebookModel.ContentFactory({});
+        const model = new NotebookModel({ contentFactory });
+        expect(model.contentFactory.codeCellContentFactory).to.equal(
           contentFactory.codeCellContentFactory
         );
       });
@@ -48,87 +48,87 @@ describe('@jupyterlab/notebook', () => {
 
     describe('#metadataChanged', () => {
       it('should be emitted when a metadata field changes', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         let called = false;
         model.metadata.changed.connect((sender, args) => {
-          expect(sender).to.be(model.metadata);
-          expect(args.key).to.be('foo');
-          expect(args.oldValue).to.be(void 0);
-          expect(args.newValue).to.be(1);
+          expect(sender).to.equal(model.metadata);
+          expect(args.key).to.equal('foo');
+          expect(args.oldValue).to.be.undefined;
+          expect(args.newValue).to.equal(1);
           called = true;
         });
         model.metadata.set('foo', 1);
-        expect(called).to.be(true);
+        expect(called).to.equal(true);
       });
 
       it('should not be emitted when the value does not change', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         let called = false;
         model.metadata.set('foo', 1);
         model.metadata.changed.connect(() => {
           called = true;
         });
         model.metadata.set('foo', 1);
-        expect(called).to.be(false);
+        expect(called).to.equal(false);
       });
     });
 
     describe('#cells', () => {
       it('should add an empty code cell by default', () => {
-        let model = new NotebookModel();
-        expect(model.cells.length).to.be(1);
-        expect(model.cells.get(0)).to.be.a(CodeCellModel);
+        const model = new NotebookModel();
+        expect(model.cells.length).to.equal(1);
+        expect(model.cells.get(0)).to.be.an.instanceof(CodeCellModel);
       });
 
       it('should be reset when loading from disk', () => {
-        let model = new NotebookModel();
-        let cell = model.contentFactory.createCodeCell({});
+        const model = new NotebookModel();
+        const cell = model.contentFactory.createCodeCell({});
         model.cells.push(cell);
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
-        expect(ArrayExt.firstIndexOf(toArray(model.cells), cell)).to.be(-1);
-        expect(model.cells.length).to.be(6);
+        expect(ArrayExt.firstIndexOf(toArray(model.cells), cell)).to.equal(-1);
+        expect(model.cells.length).to.equal(6);
       });
 
       it('should allow undoing a change', () => {
-        let model = new NotebookModel();
-        let cell = model.contentFactory.createCodeCell({});
+        const model = new NotebookModel();
+        const cell = model.contentFactory.createCodeCell({});
         cell.value.text = 'foo';
         model.cells.push(cell);
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
         model.cells.undo();
-        expect(model.cells.length).to.be(2);
-        expect(model.cells.get(1).value.text).to.be('foo');
-        expect(model.cells.get(1)).to.be(cell); // should be ===.
+        expect(model.cells.length).to.equal(2);
+        expect(model.cells.get(1).value.text).to.equal('foo');
+        expect(model.cells.get(1)).to.equal(cell); // should be ===.
       });
 
       context('cells `changed` signal', () => {
         it('should emit a `contentChanged` signal upon cell addition', () => {
-          let model = new NotebookModel();
-          let cell = model.contentFactory.createCodeCell({});
+          const model = new NotebookModel();
+          const cell = model.contentFactory.createCodeCell({});
           let called = false;
           model.contentChanged.connect(() => {
             called = true;
           });
           model.cells.push(cell);
-          expect(called).to.be(true);
+          expect(called).to.equal(true);
         });
 
         it('should emit a `contentChanged` signal upon cell removal', () => {
-          let model = new NotebookModel();
-          let cell = model.contentFactory.createCodeCell({});
+          const model = new NotebookModel();
+          const cell = model.contentFactory.createCodeCell({});
           model.cells.push(cell);
           let called = false;
           model.contentChanged.connect(() => {
             called = true;
           });
           model.cells.remove(0);
-          expect(called).to.be(true);
+          expect(called).to.equal(true);
         });
 
         it('should emit a `contentChanged` signal upon cell move', () => {
-          let model = new NotebookModel();
-          let cell0 = model.contentFactory.createCodeCell({});
-          let cell1 = model.contentFactory.createCodeCell({});
+          const model = new NotebookModel();
+          const cell0 = model.contentFactory.createCodeCell({});
+          const cell1 = model.contentFactory.createCodeCell({});
           model.cells.push(cell0);
           model.cells.push(cell1);
           let called = false;
@@ -136,60 +136,60 @@ describe('@jupyterlab/notebook', () => {
             called = true;
           });
           model.cells.move(0, 1);
-          expect(called).to.be(true);
+          expect(called).to.equal(true);
         });
 
         it('should set the dirty flag', () => {
-          let model = new NotebookModel();
-          let cell = model.contentFactory.createCodeCell({});
+          const model = new NotebookModel();
+          const cell = model.contentFactory.createCodeCell({});
           model.cells.push(cell);
-          expect(model.dirty).to.be(true);
+          expect(model.dirty).to.equal(true);
         });
 
         it('should add a new code cell when cells are cleared', async () => {
-          let model = new NotebookModel();
+          const model = new NotebookModel();
           model.cells.clear();
           await sleep();
-          expect(model.cells.length).to.be(1);
-          expect(model.cells.get(0)).to.be.a(CodeCellModel);
+          expect(model.cells.length).to.equal(1);
+          expect(model.cells.get(0)).to.be.an.instanceof(CodeCellModel);
         });
       });
 
       describe('cell `changed` signal', () => {
         it('should be called when a cell content changes', () => {
-          let model = new NotebookModel();
-          let cell = model.contentFactory.createCodeCell({});
+          const model = new NotebookModel();
+          const cell = model.contentFactory.createCodeCell({});
           model.cells.push(cell);
           cell.value.text = 'foo';
         });
 
         it('should emit the `contentChanged` signal', () => {
-          let model = new NotebookModel();
-          let cell = model.contentFactory.createCodeCell({});
+          const model = new NotebookModel();
+          const cell = model.contentFactory.createCodeCell({});
           model.cells.push(cell);
           let called = false;
           model.contentChanged.connect(() => {
             called = true;
           });
           model.metadata.set('foo', 'bar');
-          expect(called).to.be(true);
+          expect(called).to.equal(true);
         });
 
         it('should set the dirty flag', () => {
-          let model = new NotebookModel();
-          let cell = model.contentFactory.createCodeCell({});
+          const model = new NotebookModel();
+          const cell = model.contentFactory.createCodeCell({});
           model.cells.push(cell);
           model.dirty = false;
           cell.value.text = 'foo';
-          expect(model.dirty).to.be(true);
+          expect(model.dirty).to.equal(true);
         });
       });
     });
 
     describe('#contentFactory', () => {
       it('should be the cell model factory used by the model', () => {
-        let model = new NotebookModel();
-        expect(model.contentFactory.codeCellContentFactory).to.be(
+        const model = new NotebookModel();
+        expect(model.contentFactory.codeCellContentFactory).to.equal(
           NotebookModel.defaultContentFactory.codeCellContentFactory
         );
       });
@@ -197,157 +197,157 @@ describe('@jupyterlab/notebook', () => {
 
     describe('#nbformat', () => {
       it('should get the major version number of the nbformat', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
-        expect(model.nbformat).to.be(NBTestUtils.DEFAULT_CONTENT.nbformat);
+        expect(model.nbformat).to.equal(NBTestUtils.DEFAULT_CONTENT.nbformat);
       });
     });
 
     describe('#nbformatMinor', () => {
       it('should get the minor version number of the nbformat', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
-        expect(model.nbformatMinor).to.be(nbformat.MINOR_VERSION);
+        expect(model.nbformatMinor).to.equal(nbformat.MINOR_VERSION);
       });
     });
 
     describe('#defaultKernelName()', () => {
       it('should get the default kernel name of the document', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.metadata.set('kernelspec', { name: 'python3' });
-        expect(model.defaultKernelName).to.be('python3');
+        expect(model.defaultKernelName).to.equal('python3');
       });
 
       it('should default to an empty string', () => {
-        let model = new NotebookModel();
-        expect(model.defaultKernelName).to.be('');
+        const model = new NotebookModel();
+        expect(model.defaultKernelName).to.equal('');
       });
     });
 
     describe('#defaultKernelLanguage', () => {
       it('should get the default kernel language of the document', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.metadata.set('language_info', { name: 'python' });
-        expect(model.defaultKernelLanguage).to.be('python');
+        expect(model.defaultKernelLanguage).to.equal('python');
       });
 
       it('should default to an empty string', () => {
-        let model = new NotebookModel();
-        expect(model.defaultKernelLanguage).to.be('');
+        const model = new NotebookModel();
+        expect(model.defaultKernelLanguage).to.equal('');
       });
 
       it('should be set from the constructor arg', () => {
-        let model = new NotebookModel({ languagePreference: 'foo' });
-        expect(model.defaultKernelLanguage).to.be('foo');
+        const model = new NotebookModel({ languagePreference: 'foo' });
+        expect(model.defaultKernelLanguage).to.equal('foo');
       });
     });
 
     describe('#dispose()', () => {
       it('should dispose of the resources held by the model', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
         model.dispose();
-        expect(model.cells).to.be(null);
-        expect(model.isDisposed).to.be(true);
+        expect(model.cells).to.be.null;
+        expect(model.isDisposed).to.equal(true);
       });
 
       it('should be safe to call multiple times', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.dispose();
         model.dispose();
-        expect(model.isDisposed).to.be(true);
+        expect(model.isDisposed).to.equal(true);
       });
     });
 
     describe('#toString()', () => {
       it('should serialize the model to a string', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
-        let text = model.toString();
-        let data = JSON.parse(text);
-        expect(data.cells.length).to.be(6);
+        const text = model.toString();
+        const data = JSON.parse(text);
+        expect(data.cells.length).to.equal(6);
       });
     });
 
     describe('#fromString()', () => {
       it('should deserialize the model from a string', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.fromString(JSON.stringify(NBTestUtils.DEFAULT_CONTENT));
-        expect(model.cells.length).to.be(6);
+        expect(model.cells.length).to.equal(6);
       });
 
       it('should set the dirty flag', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.dirty = false;
         model.fromString(JSON.stringify(NBTestUtils.DEFAULT_CONTENT));
-        expect(model.dirty).to.be(true);
+        expect(model.dirty).to.equal(true);
       });
     });
 
     describe('#toJSON()', () => {
       it('should serialize the model to JSON', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
-        let data = model.toJSON();
-        expect(data.cells.length).to.be(6);
+        const data = model.toJSON();
+        expect(data.cells.length).to.equal(6);
       });
     });
 
     describe('#fromJSON()', () => {
       it('should serialize the model from JSON', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
-        expect(model.cells.length).to.be(6);
-        expect(model.nbformat).to.be(NBTestUtils.DEFAULT_CONTENT.nbformat);
-        expect(model.nbformatMinor).to.be(nbformat.MINOR_VERSION);
+        expect(model.cells.length).to.equal(6);
+        expect(model.nbformat).to.equal(NBTestUtils.DEFAULT_CONTENT.nbformat);
+        expect(model.nbformatMinor).to.equal(nbformat.MINOR_VERSION);
       });
 
       it('should set the dirty flag', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         model.dirty = false;
         model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
-        expect(model.dirty).to.be(true);
+        expect(model.dirty).to.equal(true);
       });
     });
 
     describe('#metadata', () => {
       it('should have default values', () => {
-        let model = new NotebookModel();
-        let metadata = model.metadata;
+        const model = new NotebookModel();
+        const metadata = model.metadata;
         expect(metadata.has('kernelspec'));
         expect(metadata.has('language_info'));
-        expect(metadata.size).to.be(2);
+        expect(metadata.size).to.equal(2);
       });
 
       it('should set the dirty flag when changed', () => {
-        let model = new NotebookModel();
-        expect(model.dirty).to.be(false);
+        const model = new NotebookModel();
+        expect(model.dirty).to.equal(false);
         model.metadata.set('foo', 'bar');
-        expect(model.dirty).to.be(true);
+        expect(model.dirty).to.equal(true);
       });
 
       it('should emit the `contentChanged` signal', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         let called = false;
         model.contentChanged.connect(() => {
           called = true;
         });
         model.metadata.set('foo', 'bar');
-        expect(called).to.be(true);
+        expect(called).to.equal(true);
       });
 
       it('should emit the `metadataChanged` signal', () => {
-        let model = new NotebookModel();
+        const model = new NotebookModel();
         let called = false;
         model.metadata.changed.connect((sender, args) => {
-          expect(sender).to.be(model.metadata);
-          expect(args.key).to.be('foo');
-          expect(args.oldValue).to.be(void 0);
-          expect(args.newValue).to.be('bar');
+          expect(sender).to.equal(model.metadata);
+          expect(args.key).to.equal('foo');
+          expect(args.oldValue).to.be.undefined;
+          expect(args.newValue).to.equal('bar');
           called = true;
         });
         model.metadata.set('foo', 'bar');
-        expect(called).to.be(true);
+        expect(called).to.equal(true);
       });
     });
 
@@ -356,104 +356,106 @@ describe('@jupyterlab/notebook', () => {
 
       context('#codeCellContentFactory', () => {
         it('should be a code cell content factory', () => {
-          expect(factory.codeCellContentFactory).to.be(
+          expect(factory.codeCellContentFactory).to.equal(
             CodeCellModel.defaultContentFactory
           );
         });
 
         it('should be settable in the constructor', () => {
-          let codeCellContentFactory = new CodeCellModel.ContentFactory();
+          const codeCellContentFactory = new CodeCellModel.ContentFactory();
           factory = new NotebookModel.ContentFactory({
             codeCellContentFactory
           });
-          expect(factory.codeCellContentFactory).to.be(codeCellContentFactory);
+          expect(factory.codeCellContentFactory).to.equal(
+            codeCellContentFactory
+          );
         });
       });
 
       context('#createCodeCell()', () => {
         it('should create a new code cell', () => {
-          let cell = factory.createCodeCell({});
-          expect(cell.type).to.be('code');
+          const cell = factory.createCodeCell({});
+          expect(cell.type).to.equal('code');
         });
 
         it('should clone an existing code cell', () => {
-          let orig = factory.createCodeCell({});
+          const orig = factory.createCodeCell({});
           orig.value.text = 'foo';
-          let cell = orig.toJSON();
-          let newCell = factory.createCodeCell({ cell });
-          expect(newCell.value.text).to.be('foo');
+          const cell = orig.toJSON();
+          const newCell = factory.createCodeCell({ cell });
+          expect(newCell.value.text).to.equal('foo');
         });
 
         it('should clone an existing raw cell', () => {
-          let orig = factory.createRawCell({});
+          const orig = factory.createRawCell({});
           orig.value.text = 'foo';
-          let cell = orig.toJSON();
-          let newCell = factory.createCodeCell({ cell });
-          expect(newCell.value.text).to.be('foo');
+          const cell = orig.toJSON();
+          const newCell = factory.createCodeCell({ cell });
+          expect(newCell.value.text).to.equal('foo');
         });
       });
 
       context('#createRawCell()', () => {
         it('should create a new raw cell', () => {
-          let cell = factory.createRawCell({});
-          expect(cell.type).to.be('raw');
+          const cell = factory.createRawCell({});
+          expect(cell.type).to.equal('raw');
         });
 
         it('should clone an existing raw cell', () => {
-          let orig = factory.createRawCell({});
+          const orig = factory.createRawCell({});
           orig.value.text = 'foo';
-          let cell = orig.toJSON();
-          let newCell = factory.createRawCell({ cell });
-          expect(newCell.value.text).to.be('foo');
+          const cell = orig.toJSON();
+          const newCell = factory.createRawCell({ cell });
+          expect(newCell.value.text).to.equal('foo');
         });
 
         it('should clone an existing code cell', () => {
-          let orig = factory.createCodeCell({});
+          const orig = factory.createCodeCell({});
           orig.value.text = 'foo';
-          let cell = orig.toJSON();
-          let newCell = factory.createRawCell({ cell });
-          expect(newCell.value.text).to.be('foo');
+          const cell = orig.toJSON();
+          const newCell = factory.createRawCell({ cell });
+          expect(newCell.value.text).to.equal('foo');
         });
       });
 
       describe('#createMarkdownCell()', () => {
         it('should create a new markdown cell', () => {
-          let cell = factory.createMarkdownCell({});
-          expect(cell.type).to.be('markdown');
+          const cell = factory.createMarkdownCell({});
+          expect(cell.type).to.equal('markdown');
         });
 
         it('should clone an existing markdown cell', () => {
-          let orig = factory.createMarkdownCell({});
+          const orig = factory.createMarkdownCell({});
           orig.value.text = 'foo';
-          let cell = orig.toJSON();
-          let newCell = factory.createMarkdownCell({ cell });
-          expect(newCell.value.text).to.be('foo');
+          const cell = orig.toJSON();
+          const newCell = factory.createMarkdownCell({ cell });
+          expect(newCell.value.text).to.equal('foo');
         });
 
         it('should clone an existing raw cell', () => {
-          let orig = factory.createRawCell({});
+          const orig = factory.createRawCell({});
           orig.value.text = 'foo';
-          let cell = orig.toJSON();
-          let newCell = factory.createMarkdownCell({ cell });
-          expect(newCell.value.text).to.be('foo');
+          const cell = orig.toJSON();
+          const newCell = factory.createMarkdownCell({ cell });
+          expect(newCell.value.text).to.equal('foo');
         });
       });
 
       describe('#modelDB', () => {
         it('should be undefined by default', () => {
-          expect(factory.modelDB).to.be(undefined);
+          expect(factory.modelDB).to.be.undefined;
         });
       });
 
       describe('#clone()', () => {
         it('should create a new content factory with a new IModelDB', () => {
-          let modelDB = new ModelDB();
-          let factory = new NotebookModel.ContentFactory({ modelDB });
-          expect(factory.modelDB).to.be(modelDB);
-          let newModelDB = new ModelDB();
-          let newFactory = factory.clone(newModelDB);
-          expect(newFactory.modelDB).to.be(newModelDB);
-          expect(newFactory.codeCellContentFactory).to.be(
+          const modelDB = new ModelDB();
+          const factory = new NotebookModel.ContentFactory({ modelDB });
+          expect(factory.modelDB).to.equal(modelDB);
+          const newModelDB = new ModelDB();
+          const newFactory = factory.clone(newModelDB);
+          expect(newFactory.modelDB).to.equal(newModelDB);
+          expect(newFactory.codeCellContentFactory).to.equal(
             factory.codeCellContentFactory
           );
         });
@@ -462,7 +464,7 @@ describe('@jupyterlab/notebook', () => {
 
     describe('.defaultContentFactory', () => {
       it('should be a ContentFactory', () => {
-        expect(NotebookModel.defaultContentFactory).to.be.a(
+        expect(NotebookModel.defaultContentFactory).to.be.an.instanceof(
           NotebookModel.ContentFactory
         );
       });

+ 39 - 37
tests/test-notebook/src/modelfactory.spec.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import expect = require('expect.js');
+import { expect } from 'chai';
 
 import { CodeCellModel } from '@jupyterlab/cells';
 
@@ -13,103 +13,105 @@ describe('@jupyterlab/notebook', () => {
   describe('NotebookModelFactory', () => {
     describe('#constructor', () => {
       it('should create a new notebook model factory', () => {
-        let factory = new NotebookModelFactory({});
-        expect(factory).to.be.a(NotebookModelFactory);
+        const factory = new NotebookModelFactory({});
+        expect(factory).to.be.an.instanceof(NotebookModelFactory);
       });
 
       it('should accept a code cell content factory', () => {
-        let codeCellContentFactory = new CodeCellModel.ContentFactory();
-        let factory = new NotebookModelFactory({ codeCellContentFactory });
-        expect(factory.contentFactory.codeCellContentFactory).to.be(
+        const codeCellContentFactory = new CodeCellModel.ContentFactory();
+        const factory = new NotebookModelFactory({ codeCellContentFactory });
+        expect(factory.contentFactory.codeCellContentFactory).to.equal(
           codeCellContentFactory
         );
       });
 
       it('should accept a notebook model content factory', () => {
-        let contentFactory = new NotebookModel.ContentFactory({});
-        let factory = new NotebookModelFactory({ contentFactory });
-        expect(factory.contentFactory).to.be(contentFactory);
+        const contentFactory = new NotebookModel.ContentFactory({});
+        const factory = new NotebookModelFactory({ contentFactory });
+        expect(factory.contentFactory).to.equal(contentFactory);
       });
     });
 
     describe('#contentFactory', () => {
       it('should be the content factory used by the model factory', () => {
-        let factory = new NotebookModelFactory({});
-        expect(factory.contentFactory).to.be.a(NotebookModel.ContentFactory);
+        const factory = new NotebookModelFactory({});
+        expect(factory.contentFactory).to.be.an.instanceof(
+          NotebookModel.ContentFactory
+        );
       });
     });
 
     describe('#name', () => {
       it('should get the name of the model factory', () => {
-        let factory = new NotebookModelFactory({});
-        expect(factory.name).to.be('notebook');
+        const factory = new NotebookModelFactory({});
+        expect(factory.name).to.equal('notebook');
       });
     });
 
     describe('#contentType', () => {
       it('should get the file type', () => {
-        let factory = new NotebookModelFactory({});
-        expect(factory.contentType).to.be('notebook');
+        const factory = new NotebookModelFactory({});
+        expect(factory.contentType).to.equal('notebook');
       });
     });
 
     describe('#fileFormat', () => {
       it('should get the file format', () => {
-        let factory = new NotebookModelFactory({});
-        expect(factory.fileFormat).to.be('json');
+        const factory = new NotebookModelFactory({});
+        expect(factory.fileFormat).to.equal('json');
       });
     });
 
     describe('#isDisposed', () => {
       it('should get whether the factory is disposed', () => {
-        let factory = new NotebookModelFactory({});
-        expect(factory.isDisposed).to.be(false);
+        const factory = new NotebookModelFactory({});
+        expect(factory.isDisposed).to.equal(false);
         factory.dispose();
-        expect(factory.isDisposed).to.be(true);
+        expect(factory.isDisposed).to.equal(true);
       });
     });
 
     describe('#dispose()', () => {
       it('should dispose of the model factory', () => {
-        let factory = new NotebookModelFactory({});
+        const factory = new NotebookModelFactory({});
         factory.dispose();
-        expect(factory.isDisposed).to.be(true);
+        expect(factory.isDisposed).to.equal(true);
       });
 
       it('should be safe to call multiple times', () => {
-        let factory = new NotebookModelFactory({});
+        const factory = new NotebookModelFactory({});
         factory.dispose();
         factory.dispose();
-        expect(factory.isDisposed).to.be(true);
+        expect(factory.isDisposed).to.equal(true);
       });
     });
 
     describe('#createNew()', () => {
       it('should create a new model for a given path', () => {
-        let factory = new NotebookModelFactory({});
-        let model = factory.createNew();
-        expect(model).to.be.a(NotebookModel);
+        const factory = new NotebookModelFactory({});
+        const model = factory.createNew();
+        expect(model).to.be.an.instanceof(NotebookModel);
       });
 
       it('should add an empty code cell by default', () => {
-        let factory = new NotebookModelFactory({});
-        let model = factory.createNew();
-        expect(model.cells.length).to.be(1);
-        expect(model.cells.get(0).type).to.be('code');
+        const factory = new NotebookModelFactory({});
+        const model = factory.createNew();
+        expect(model.cells.length).to.equal(1);
+        expect(model.cells.get(0).type).to.equal('code');
       });
 
       it('should accept a language preference', () => {
-        let factory = new NotebookModelFactory({});
-        let model = factory.createNew('foo');
-        expect(model.defaultKernelLanguage).to.be('foo');
+        const factory = new NotebookModelFactory({});
+        const model = factory.createNew('foo');
+        expect(model.defaultKernelLanguage).to.equal('foo');
       });
     });
 
     describe('#preferredLanguage()', () => {
       it('should always return an empty string', () => {
-        let factory = new NotebookModelFactory({});
-        expect(factory.preferredLanguage('')).to.be('');
-        expect(factory.preferredLanguage('.ipynb')).to.be('');
+        const factory = new NotebookModelFactory({});
+        expect(factory.preferredLanguage('')).to.equal('');
+        expect(factory.preferredLanguage('.ipynb')).to.equal('');
       });
     });
   });

+ 19 - 17
tests/test-notebook/src/panel.spec.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import expect = require('expect.js');
+import { expect } from 'chai';
 
 import { Context } from '@jupyterlab/docregistry';
 
@@ -33,13 +33,13 @@ describe('@jupyterlab/notebook', () => {
       it('should create a notebook panel', () => {
         const content = NBTestUtils.createNotebook();
         const panel = new NotebookPanel({ context, content });
-        expect(panel).to.be.a(NotebookPanel);
+        expect(panel).to.be.an.instanceof(NotebookPanel);
       });
 
       it('should change notebook to edit mode if we have a single empty code cell', async () => {
         const panel = NBTestUtils.createNotebookPanel(context);
         const model = panel.content.model;
-        expect(model).to.be(context.model);
+        expect(model).to.equal(context.model);
         await context.initialize(true);
         await context.ready;
         expect(panel.content.mode).to.equal('edit');
@@ -48,58 +48,60 @@ describe('@jupyterlab/notebook', () => {
 
     describe('#toolbar', () => {
       it('should be the toolbar used by the widget', () => {
-        let panel = NBTestUtils.createNotebookPanel(context);
-        expect(panel.toolbar).to.be.a(Toolbar);
+        const panel = NBTestUtils.createNotebookPanel(context);
+        expect(panel.toolbar).to.be.an.instanceof(Toolbar);
       });
     });
 
     describe('#content', () => {
       it('should be the notebook content widget', () => {
-        let panel = NBTestUtils.createNotebookPanel(context);
-        expect(panel.content).to.be.a(Notebook);
+        const panel = NBTestUtils.createNotebookPanel(context);
+        expect(panel.content).to.be.an.instanceof(Notebook);
       });
     });
 
     describe('#context', () => {
       it('should get the document context for the widget', () => {
-        let panel = NBTestUtils.createNotebookPanel(context);
-        expect(panel.context).to.be(context);
+        const panel = NBTestUtils.createNotebookPanel(context);
+        expect(panel.context).to.equal(context);
       });
     });
 
     describe('#dispose()', () => {
       it('should dispose of the resources used by the widget', () => {
-        let panel = NBTestUtils.createNotebookPanel(context);
+        const panel = NBTestUtils.createNotebookPanel(context);
         panel.dispose();
-        expect(panel.isDisposed).to.be(true);
+        expect(panel.isDisposed).to.equal(true);
       });
 
       it('should be safe to call more than once', () => {
-        let panel = NBTestUtils.createNotebookPanel(context);
+        const panel = NBTestUtils.createNotebookPanel(context);
         panel.dispose();
         panel.dispose();
-        expect(panel.isDisposed).to.be(true);
+        expect(panel.isDisposed).to.equal(true);
       });
     });
 
     describe('.ContentFactory', () => {
       describe('#constructor', () => {
         it('should create a new ContentFactory', () => {
-          let factory = new NotebookPanel.ContentFactory({
+          const factory = new NotebookPanel.ContentFactory({
             editorFactory: NBTestUtils.editorFactory
           });
-          expect(factory).to.be.a(NotebookPanel.ContentFactory);
+          expect(factory).to.be.an.instanceof(NotebookPanel.ContentFactory);
         });
       });
 
       describe('#NBTestUtils.createNotebook()', () => {
         it('should create a notebook widget', () => {
-          let options = {
+          const options = {
             contentFactory: contentFactory,
             rendermime: NBTestUtils.defaultRenderMime(),
             mimeTypeService: NBTestUtils.mimeTypeService
           };
-          expect(contentFactory.createNotebook(options)).to.be.a(Notebook);
+          expect(contentFactory.createNotebook(options)).to.be.an.instanceof(
+            Notebook
+          );
         });
       });
     });

+ 17 - 17
tests/test-notebook/src/tracker.spec.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import expect = require('expect.js');
+import { expect } from 'chai';
 
 import { Cell } from '@jupyterlab/cells';
 
@@ -41,56 +41,56 @@ describe('@jupyterlab/notebook', () => {
 
     describe('#constructor()', () => {
       it('should create a NotebookTracker', () => {
-        let tracker = new NotebookTracker({ namespace });
-        expect(tracker).to.be.a(NotebookTracker);
+        const tracker = new NotebookTracker({ namespace });
+        expect(tracker).to.be.an.instanceof(NotebookTracker);
       });
     });
 
     describe('#activeCell', () => {
       it('should be `null` if there is no tracked notebook panel', () => {
-        let tracker = new NotebookTracker({ namespace });
-        expect(tracker.activeCell).to.be(null);
+        const tracker = new NotebookTracker({ namespace });
+        expect(tracker.activeCell).to.be.null;
       });
 
       it('should be `null` if a tracked notebook has no active cell', () => {
-        let tracker = new NotebookTracker({ namespace });
-        let panel = NBTestUtils.createNotebookPanel(context);
+        const tracker = new NotebookTracker({ namespace });
+        const panel = NBTestUtils.createNotebookPanel(context);
         panel.content.model.cells.clear();
         tracker.add(panel);
-        expect(tracker.activeCell).to.be(null);
+        expect(tracker.activeCell).to.be.null;
       });
 
       it('should be the active cell if a tracked notebook has one', () => {
-        let tracker = new NotebookTracker({ namespace });
-        let panel = NBTestUtils.createNotebookPanel(context);
+        const tracker = new NotebookTracker({ namespace });
+        const panel = NBTestUtils.createNotebookPanel(context);
         tracker.add(panel);
         panel.content.model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
-        expect(tracker.activeCell).to.be.a(Cell);
+        expect(tracker.activeCell).to.be.an.instanceof(Cell);
         panel.dispose();
       });
     });
 
     describe('#activeCellChanged', () => {
       it('should emit a signal when the active cell changes', () => {
-        let tracker = new NotebookTracker({ namespace });
-        let panel = NBTestUtils.createNotebookPanel(context);
+        const tracker = new NotebookTracker({ namespace });
+        const panel = NBTestUtils.createNotebookPanel(context);
         let count = 0;
         tracker.activeCellChanged.connect(() => {
           count++;
         });
         panel.content.model.fromJSON(NBTestUtils.DEFAULT_CONTENT);
         tracker.add(panel);
-        expect(count).to.be(1);
+        expect(count).to.equal(1);
         panel.content.activeCellIndex = 1;
-        expect(count).to.be(2);
+        expect(count).to.equal(2);
         panel.dispose();
       });
     });
 
     describe('#onCurrentChanged()', () => {
       it('should be called when the active cell changes', () => {
-        let tracker = new TestTracker({ namespace });
-        let panel = NBTestUtils.createNotebookPanel(context);
+        const tracker = new TestTracker({ namespace });
+        const panel = NBTestUtils.createNotebookPanel(context);
         tracker.add(panel);
         expect(tracker.methods).to.contain('onCurrentChanged');
       });

File diff suppressed because it is too large
+ 230 - 228
tests/test-notebook/src/widget.spec.ts


+ 27 - 27
tests/test-notebook/src/widgetfactory.spec.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import expect = require('expect.js');
+import { expect } from 'chai';
 
 import { toArray } from '@phosphor/algorithm';
 
@@ -44,74 +44,74 @@ describe('@jupyterlab/notebook', () => {
 
     describe('#constructor()', () => {
       it('should create a notebook widget factory', () => {
-        let factory = createFactory();
-        expect(factory).to.be.a(NotebookWidgetFactory);
+        const factory = createFactory();
+        expect(factory).to.be.an.instanceof(NotebookWidgetFactory);
       });
     });
 
     describe('#isDisposed', () => {
       it('should get whether the factory has been disposed', () => {
-        let factory = createFactory();
-        expect(factory.isDisposed).to.be(false);
+        const factory = createFactory();
+        expect(factory.isDisposed).to.equal(false);
         factory.dispose();
-        expect(factory.isDisposed).to.be(true);
+        expect(factory.isDisposed).to.equal(true);
       });
     });
 
     describe('#dispose()', () => {
       it('should dispose of the resources held by the factory', () => {
-        let factory = createFactory();
+        const factory = createFactory();
         factory.dispose();
-        expect(factory.isDisposed).to.be(true);
+        expect(factory.isDisposed).to.equal(true);
       });
 
       it('should be safe to call multiple times', () => {
-        let factory = createFactory();
+        const factory = createFactory();
         factory.dispose();
         factory.dispose();
-        expect(factory.isDisposed).to.be(true);
+        expect(factory.isDisposed).to.equal(true);
       });
     });
 
     describe('#editorConfig', () => {
       it('should be the editor config passed into the constructor', () => {
-        let factory = createFactory();
-        expect(factory.editorConfig).to.be(NBTestUtils.defaultEditorConfig);
+        const factory = createFactory();
+        expect(factory.editorConfig).to.equal(NBTestUtils.defaultEditorConfig);
       });
 
       it('should be settable', () => {
-        let factory = createFactory();
-        let newConfig = { ...NBTestUtils.defaultEditorConfig };
+        const factory = createFactory();
+        const newConfig = { ...NBTestUtils.defaultEditorConfig };
         factory.editorConfig = newConfig;
-        expect(factory.editorConfig).to.be(newConfig);
+        expect(factory.editorConfig).to.equal(newConfig);
       });
     });
 
     describe('#createNew()', () => {
       it('should create a new `NotebookPanel` widget', () => {
-        let factory = createFactory();
-        let panel = factory.createNew(context);
-        expect(panel).to.be.a(NotebookPanel);
+        const factory = createFactory();
+        const panel = factory.createNew(context);
+        expect(panel).to.be.an.instanceof(NotebookPanel);
       });
 
       it('should create a clone of the rendermime', () => {
-        let factory = createFactory();
-        let panel = factory.createNew(context);
-        expect(panel.rendermime).to.not.be(rendermime);
+        const factory = createFactory();
+        const panel = factory.createNew(context);
+        expect(panel.rendermime).to.not.equal(rendermime);
       });
 
       it('should pass the editor config to the notebook', () => {
-        let factory = createFactory();
-        let panel = factory.createNew(context);
-        expect(panel.content.editorConfig).to.be(
+        const factory = createFactory();
+        const panel = factory.createNew(context);
+        expect(panel.content.editorConfig).to.equal(
           NBTestUtils.defaultEditorConfig
         );
       });
 
       it('should populate the default toolbar items', () => {
-        let factory = createFactory();
-        let panel = factory.createNew(context);
-        let items = toArray(panel.toolbar.names());
+        const factory = createFactory();
+        const panel = factory.createNew(context);
+        const items = toArray(panel.toolbar.names());
         expect(items).to.contain('save');
         expect(items).to.contain('restart');
         expect(items).to.contain('kernelStatus');

Some files were not shown because too many files changed in this diff