|
@@ -66,33 +66,14 @@ class LogCell extends BaseCellWidget {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-describe('jupyter-js-notebook', () => {
|
|
|
|
|
|
+describe('notebook/cells', () => {
|
|
|
|
|
|
describe('BaseCellWidget', () => {
|
|
describe('BaseCellWidget', () => {
|
|
|
|
|
|
- describe('.createCellEditor()', () => {
|
|
|
|
-
|
|
|
|
- it('should create a cell editor widget', () => {
|
|
|
|
- let editor = BaseCellWidget.createCellEditor(new CellModel());
|
|
|
|
- expect(editor).to.be.a(CellEditorWidget);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- describe('.createInputArea()', () => {
|
|
|
|
-
|
|
|
|
- it('should create an input area widget', () => {
|
|
|
|
- let editor = BaseCellWidget.createCellEditor(new CellModel());
|
|
|
|
- let input = BaseCellWidget.createInputArea(editor);
|
|
|
|
- expect(input).to.be.a(InputAreaWidget);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
describe('#constructor()', () => {
|
|
describe('#constructor()', () => {
|
|
|
|
|
|
it('should create a base cell widget', () => {
|
|
it('should create a base cell widget', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(widget).to.be.a(BaseCellWidget);
|
|
expect(widget).to.be.a(BaseCellWidget);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -102,7 +83,9 @@ describe('jupyter-js-notebook', () => {
|
|
|
|
|
|
it('should be settable', () => {
|
|
it('should be settable', () => {
|
|
let model = new CellModel();
|
|
let model = new CellModel();
|
|
- let widget = new BaseCellWidget(model);
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
|
|
+ expect(widget.model).to.be(null);
|
|
|
|
+ widget.model = model;
|
|
expect(widget.model).to.be(model);
|
|
expect(widget.model).to.be(model);
|
|
widget.model = new CellModel();
|
|
widget.model = new CellModel();
|
|
expect(widget.model).not.to.be(model);
|
|
expect(widget.model).not.to.be(model);
|
|
@@ -113,12 +96,12 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#editor', () => {
|
|
describe('#editor', () => {
|
|
|
|
|
|
it('should be a cell editor widget', () => {
|
|
it('should be a cell editor widget', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(widget.editor).to.be.a(CellEditorWidget);
|
|
expect(widget.editor).to.be.a(CellEditorWidget);
|
|
});
|
|
});
|
|
|
|
|
|
it('should be read-only', () => {
|
|
it('should be read-only', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(() => { widget.editor = null; }).to.throwError();
|
|
expect(() => { widget.editor = null; }).to.throwError();
|
|
});
|
|
});
|
|
|
|
|
|
@@ -127,23 +110,23 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#mimetype', () => {
|
|
describe('#mimetype', () => {
|
|
|
|
|
|
it('should be a string', () => {
|
|
it('should be a string', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(typeof widget.mimetype).to.be('string');
|
|
expect(typeof widget.mimetype).to.be('string');
|
|
});
|
|
});
|
|
|
|
|
|
it('should default to text/plain', () => {
|
|
it('should default to text/plain', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(widget.mimetype).to.be('text/plain');
|
|
expect(widget.mimetype).to.be('text/plain');
|
|
});
|
|
});
|
|
|
|
|
|
it('should supporting being set to other types', () => {
|
|
it('should supporting being set to other types', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
widget.mimetype = 'test/test';
|
|
widget.mimetype = 'test/test';
|
|
expect(widget.mimetype).to.be('test/test');
|
|
expect(widget.mimetype).to.be('test/test');
|
|
});
|
|
});
|
|
|
|
|
|
it('should not allow being set to empty or null strings', () => {
|
|
it('should not allow being set to empty or null strings', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
widget.mimetype = null;
|
|
widget.mimetype = null;
|
|
expect(widget.mimetype).to.be('text/plain');
|
|
expect(widget.mimetype).to.be('text/plain');
|
|
widget.mimetype = '';
|
|
widget.mimetype = '';
|
|
@@ -155,17 +138,17 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#readOnly', () => {
|
|
describe('#readOnly', () => {
|
|
|
|
|
|
it('should be a boolean', () => {
|
|
it('should be a boolean', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(typeof widget.readOnly).to.be('boolean');
|
|
expect(typeof widget.readOnly).to.be('boolean');
|
|
});
|
|
});
|
|
|
|
|
|
it('should default to false', () => {
|
|
it('should default to false', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(widget.readOnly).to.be(false);
|
|
expect(widget.readOnly).to.be(false);
|
|
});
|
|
});
|
|
|
|
|
|
it('should be settable', () => {
|
|
it('should be settable', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
widget.readOnly = true;
|
|
widget.readOnly = true;
|
|
expect(widget.readOnly).to.be(true);
|
|
expect(widget.readOnly).to.be(true);
|
|
});
|
|
});
|
|
@@ -175,17 +158,18 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#trusted', () => {
|
|
describe('#trusted', () => {
|
|
|
|
|
|
it('should be a boolean', () => {
|
|
it('should be a boolean', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(typeof widget.trusted).to.be('boolean');
|
|
expect(typeof widget.trusted).to.be('boolean');
|
|
});
|
|
});
|
|
|
|
|
|
it('should default to false', () => {
|
|
it('should default to false', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(widget.trusted).to.be(false);
|
|
expect(widget.trusted).to.be(false);
|
|
});
|
|
});
|
|
|
|
|
|
it('should be settable', () => {
|
|
it('should be settable', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
|
|
+ widget.model = new CellModel();
|
|
widget.trusted = true;
|
|
widget.trusted = true;
|
|
expect(widget.trusted).to.be(true);
|
|
expect(widget.trusted).to.be(true);
|
|
});
|
|
});
|
|
@@ -195,7 +179,7 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#focus()', () => {
|
|
describe('#focus()', () => {
|
|
|
|
|
|
it('should focus the cell editor', () => {
|
|
it('should focus the cell editor', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
widget.attach(document.body);
|
|
widget.attach(document.body);
|
|
expect(widget.editor.editor.hasFocus()).to.be(false);
|
|
expect(widget.editor.editor.hasFocus()).to.be(false);
|
|
widget.focus();
|
|
widget.focus();
|
|
@@ -208,7 +192,7 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#setPrompt()', () => {
|
|
describe('#setPrompt()', () => {
|
|
|
|
|
|
it('should not throw an error (full test in input area)', () => {
|
|
it('should not throw an error (full test in input area)', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
expect(() => { widget.setPrompt(void 0); }).to.not.throwError();
|
|
expect(() => { widget.setPrompt(void 0); }).to.not.throwError();
|
|
expect(() => { widget.setPrompt(null); }).to.not.throwError();
|
|
expect(() => { widget.setPrompt(null); }).to.not.throwError();
|
|
expect(() => { widget.setPrompt(''); }).to.not.throwError();
|
|
expect(() => { widget.setPrompt(''); }).to.not.throwError();
|
|
@@ -221,7 +205,7 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#toggleInput()', () => {
|
|
describe('#toggleInput()', () => {
|
|
|
|
|
|
it('should toggle whether the input is shown', () => {
|
|
it('should toggle whether the input is shown', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
let input = widget.node.getElementsByClassName(INPUT_CLASS)[0];
|
|
let input = widget.node.getElementsByClassName(INPUT_CLASS)[0];
|
|
widget.attach(document.body);
|
|
widget.attach(document.body);
|
|
expect(window.getComputedStyle(input).display).to.not.be('none');
|
|
expect(window.getComputedStyle(input).display).to.not.be('none');
|
|
@@ -236,13 +220,13 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#dispose()', () => {
|
|
describe('#dispose()', () => {
|
|
|
|
|
|
it('should dispose of the resources held by the widget', () => {
|
|
it('should dispose of the resources held by the widget', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
widget.dispose();
|
|
widget.dispose();
|
|
expect(widget.isDisposed).to.be(true);
|
|
expect(widget.isDisposed).to.be(true);
|
|
});
|
|
});
|
|
|
|
|
|
it('should be safe to call multiple times', () => {
|
|
it('should be safe to call multiple times', () => {
|
|
- let widget = new BaseCellWidget(new CellModel());
|
|
|
|
|
|
+ let widget = new BaseCellWidget();
|
|
widget.dispose();
|
|
widget.dispose();
|
|
widget.dispose();
|
|
widget.dispose();
|
|
expect(widget.isDisposed).to.be(true);
|
|
expect(widget.isDisposed).to.be(true);
|
|
@@ -253,7 +237,7 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#onAfterAttach()', () => {
|
|
describe('#onAfterAttach()', () => {
|
|
|
|
|
|
it('should run when widget is attached', () => {
|
|
it('should run when widget is attached', () => {
|
|
- let widget = new LogCell(new CellModel());
|
|
|
|
|
|
+ let widget = new LogCell();
|
|
expect(widget.methods).to.not.contain('onAfterAttach');
|
|
expect(widget.methods).to.not.contain('onAfterAttach');
|
|
widget.attach(document.body);
|
|
widget.attach(document.body);
|
|
expect(widget.methods).to.contain('onAfterAttach');
|
|
expect(widget.methods).to.contain('onAfterAttach');
|
|
@@ -265,7 +249,7 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#onUpdateRequest()', () => {
|
|
describe('#onUpdateRequest()', () => {
|
|
|
|
|
|
it('should update the widget', () => {
|
|
it('should update the widget', () => {
|
|
- let widget = new LogCell(new CellModel());
|
|
|
|
|
|
+ let widget = new LogCell();
|
|
expect(widget.methods).to.not.contain('onUpdateRequest');
|
|
expect(widget.methods).to.not.contain('onUpdateRequest');
|
|
sendMessage(widget, Widget.MsgUpdateRequest);
|
|
sendMessage(widget, Widget.MsgUpdateRequest);
|
|
expect(widget.methods).to.contain('onUpdateRequest');
|
|
expect(widget.methods).to.contain('onUpdateRequest');
|
|
@@ -276,7 +260,8 @@ describe('jupyter-js-notebook', () => {
|
|
describe('#onMetadataChanged()', () => {
|
|
describe('#onMetadataChanged()', () => {
|
|
|
|
|
|
it('should fire when model metadata changes', () => {
|
|
it('should fire when model metadata changes', () => {
|
|
- let widget = new LogCell(new CellModel());
|
|
|
|
|
|
+ let widget = new LogCell();
|
|
|
|
+ widget.model = new CellModel();
|
|
expect(widget.methods).to.not.contain('onMetadataChanged');
|
|
expect(widget.methods).to.not.contain('onMetadataChanged');
|
|
widget.model.metadataChanged.emit({
|
|
widget.model.metadataChanged.emit({
|
|
name: 'foo',
|
|
name: 'foo',
|
|
@@ -292,15 +277,6 @@ describe('jupyter-js-notebook', () => {
|
|
|
|
|
|
describe('CodeCellWidget', () => {
|
|
describe('CodeCellWidget', () => {
|
|
|
|
|
|
- describe('.createOutput()', () => {
|
|
|
|
-
|
|
|
|
- it('should create an input area widget', () => {
|
|
|
|
- let editor = CodeCellWidget.createInputArea(new CodeCellModel());
|
|
|
|
- expect(editor).to.be.a(CellEditorWidget);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
});
|
|
});
|
|
|
|
|
|
});
|
|
});
|