浏览代码

Fix session context tests

This documents the change in behavior that a session context is not tied to the session lifecycle.
Jason Grout 5 年之前
父节点
当前提交
be9ea013b0
共有 2 个文件被更改,包括 14 次插入10 次删除
  1. 1 1
      packages/apputils/src/sessioncontext.tsx
  2. 13 9
      tests/test-apputils/src/sessioncontext.spec.ts

+ 1 - 1
packages/apputils/src/sessioncontext.tsx

@@ -437,7 +437,7 @@ export class SessionContext implements ISessionContext {
   }
 
   /**
-   * Kill the kernel and shutdown the session.
+   * Shut down the session and kernel.
    *
    * @returns A promise that resolves when the session is shut down.
    */

+ 13 - 9
tests/test-apputils/src/sessioncontext.spec.ts

@@ -64,7 +64,7 @@ describe('@jupyterlab/apputils', () => {
     });
 
     describe('#disposed', () => {
-      it('should be emitted when the session is disposed', async () => {
+      it('should be emitted when the session context is disposed', async () => {
         await sessionContext.initialize();
         let called = false;
         sessionContext.disposed.connect((sender, args) => {
@@ -72,7 +72,7 @@ describe('@jupyterlab/apputils', () => {
           expect(args).to.be.undefined;
           called = true;
         });
-        await sessionContext.shutdown();
+        sessionContext.dispose();
         expect(called).to.be.true;
       });
     });
@@ -80,12 +80,14 @@ describe('@jupyterlab/apputils', () => {
     describe('#kernelChanged', () => {
       it('should be emitted when the kernel changes', async () => {
         let called = false;
-        sessionContext.kernelChanged.connect((sender, { oldValue, newValue }) => {
-          expect(sender).to.equal(sessionContext);
-          expect(oldValue).to.be.null;
-          expect(newValue).to.equal(sessionContext.kernel);
-          called = true;
-        });
+        sessionContext.kernelChanged.connect(
+          (sender, { oldValue, newValue }) => {
+            expect(sender).to.equal(sessionContext);
+            expect(oldValue).to.be.null;
+            expect(newValue).to.equal(sessionContext.kernel);
+            called = true;
+          }
+        );
         await sessionContext.initialize();
         expect(called).to.be.true;
       });
@@ -275,6 +277,7 @@ describe('@jupyterlab/apputils', () => {
         sessionContext.dispose();
         expect(sessionContext.isDisposed).to.equal(true);
       });
+      it.todo('should shut down the session when shutdownOnDispose is true');
     });
 
     describe('#changeKernel()', () => {
@@ -328,11 +331,12 @@ describe('@jupyterlab/apputils', () => {
     });
 
     describe('#restart()', () => {
-      it.only('should restart if the user accepts the dialog', async () => {
+      it('should restart if the user accepts the dialog', async () => {
         const emission = testEmission(sessionContext.statusChanged, {
           find: (_, args) => args === 'restarting'
         });
         await sessionContext.initialize();
+        await sessionContext.session?.kernel?.info;
         const restart = sessionContext.restart();
 
         await acceptDialog();