Explorar o código

Update the cell widget tests

Steven Silvester %!s(int64=8) %!d(string=hai) anos
pai
achega
36a61c35b2
Modificáronse 1 ficheiros con 27 adicións e 23 borrados
  1. 27 23
      test/src/cells/widget.spec.ts

+ 27 - 23
test/src/cells/widget.spec.ts

@@ -3,10 +3,6 @@
 
 import expect = require('expect.js');
 
-import {
-  Kernel
-} from '@jupyterlab/services';
-
 import {
   Message, MessageLoop
 } from '@phosphor/messaging';
@@ -15,6 +11,10 @@ import {
   Widget
 } from '@phosphor/widgets';
 
+import {
+  IClientSession
+} from '@jupyterlab/apputils';
+
 import {
   CodeEditorWidget
 } from '@jupyterlab/codeeditor';
@@ -34,6 +34,10 @@ import {
   editorFactory
 } from '../notebook/utils';
 
+import {
+  createClientSession
+} from '../utils';
+
 
 const RENDERED_CLASS = 'jp-mod-rendered';
 
@@ -383,34 +387,34 @@ describe('cells/widget', () => {
 
     describe('#execute()', () => {
 
-      it('should fulfill a promise if there is no code to execute', () => {
-        let widget = new CodeCellWidget({ model, rendermime, contentFactory });
-        let kernel: Kernel.IKernel;
-        return Kernel.startNew().then(k => {
-          kernel = k;
-          return kernel.ready;
-        }).then(() => {
-          return widget.execute(kernel);
+      let session: IClientSession;
+
+      beforeEach(() => {
+        return createClientSession().then(s => {
+          session = s;
+          return s.initialize();
         }).then(() => {
-          return kernel.shutdown();
+          return session.kernel.ready;
         });
       });
 
+      afterEach(() => {
+        return session.shutdown();
+      });
+
+      it('should fulfill a promise if there is no code to execute', () => {
+        let widget = new CodeCellWidget({ model, rendermime, contentFactory });
+        return widget.execute(session);
+      });
+
       it('should fulfill a promise if there is code to execute', () => {
         let widget = new CodeCellWidget({ model, rendermime, contentFactory });
-        let kernel: Kernel.IKernel;
         let originalCount: number;
-        return Kernel.startNew().then(k => {
-          kernel = k;
-          return kernel.ready;
-        }).then(() => {
-          widget.model.value.text = 'foo';
-          originalCount = (widget.model).executionCount;
-          return widget.execute(kernel);
-        }).then(() => {
+        widget.model.value.text = 'foo';
+        originalCount = (widget.model).executionCount;
+        return widget.execute(session).then(() => {
           let executionCount = (widget.model).executionCount;
           expect(executionCount).to.not.equal(originalCount);
-          return kernel.shutdown();
         });
       });