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 accept a baseDB', () => {
const base = new ModelDB();
const db = new ModelDB({ baseDB: base });
expect(db instanceof ModelDB).to.equal(true);
});
});
it('should dispose of the resources used by the model', () => {
const db = new ModelDB();
const str = db.createString('str');
const view = db.view('base');
const str2 = view.createString('str');
expect(db.isDisposed).to.equal(false);
expect(str.isDisposed).to.equal(false);
expect(view.isDisposed).to.equal(false);
expect(str2.isDisposed).to.equal(false);
db.dispose();
expect(db.isDisposed).to.equal(true);
expect(str.isDisposed).to.equal(true);
expect(view.isDisposed).to.equal(true);
expect(str2.isDisposed).to.equal(true);
});
it('should create an ObservableValue`', () => {
const db = new ModelDB();
const value = db.createValue('value');
expect(value instanceof ObservableValue).to.equal(true);
});
it('should be able to retrieve that value using `get`', () => {
const db = new ModelDB();
const value = db.createString('value');
expect(db.get('value')).to.equal(value);
});
});
it('should be safe to call more than once', () => {
const db = new ModelDB();
expect(db.isDisposed).to.equal(false);
db.dispose();
expect(db.isDisposed).to.equal(true);
});
});
it('should get a value that exists at a path', () => {
const db = new ModelDB();
const value = db.createValue('value');
const value2 = db.get('value');
expect(value2).to.equal(value);
});
it('should return false for a value that does not exist', () => {
const db = new ModelDB();
expect(db.has('value')).to.equal(false);
});
});
it('should return a view onto the base ModelDB', () => {
const db = new ModelDB();
const view = db.view('base');
db.createString('base.str1');
expect(db.get('base.str1')).to.equal(view.get('str1'));
view.createString('str2');
expect(db.get('base.str2')).to.equal(view.get('str2'));
});
it('should return true if a value exists at a path', () => {
const db = new ModelDB();
db.createValue('value');
expect(db.has('value')).to.equal(true);
});
it('should create an ObservableUndoableList`', () => {
const db = new ModelDB();
const str = db.createList('vec');
expect(str instanceof ObservableUndoableList).to.equal(true);
});