瀏覽代碼

test cleanup

Steven Silvester 4 年之前
父節點
當前提交
c9c43470da

+ 8 - 5
packages/apputils/src/sessioncontext.tsx

@@ -1413,6 +1413,9 @@ namespace Private {
     const { preference, sessions, specs } = options;
     const { name, id, language, canStart, shouldStart } = preference;
 
+    translator = translator || nullTranslator;
+    const trans = translator.load('jupyterlab');
+
     if (!specs || canStart === false) {
       node.appendChild(optionForNone(translator));
       node.value = 'null';
@@ -1453,7 +1456,7 @@ namespace Private {
 
     // Handle a preferred kernels in order of display name.
     const preferred = document.createElement('optgroup');
-    preferred.label = this._trans.__('Start Preferred Kernel');
+    preferred.label = trans.__('Start Preferred Kernel');
 
     names.sort((a, b) => displayNames[a].localeCompare(displayNames[b]));
     for (const name of names) {
@@ -1468,7 +1471,7 @@ namespace Private {
     node.appendChild(optionForNone());
 
     const other = document.createElement('optgroup');
-    other.label = this._trans.__('Start Other Kernel');
+    other.label = trans.__('Start Other Kernel');
 
     // Add the rest of the kernel names in alphabetical order.
     const otherNames: string[] = [];
@@ -1517,7 +1520,7 @@ namespace Private {
     });
 
     const matching = document.createElement('optgroup');
-    matching.label = this._trans.__('Use Kernel from Preferred Session');
+    matching.label = trans.__('Use Kernel from Preferred Session');
     node.appendChild(matching);
 
     if (matchingSessions.length) {
@@ -1532,7 +1535,7 @@ namespace Private {
     }
 
     const otherSessionsNode = document.createElement('optgroup');
-    otherSessionsNode.label = this._trans.__('Use Kernel from Other Session');
+    otherSessionsNode.label = trans.__('Use Kernel from Other Session');
     node.appendChild(otherSessionsNode);
 
     if (otherSessions.length) {
@@ -1599,7 +1602,7 @@ namespace Private {
     translator?: ITranslator
   ): HTMLOptionElement {
     translator = translator || nullTranslator;
-    const trans = this.translator.load('jupyterlab');
+    const trans = translator.load('jupyterlab');
 
     const option = document.createElement('option');
     const sessionName = session.name || PathExt.basename(session.path);

+ 1 - 1
packages/apputils/test/sessioncontext.spec.ts

@@ -107,7 +107,7 @@ describe('@jupyterlab/apputils', () => {
           (sender, { oldValue, newValue }) => {
             expect(sender).toBe(sessionContext);
             expect(oldValue).toBeNull();
-            expect(newValue).toBe(sessionContext.session?.kernel);
+            expect(newValue).toBe(sessionContext.session?.kernel || null);
             called = true;
           }
         );

+ 2 - 2
packages/services/src/session/default.ts

@@ -189,9 +189,9 @@ export class SessionConnection implements Session.ISessionConnection {
       if (this._kernel !== null) {
         this._kernel.dispose();
       }
-      const oldValue = this._kernel;
+      const oldValue = this._kernel || null;
       this.setupKernel(model.kernel);
-      const newValue = this._kernel;
+      const newValue = this._kernel || null;
       this._kernelChanged.emit({ name: 'kernel', oldValue, newValue });
     }
 

+ 1 - 0
testutils/src/jest-config.ts

@@ -13,6 +13,7 @@ module.exports = function(baseDir: string) {
       '\\.svg$': 'jest-raw-loader',
       '^.+\\.md?$': 'markdown-loader-jest'
     },
+    testTimeout: 10000,
     setupFiles: ['@jupyterlab/testutils/lib/jest-shim.js'],
     testPathIgnorePatterns: ['/lib/', '/node_modules/'],
     moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],

+ 6 - 2
testutils/src/start_jupyter_server.ts

@@ -214,10 +214,14 @@ namespace Private {
     const workspaces_dir = mktempDir('workspaces');
 
     const configData = {
-      LabApp: { user_settings_dir, workspaces_dir, app_dir },
+      LabApp: {
+        user_settings_dir,
+        workspaces_dir,
+        app_dir,
+        open_browser: false
+      },
       ServerApp: {
         token: '',
-        open_browser: false,
         notebook_dir,
         disable_check_xsrf: true,
         allow_origin: '*'