|
@@ -107,6 +107,7 @@ describe('@jupyterlab/apputils', () => {
|
|
describe('#propertyChanged', () => {
|
|
describe('#propertyChanged', () => {
|
|
|
|
|
|
it('should be emitted when a session path changes', (done) => {
|
|
it('should be emitted when a session path changes', (done) => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
session.propertyChanged.connect((sender, args) => {
|
|
session.propertyChanged.connect((sender, args) => {
|
|
expect(sender).to.be(session);
|
|
expect(sender).to.be(session);
|
|
expect(args).to.be('path');
|
|
expect(args).to.be('path');
|
|
@@ -116,6 +117,7 @@ describe('@jupyterlab/apputils', () => {
|
|
});
|
|
});
|
|
|
|
|
|
it('should be emitted when a session name changes', (done) => {
|
|
it('should be emitted when a session name changes', (done) => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
session.propertyChanged.connect((sender, args) => {
|
|
session.propertyChanged.connect((sender, args) => {
|
|
expect(sender).to.be(session);
|
|
expect(sender).to.be(session);
|
|
expect(args).to.be('name');
|
|
expect(args).to.be('name');
|
|
@@ -125,6 +127,7 @@ describe('@jupyterlab/apputils', () => {
|
|
});
|
|
});
|
|
|
|
|
|
it('should be emitted when a session type changes', (done) => {
|
|
it('should be emitted when a session type changes', (done) => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
session.propertyChanged.connect((sender, args) => {
|
|
session.propertyChanged.connect((sender, args) => {
|
|
expect(sender).to.be(session);
|
|
expect(sender).to.be(session);
|
|
expect(args).to.be('type');
|
|
expect(args).to.be('type');
|
|
@@ -149,6 +152,7 @@ describe('@jupyterlab/apputils', () => {
|
|
describe('#path', () => {
|
|
describe('#path', () => {
|
|
|
|
|
|
it('should current path of the the session', () => {
|
|
it('should current path of the the session', () => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
expect(typeof session.path).to.be('string');
|
|
expect(typeof session.path).to.be('string');
|
|
return session.setPath('foo').then(() => {
|
|
return session.setPath('foo').then(() => {
|
|
expect(session.path).to.be('foo');
|
|
expect(session.path).to.be('foo');
|
|
@@ -160,6 +164,7 @@ describe('@jupyterlab/apputils', () => {
|
|
describe('#name', () => {
|
|
describe('#name', () => {
|
|
|
|
|
|
it('should the current name of the the session', () => {
|
|
it('should the current name of the the session', () => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
expect(typeof session.name).to.be('string');
|
|
expect(typeof session.name).to.be('string');
|
|
return session.setName('foo').then(() => {
|
|
return session.setName('foo').then(() => {
|
|
expect(session.name).to.be('foo');
|
|
expect(session.name).to.be('foo');
|
|
@@ -171,6 +176,7 @@ describe('@jupyterlab/apputils', () => {
|
|
describe('#type', () => {
|
|
describe('#type', () => {
|
|
|
|
|
|
it('should the current type of the the session', () => {
|
|
it('should the current type of the the session', () => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
expect(typeof session.type).to.be('string');
|
|
expect(typeof session.type).to.be('string');
|
|
return session.setType('foo').then(() => {
|
|
return session.setType('foo').then(() => {
|
|
expect(session.type).to.be('foo');
|
|
expect(session.type).to.be('foo');
|
|
@@ -243,9 +249,12 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
it('should connect to an existing kernel', () => {
|
|
it('should connect to an existing kernel', () => {
|
|
let other: Session.ISession;
|
|
let other: Session.ISession;
|
|
|
|
+ session.dispose();
|
|
return manager.startNew({ path: uuid() }).then(o => {
|
|
return manager.startNew({ path: uuid() }).then(o => {
|
|
other = o;
|
|
other = o;
|
|
- session.kernelPreference = { id: other.kernel.id };
|
|
|
|
|
|
+ session = new ClientSession({
|
|
|
|
+ manager, kernelPreference: { id: other.kernel.id }
|
|
|
|
+ });
|
|
return session.ready;
|
|
return session.ready;
|
|
}).then(() => {
|
|
}).then(() => {
|
|
expect(session.kernel.id).to.be(other.kernel.id);
|
|
expect(session.kernel.id).to.be(other.kernel.id);
|
|
@@ -416,6 +425,7 @@ describe('@jupyterlab/apputils', () => {
|
|
});
|
|
});
|
|
|
|
|
|
it('should be a no-op if no kernel has been started', () => {
|
|
it('should be a no-op if no kernel has been started', () => {
|
|
|
|
+ session.kernelPreference = { shouldStart: false };
|
|
return session.restart().then(() => {
|
|
return session.restart().then(() => {
|
|
expect(session.kernel).to.not.be.ok();
|
|
expect(session.kernel).to.not.be.ok();
|
|
});
|
|
});
|
|
@@ -426,6 +436,7 @@ describe('@jupyterlab/apputils', () => {
|
|
describe('#setPath()', () => {
|
|
describe('#setPath()', () => {
|
|
|
|
|
|
it('should change the session path', () => {
|
|
it('should change the session path', () => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
return session.setPath('foo').then(() => {
|
|
return session.setPath('foo').then(() => {
|
|
expect(session.path).to.be('foo');
|
|
expect(session.path).to.be('foo');
|
|
});
|
|
});
|
|
@@ -436,6 +447,7 @@ describe('@jupyterlab/apputils', () => {
|
|
describe('#setName', () => {
|
|
describe('#setName', () => {
|
|
|
|
|
|
it('should change the session name', () => {
|
|
it('should change the session name', () => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
return session.setName('foo').then(() => {
|
|
return session.setName('foo').then(() => {
|
|
expect(session.name).to.be('foo');
|
|
expect(session.name).to.be('foo');
|
|
});
|
|
});
|
|
@@ -446,6 +458,7 @@ describe('@jupyterlab/apputils', () => {
|
|
describe('#setType()', () => {
|
|
describe('#setType()', () => {
|
|
|
|
|
|
it('should set the session type', () => {
|
|
it('should set the session type', () => {
|
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
return session.setType('foo').then(() => {
|
|
return session.setType('foo').then(() => {
|
|
expect(session.type).to.be('foo');
|
|
expect(session.type).to.be('foo');
|
|
});
|
|
});
|
|
@@ -457,13 +470,14 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
it('should restart if the user accepts the dialog', () => {
|
|
it('should restart if the user accepts the dialog', () => {
|
|
let called = false;
|
|
let called = false;
|
|
|
|
+
|
|
return session.ready.then(() => {
|
|
return session.ready.then(() => {
|
|
- acceptDialog();
|
|
|
|
session.statusChanged.connect((sender, args) => {
|
|
session.statusChanged.connect((sender, args) => {
|
|
if (args === 'restarting') {
|
|
if (args === 'restarting') {
|
|
called = true;
|
|
called = true;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ acceptDialog();
|
|
return ClientSession.restartKernel(session.kernel);
|
|
return ClientSession.restartKernel(session.kernel);
|
|
}).then(() => {
|
|
}).then(() => {
|
|
expect(called).to.be(true);
|
|
expect(called).to.be(true);
|
|
@@ -473,12 +487,12 @@ describe('@jupyterlab/apputils', () => {
|
|
it('should not restart if the user rejects the dialog', () => {
|
|
it('should not restart if the user rejects the dialog', () => {
|
|
let called = false;
|
|
let called = false;
|
|
return session.ready.then(() => {
|
|
return session.ready.then(() => {
|
|
- dismissDialog();
|
|
|
|
session.statusChanged.connect((sender, args) => {
|
|
session.statusChanged.connect((sender, args) => {
|
|
if (args === 'restarting') {
|
|
if (args === 'restarting') {
|
|
called = true;
|
|
called = true;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ dismissDialog();
|
|
return ClientSession.restartKernel(session.kernel);
|
|
return ClientSession.restartKernel(session.kernel);
|
|
}).then(() => {
|
|
}).then(() => {
|
|
expect(called).to.be(false);
|
|
expect(called).to.be(false);
|
|
@@ -489,6 +503,10 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
describe('.getDefaultKernel()', () => {
|
|
describe('.getDefaultKernel()', () => {
|
|
|
|
|
|
|
|
+ beforeEach(() => {
|
|
|
|
+ session.dispose();
|
|
|
|
+ });
|
|
|
|
+
|
|
it('should return null if no options are given', () => {
|
|
it('should return null if no options are given', () => {
|
|
expect(ClientSession.getDefaultKernel({
|
|
expect(ClientSession.getDefaultKernel({
|
|
specs: manager.specs,
|
|
specs: manager.specs,
|
|
@@ -542,6 +560,10 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
describe('.populateKernelSelect()', () => {
|
|
describe('.populateKernelSelect()', () => {
|
|
|
|
|
|
|
|
+ beforeEach(() => {
|
|
|
|
+ session.dispose();
|
|
|
|
+ });
|
|
|
|
+
|
|
it('should populate the select div', () => {
|
|
it('should populate the select div', () => {
|
|
let div = document.createElement('select');
|
|
let div = document.createElement('select');
|
|
ClientSession.populateKernelSelect(div, {
|
|
ClientSession.populateKernelSelect(div, {
|