Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should save the collapse state to the model', () => {
const model = new CellModel({});
const widget = new Cell({ model, contentFactory }).initializeState();
expect(widget.inputHidden).toEqual(false);
widget.inputHidden = true;
widget.saveCollapseState();
expect(model.metadata.get('jupyter')).toEqual({
source_hidden: true
});
widget.inputHidden = false;
widget.saveCollapseState();
// Default values are not saved explicitly
expect(model.metadata.get('jupyter')).toEqual(undefined);
});
});
it('should be true after model is disposed', () => {
let model = new CellModel({});
model.dispose();
expect(model.isDisposed).to.be(true);
});
it('should be the model used by the widget', () => {
let model = new CellModel({});
let widget = new BaseCellWidget({ model, contentFactory });
expect(widget.model).to.be(model);
});
it('should be false by default', () => {
const model = new CellModel({});
expect(model.isDisposed).to.equal(false);
});
it('should default to an empty string', () => {
const model = new CellModel({});
expect(model.value.text).to.be.empty;
});
it('should signal when model content has changed', () => {
const model = new CellModel({});
let called = false;
model.contentChanged.connect(() => {
called = true;
});
expect(called).to.equal(false);
model.value.text = 'foo';
expect(called).to.equal(true);
});
});
it('should accept a base cell argument', () => {
const cell: nbformat.IRawCell = {
cell_type: 'raw',
source: 'foo',
metadata: { trusted: false }
};
const model = new CellModel({ cell });
expect(model).to.be.an.instanceof(CellModel);
expect(model.value.text).to.equal(cell.source);
});
it('should default to an empty string', () => {
let model = new CellModel({});
expect(model.value.text).to.be.empty();
});
it('should be settable', () => {
const model = new CellModel({});
expect(model.value.text).to.be.empty;
model.value.text = 'foo';
expect(model.value.text).to.equal('foo');
});
});
constructor() {
super({
model: new CellModel({}),
contentFactory: NBTestUtils.createBaseCellFactory()
});
}