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 yield a list of valid session models', async () => {
const response = await Session.listRunning();
const running = toArray(response);
expect(running.length).to.greaterThan(0);
});
it('should list all directories whatever the filter', async () => {
let filteredModel = new FilterFileBrowserModel({
iconRegistry,
manager,
filter: (model: Contents.IModel) => false
});
await filteredModel.cd();
let model = new FileBrowserModel({ iconRegistry, manager });
await model.cd();
const filteredItems = toArray(filteredModel.items());
const items = toArray(model.items());
const folders = items.filter(item => item.type === 'directory');
expect(filteredItems.length).equal(folders.length);
});
it('should list all elements if no filter is defined', async () => {
let filteredModel = new FilterFileBrowserModel({
iconRegistry,
manager
});
await filteredModel.cd();
let model = new FileBrowserModel({ iconRegistry, manager });
await model.cd();
const filteredItems = toArray(filteredModel.items());
const items = toArray(model.items());
expect(filteredItems.length).equal(items.length);
});
it('should update the running session models', async () => {
let model: TerminalSession.IModel;
const before = toArray(manager.running()).length;
session = await TerminalSession.startNew();
model = session.model;
await manager.refreshRunning();
const running = toArray(manager.running());
expect(running.length).to.equal(before + 1);
let found = false;
running.map(m => {
if (m.name === model.name) {
found = true;
}
});
expect(found).to.equal(true);
});
});
it('should update the running kernels', async () => {
await manager.refreshRunning();
expect(toArray(manager.running()).length).to.be.greaterThan(0);
});
});
it('should populate the customized toolbar items', () => {
const toolbarFactory = () => [
{ name: 'foo', widget: new ToolbarButton() },
{ name: 'bar', widget: new ToolbarButton() }
];
const factory = createFactory(toolbarFactory);
const panel = factory.createNew(context);
const panel2 = factory.createNew(context);
expect(toArray(panel.toolbar.names())).to.deep.equal(['foo', 'bar']);
expect(toArray(panel2.toolbar.names())).to.deep.equal(['foo', 'bar']);
expect(toArray(panel.toolbar.children()).length).to.equal(2);
expect(toArray(panel2.toolbar.children()).length).to.equal(2);
});
manager.runningChanged.connect((sender, args) => {
expect(sender).to.equal(manager);
expect(toArray(args).length).to.be.greaterThan(0);
called = true;
});
await Kernel.startNew();
insertAll(index: number, values: IterableOrArrayLike): void {
let newIndex = index;
each(values, value => {
ArrayExt.insert(this._array, index++, value);
});
this._changed.emit({
type: 'add',
oldIndex: -1,
newIndex,
oldValues: [],
newValues: toArray(values)
});
}
setOptions(
newValue: IterableOrArrayLike,
typeMap?: Completer.TypeMap
) {
const values = toArray(newValue || []);
const types = typeMap || {};
if (
JSONExt.deepEqual(values, this._options) &&
JSONExt.deepEqual(types, this._typeMap)
) {
return;
}
if (values.length) {
this._options = values;
this._typeMap = types;
this._orderedTypes = Private.findOrderedTypes(types);
} else {
this._options = [];
this._typeMap = {};
this._orderedTypes = [];
private _sendSessions(): void {
this.set('sessions', toArray(this._sessions.running()));
this.save_changes();
}