|
@@ -54,7 +54,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
describe('#terminated', () => {
|
|
|
|
|
|
it('should be emitted when the session is terminated', (done) => {
|
|
|
- session.initialize().then(() => {
|
|
|
+ session.ready.then(() => {
|
|
|
session.terminated.connect((sender, args) => {
|
|
|
expect(sender).to.be(session);
|
|
|
expect(args).to.be(undefined);
|
|
@@ -74,7 +74,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
expect(args).to.be.ok();
|
|
|
done();
|
|
|
});
|
|
|
- session.initialize().catch(done);
|
|
|
+ session.ready.catch(done);
|
|
|
});
|
|
|
|
|
|
});
|
|
@@ -87,7 +87,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
expect(typeof args).to.be('string');
|
|
|
done();
|
|
|
});
|
|
|
- session.initialize().catch(done);
|
|
|
+ session.ready.catch(done);
|
|
|
});
|
|
|
|
|
|
});
|
|
@@ -99,7 +99,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
expect(sender).to.be(session);
|
|
|
done();
|
|
|
});
|
|
|
- session.initialize().catch(done);
|
|
|
+ session.ready.catch(done);
|
|
|
});
|
|
|
|
|
|
});
|
|
@@ -139,7 +139,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
it('should be the current kernel of the the session', () => {
|
|
|
expect(session.kernel).to.be(null);
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
expect(session.kernel).to.be.ok();
|
|
|
});
|
|
|
});
|
|
@@ -211,11 +211,78 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
});
|
|
|
|
|
|
+ describe('#isReady', () => {
|
|
|
+
|
|
|
+ it('should be false until ready', () => {
|
|
|
+ expect(session.isReady).to.be(false);
|
|
|
+ return session.ready.then(() => {
|
|
|
+ expect(session.isReady).to.be(true);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('#ready', () => {
|
|
|
+
|
|
|
+ it('should start the default kernel', () => {
|
|
|
+ return session.ready.then(() => {
|
|
|
+ expect(session.kernel.name).to.be(manager.specs.default);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should connect to an existing session on the path', () => {
|
|
|
+ let other: Session.ISession;
|
|
|
+ return manager.startNew({ path: session.path }).then(o => {
|
|
|
+ other = o;
|
|
|
+ return session.ready;
|
|
|
+ }).then(() => {
|
|
|
+ expect(session.kernel.id).to.be(other.kernel.id);
|
|
|
+ return other.dispose();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should connect to an existing kernel', () => {
|
|
|
+ let other: Session.ISession;
|
|
|
+ return manager.startNew({ path: uuid() }).then(o => {
|
|
|
+ other = o;
|
|
|
+ session.kernelPreference = { id: other.kernel.id };
|
|
|
+ return session.ready;
|
|
|
+ }).then(() => {
|
|
|
+ expect(session.kernel.id).to.be(other.kernel.id);
|
|
|
+ return other.dispose();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should present a dialog if there is no distinct kernel to start', () => {
|
|
|
+ session.kernelPreference = {};
|
|
|
+ acceptDialog();
|
|
|
+ return session.ready.then(() => {
|
|
|
+ expect(session.kernel.name).to.be(manager.specs.default);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should be a no-op if if the shouldStart kernelPreference is false', () => {
|
|
|
+ session.kernelPreference = { shouldStart: false };
|
|
|
+ return session.ready.then(() => {
|
|
|
+ expect(session.kernel).to.not.be.ok();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ it('should be a no-op if if the canStart kernelPreference is false', () => {
|
|
|
+ session.kernelPreference = { canStart: false };
|
|
|
+ return session.ready.then(() => {
|
|
|
+ expect(session.kernel).to.not.be.ok();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
describe('#kernelDisplayName', () => {
|
|
|
|
|
|
it('should be the display name of the current kernel', () => {
|
|
|
expect(session.kernelDisplayName).to.be('No Kernel!');
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
expect(session.kernelDisplayName).to.not.be('No Kernel!');
|
|
|
});
|
|
|
});
|
|
@@ -249,7 +316,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
it('should change the current kernel', () => {
|
|
|
let id = '';
|
|
|
let name = '';
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
name = session.kernel.name;
|
|
|
id = session.kernel.id;
|
|
|
return session.changeKernel({ name });
|
|
@@ -271,7 +338,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
describe('#selectKernel()', () => {
|
|
|
|
|
|
it('should select a kernel for the session', () => {
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
let { id, name } = session.kernel;
|
|
|
acceptDialog();
|
|
|
return session.selectKernel().then(() => {
|
|
@@ -282,7 +349,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
});
|
|
|
|
|
|
it('should keep the existing kernel', () => {
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
let { id, name } = session.kernel;
|
|
|
dismissDialog();
|
|
|
return session.selectKernel().then(() => {
|
|
@@ -297,7 +364,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
describe('#shutdown', () => {
|
|
|
|
|
|
it('should kill the kernel and shut down the session', () => {
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
return session.shutdown();
|
|
|
}).then(() => {
|
|
|
expect(session.kernel).to.be(null);
|
|
@@ -310,7 +377,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
it('should restart if the user accepts the dialog', () => {
|
|
|
let called = false;
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
acceptDialog();
|
|
|
session.statusChanged.connect((sender, args) => {
|
|
|
if (args === 'restarting') {
|
|
@@ -325,7 +392,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
it('should not restart if the user rejects the dialog', () => {
|
|
|
let called = false;
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
dismissDialog();
|
|
|
session.statusChanged.connect((sender, args) => {
|
|
|
if (args === 'restarting') {
|
|
@@ -339,7 +406,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
});
|
|
|
|
|
|
it('should start the same kernel as the previously started kernel', () => {
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
return session.shutdown();
|
|
|
}).then(() => {
|
|
|
return session.restart();
|
|
@@ -386,67 +453,11 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
});
|
|
|
|
|
|
- describe('#initialize()', () => {
|
|
|
-
|
|
|
- it('should start the default kernel', () => {
|
|
|
- return session.initialize().then(() => {
|
|
|
- expect(session.kernel.name).to.be(manager.specs.default);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- it('should connect to an existing session on the path', () => {
|
|
|
- let other: Session.ISession;
|
|
|
- return manager.startNew({ path: session.path }).then(o => {
|
|
|
- other = o;
|
|
|
- return session.initialize();
|
|
|
- }).then(() => {
|
|
|
- expect(session.kernel.id).to.be(other.kernel.id);
|
|
|
- return other.dispose();
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- it('should connect to an existing kernel', () => {
|
|
|
- let other: Session.ISession;
|
|
|
- return manager.startNew({ path: uuid() }).then(o => {
|
|
|
- other = o;
|
|
|
- session.kernelPreference = { id: other.kernel.id };
|
|
|
- return session.initialize();
|
|
|
- }).then(() => {
|
|
|
- expect(session.kernel.id).to.be(other.kernel.id);
|
|
|
- return other.dispose();
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- it('should present a dialog if there is no distinct kernel to start', () => {
|
|
|
- session.kernelPreference = {};
|
|
|
- acceptDialog();
|
|
|
- return session.initialize().then(() => {
|
|
|
- expect(session.kernel.name).to.be(manager.specs.default);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- it('should be a no-op if if the shouldStart kernelPreference is false', () => {
|
|
|
- session.kernelPreference = { shouldStart: false };
|
|
|
- return session.initialize().then(() => {
|
|
|
- expect(session.kernel).to.not.be.ok();
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- it('should be a no-op if if the canStart kernelPreference is false', () => {
|
|
|
- session.kernelPreference = { canStart: false };
|
|
|
- return session.initialize().then(() => {
|
|
|
- expect(session.kernel).to.not.be.ok();
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
describe('.restartKernel()', () => {
|
|
|
|
|
|
it('should restart if the user accepts the dialog', () => {
|
|
|
let called = false;
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
acceptDialog();
|
|
|
session.statusChanged.connect((sender, args) => {
|
|
|
if (args === 'restarting') {
|
|
@@ -461,7 +472,7 @@ describe('@jupyterlab/apputils', () => {
|
|
|
|
|
|
it('should not restart if the user rejects the dialog', () => {
|
|
|
let called = false;
|
|
|
- return session.initialize().then(() => {
|
|
|
+ return session.ready.then(() => {
|
|
|
dismissDialog();
|
|
|
session.statusChanged.connect((sender, args) => {
|
|
|
if (args === 'restarting') {
|