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 not trigger a changed signal if not actually removed', () => {
const value = new ObservableMap();
value.set('one', 1);
value.set('three', 3);
let called = false;
value.changed.connect((sender, args) => {
expect(sender).to.equal(value);
expect(args.type).to.equal('remove');
expect(args.key).to.equal('two');
expect(args.oldValue).to.equal(2);
expect(args.newValue).to.be.undefined;
called = true;
});
// 'two' is not in the map
value.delete('two');
expect(called).to.equal(false);
it('should return `Map`', () => {
const value = new ObservableMap();
expect(value.type).to.equal('Map');
});
});
it('should return a list of the keys in the map', () => {
const value = new ObservableMap();
value.set('one', 1);
value.set('two', 2);
value.set('three', 3);
const keys = value.keys();
expect(keys).to.deep.equal(['one', 'two', 'three']);
});
});
it('should return the number of entries in the map', () => {
const value = new ObservableMap();
value.set('one', 1);
value.set('two', 2);
expect(value.size).to.equal(2);
});
});
it('should test whether the map is disposed', () => {
const value = new ObservableMap();
expect(value.isDisposed).to.equal(false);
value.dispose();
expect(value.isDisposed).to.equal(true);
});
});
it('should return the old value for that key', () => {
const value = new ObservableMap();
value.set('one', 1);
const x = value.set('one', 1.01);
expect(x).to.equal(1);
});
it('should return undefined if the key does not exist', () => {
const value = new ObservableMap();
value.set('one', 1);
expect(value.get('two')).to.be.undefined;
});
});
constructor(options: NotebookHandler.IOptions) {
this.debuggerService = options.debuggerService;
this.notebookPanel = options.widget;
this._cellMap = new ObservableMap();
const notebook = this.notebookPanel.content;
notebook.widgets.forEach(cell => this.addEditorHandler(cell));
notebook.activeCellChanged.connect(this.onActiveCellChanged, this);
}
constructor(modelDB: IModelDB, factory: NotebookModel.IContentFactory) {
this._cellOrder = modelDB.createList('cellOrder');
this._cellMap = new ObservableMap();
this._cellOrder.changed.connect(this._onOrderChanged, this);
}
static model_module = MODULE_NAME;
static model_module_version = MODULE_VERSION;
static view_name: string = null;
static view_module: string = null;
static view_module_version = MODULE_VERSION;
private _palette: ICommandPalette;
static palette: ICommandPalette;
}
/**
* A namespace for private data
*/
namespace Private {
export const customItems = new ObservableMap();
}