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 return false for a value that does not exist', () => {
const db = new ModelDB();
expect(db.has('value')).to.equal(false);
});
});
it('should create an ObservableMap`', () => {
const db = new ModelDB();
const map = db.createMap('map');
expect(map instanceof ObservableJSON).to.equal(true);
});
it('should set a value at a path', () => {
const db = new ModelDB();
const value = db.createValue('value');
db.setValue('value', 'set');
expect(value.get()).to.equal('set');
});
});
it('should be stackable', () => {
const db = new ModelDB();
const view = db.view('one');
const viewView = view.view('two');
expect(view.basePath).to.equal('one');
expect(viewView.basePath).to.equal('two');
viewView.createString('str');
expect(viewView.get('str')).to.equal(view.get('two.str'));
expect(viewView.get('str')).to.equal(db.get('one.two.str'));
});
});
it('should create a new content factory with a new IModelDB', () => {
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
);
});
});
it('should accept a baseDB', () => {
const base = new ModelDB();
const db = new ModelDB({ baseDB: base });
expect(db instanceof ModelDB).to.equal(true);
});
});
it('should be able to retrieve that map using `get`', () => {
const db = new ModelDB();
const map = db.createMap('map');
expect(db.get('map')).to.equal(map);
});
});
it('should return false for an in-memory database', () => {
const db = new ModelDB();
expect(db.isCollaborative).to.equal(false);
});
});
it('should set the baseDB path on the view', () => {
const db = new ModelDB();
const view = db.view('base');
expect(view.basePath).to.equal('base');
});
constructor(options?: Model.IOptions) {
options = options || {};
if (options.modelDB) {
this.modelDB = options.modelDB;
} else {
this.modelDB = new ModelDB();
}
let value = this.modelDB.createString('value');
value.text = value.text || options.value || '';
let mimeType = this.modelDB.createValue('mimeType');
mimeType.set(options.mimeType || 'text/plain');
mimeType.changed.connect(this._onMimeTypeChanged, this);
this.modelDB.createMap('selections');
}