Explorar el Código

Fix test compilation errors.

Jason Grout hace 6 años
padre
commit
4f79ecde52

+ 2 - 2
packages/notebook/src/notebooktools.ts

@@ -153,7 +153,7 @@ export class NotebookTools extends Widget implements INotebookTools {
     let section: RankedPanel<NotebookTools.Tool>;
     if (options.section === 'advanced') {
       section = this._advancedTools;
-    } else if (options.section === 'common') {
+    } else {
       section = this._commonTools;
     }
 
@@ -260,7 +260,7 @@ export namespace NotebookTools {
     /**
      * The section to which the tool should be added.
      */
-    section: 'common' | 'advanced';
+    section?: 'common' | 'advanced';
 
     /**
      * The rank order of the widget among its siblings.

+ 0 - 60
tests/test-codeeditor/src/jsoneditor.spec.ts

@@ -69,33 +69,6 @@ describe('codeeditor', () => {
       });
     });
 
-    describe('#collapsible', () => {
-      it('should default to false', () => {
-        expect(editor.collapsible).to.be.false;
-      });
-
-      it('should be settable in the constructor', () => {
-        let newEditor = new JSONEditor({ editorFactory, collapsible: true });
-        expect(newEditor.collapsible).to.be.true;
-      });
-    });
-
-    describe('#editorTitle', () => {
-      it('should default to empty string', () => {
-        expect(editor.editorTitle).to.equal('');
-      });
-
-      it('should be settable in the constructor', () => {
-        let newEditor = new JSONEditor({ editorFactory, title: 'foo' });
-        expect(newEditor.editorTitle).to.equal('foo');
-      });
-
-      it('should be settable', () => {
-        editor.editorTitle = 'foo';
-        expect(editor.editorTitle).to.equal('foo');
-      });
-    });
-
     describe('#headerNode', () => {
       it('should be the header node used by the editor', () => {
         expect(Array.from(editor.headerNode.classList)).to.contain(
@@ -104,22 +77,6 @@ describe('codeeditor', () => {
       });
     });
 
-    describe('#titleNode', () => {
-      it('should be the title node used by the editor', () => {
-        expect(Array.from(editor.titleNode.classList)).to.contain(
-          'jp-JSONEditor-title'
-        );
-      });
-    });
-
-    describe('#collapserNode', () => {
-      it('should be the collapser node used by the editor', () => {
-        expect(Array.from(editor.collapserNode.classList)).to.contain(
-          'jp-JSONEditor-collapser'
-        );
-      });
-    });
-
     describe('#editorHostNode', () => {
       it('should be the editor host node used by the editor', () => {
         expect(Array.from(editor.editorHostNode.classList)).to.contain(
@@ -340,23 +297,6 @@ describe('codeeditor', () => {
           let expected = '{\n    "foo": 2,\n    "bar": 3\n}';
           expect(editor.model.value.text).to.equal(expected);
         });
-
-        it('should collapse the editor', () => {
-          editor.dispose();
-          editor = new LogEditor({ editorFactory, collapsible: true });
-          Widget.attach(editor, document.body);
-          simulate(editor.titleNode, 'click');
-          expect(Array.from(editor.editorHostNode.classList)).to.contain(
-            'jp-mod-collapsed'
-          );
-        });
-
-        it('should have no effect if the editor is not collapsible', () => {
-          simulate(editor.titleNode, 'click');
-          expect(Array.from(editor.editorHostNode.classList)).to.not.contain(
-            'jp-mod-collapsed'
-          );
-        });
       });
     });
 

+ 0 - 65
tests/test-notebook/src/actions.spec.ts

@@ -1312,71 +1312,6 @@ describe('@jupyterlab/notebook', () => {
       });
     });
 
-    describe('#persistViewState()', () => {
-      it('input hidden, output hidden and scrolled', () => {
-        for (const cell of widget.widgets) {
-          cell.inputHidden = true;
-          if (cell instanceof CodeCell) {
-            cell.outputHidden = true;
-            cell.outputsScrolled = true;
-          }
-        }
-        NotebookActions.persistViewState(widget);
-        for (const cell of widget.widgets) {
-          if (cell instanceof CodeCell) {
-            expect(cell.model.metadata.get('collapsed')).to.equal(true);
-            expect(cell.model.metadata.get('scrolled')).to.equal(true);
-            expect(cell.model.metadata.get('jupyter')).to.deep.equal({
-              source_hidden: true,
-              outputs_hidden: true
-            });
-          } else {
-            expect(cell.model.metadata.get('jupyter')).to.deep.equal({
-              source_hidden: true
-            });
-          }
-        }
-      });
-
-      it('input hidden, output hidden and not scrolled', () => {
-        for (const cell of widget.widgets) {
-          cell.inputHidden = false;
-          if (cell instanceof CodeCell) {
-            cell.outputHidden = false;
-            cell.outputsScrolled = false;
-          }
-        }
-        NotebookActions.persistViewState(widget);
-        for (const cell of widget.widgets) {
-          if (cell instanceof CodeCell) {
-            expect(cell.model.metadata.has('collapsed')).to.equal(false);
-            expect(cell.model.metadata.has('scrolled')).to.equal(false);
-          }
-          expect(cell.model.metadata.has('jupyter')).to.equal(false);
-        }
-      });
-
-      it('input hidden, output shown and not scrolled', () => {
-        for (const cell of widget.widgets) {
-          cell.inputHidden = true;
-          if (cell instanceof CodeCell) {
-            cell.outputHidden = false;
-            cell.outputsScrolled = false;
-          }
-        }
-        NotebookActions.persistViewState(widget);
-        for (const cell of widget.widgets) {
-          if (cell instanceof CodeCell) {
-            expect(cell.model.metadata.has('collapsed')).to.equal(false);
-            expect(cell.model.metadata.has('scrolled')).to.equal(false);
-          }
-          expect(cell.model.metadata.get('jupyter')).to.deep.equal({
-            source_hidden: true
-          });
-        }
-      });
-    });
-
     describe('#setMarkdownHeader()', () => {
       it('should set the markdown header level of selected cells', () => {
         const next = widget.widgets[1];

+ 10 - 10
tests/test-notebook/src/notebooktools.spec.ts

@@ -41,9 +41,9 @@ class LogTool extends NotebookTools.Tool {
     this.methods.push('onSelectionChanged');
   }
 
-  protected onMetadataChanged(msg: ObservableJSON.ChangeMessage): void {
-    super.onMetadataChanged(msg);
-    this.methods.push('onMetadataChanged');
+  protected onCellMetadataChanged(msg: ObservableJSON.ChangeMessage): void {
+    super.onCellMetadataChanged(msg);
+    this.methods.push('onCellMetadataChanged');
   }
 }
 
@@ -71,9 +71,9 @@ class LogKeySelector extends NotebookTools.KeySelector {
     this.methods.push('onActiveCellChanged');
   }
 
-  protected onMetadataChanged(message: ObservableJSON.ChangeMessage): void {
-    super.onMetadataChanged(message);
-    this.methods.push('onMetadataChanged');
+  protected onCellMetadataChanged(message: ObservableJSON.ChangeMessage): void {
+    super.onCellMetadataChanged(message);
+    this.methods.push('onCellMetadataChanged');
   }
 
   protected onValueChanged(): void {
@@ -203,7 +203,7 @@ describe('@jupyterlab/notebook', () => {
         });
       });
 
-      describe('#onMetadataChanged()', () => {
+      describe('#onCellMetadataChanged()', () => {
         it('should be called when the metadata changes', () => {
           const tool = new LogTool({});
           notebookTools.addItem({ tool });
@@ -211,7 +211,7 @@ describe('@jupyterlab/notebook', () => {
           const metadata = notebookTools.activeCell.model.metadata;
           metadata.set('foo', 1);
           metadata.set('foo', 2);
-          expect(tool.methods).to.contain('onMetadataChanged');
+          expect(tool.methods).to.contain('onCellMetadataChanged');
         });
       });
     });
@@ -381,11 +381,11 @@ describe('@jupyterlab/notebook', () => {
         });
       });
 
-      describe('#onMetadataChanged()', () => {
+      describe('#onCellMetadataChanged()', () => {
         it('should update the select value', () => {
           const metadata = notebookTools.activeCell.model.metadata;
           metadata.set('foo', 1);
-          expect(tool.methods).to.contain('onMetadataChanged');
+          expect(tool.methods).to.contain('onCellMetadataChanged');
           expect(tool.selectNode.value).to.equal('1');
         });
       });

+ 5 - 2
tests/test-observables/src/observablejson.spec.ts

@@ -41,7 +41,7 @@ describe('@jupyterlab/observables', () => {
   describe('ObservableJSON.ChangeMessage', () => {
     describe('#constructor()', () => {
       it('should create a new message', () => {
-        const message = new ObservableJSON.ChangeMessage({
+        const message = new ObservableJSON.ChangeMessage('jsonvalue-changed', {
           key: 'foo',
           type: 'add',
           oldValue: 1,
@@ -59,7 +59,10 @@ describe('@jupyterlab/observables', () => {
           oldValue: 'ho',
           newValue: 'hi'
         };
-        const message = new ObservableJSON.ChangeMessage(args);
+        const message = new ObservableJSON.ChangeMessage(
+          'jsonvalue-changed',
+          args
+        );
         expect(message.args).to.equal(args);
       });
     });