浏览代码

test cleanup

Steven Silvester 6 年之前
父节点
当前提交
bf07ce830a

+ 3 - 3
tests/test-cells/src/widget.spec.ts

@@ -277,10 +277,10 @@ describe('cells/widget', () => {
         });
       });
 
-      describe('#NBTestUtils.editorFactory', () => {
+      describe('#editorFactory', () => {
         it('should be the editor factory used by the content factory', () => {
-          let factory = new Cell.ContentFactory({});
-          expect(factory.editorFactory).to.be(editorFactory);
+          let factory = new Cell.ContentFactory({ editorFactory });
+          expect(factory.editorFactory).to.equal(editorFactory);
         });
       });
 

+ 1 - 1
tests/test-codeeditor/src/jsoneditor.spec.ts

@@ -369,7 +369,7 @@ describe('apputils', () => {
     });
 
     describe('#onAfterShow()', () => {
-      it('should update the editor', done => {
+      it('should update the editor', async () => {
         editor.hide();
         Widget.attach(editor, document.body);
         editor.show();

+ 1 - 1
tests/test-coreutils/src/settingregistry.spec.ts

@@ -148,7 +148,7 @@ describe('@jupyterlab/coreutils', () => {
         });
         await registry.load(id);
         await registry.set(id, key, value);
-        expect(called).to.be(true);
+        expect(called).to.equal(true);
       });
     });
 

+ 23 - 21
tests/test-outputarea/src/model.spec.ts

@@ -7,7 +7,7 @@ import { OutputModel } from '@jupyterlab/rendermime';
 
 import { OutputAreaModel } from '@jupyterlab/outputarea';
 
-import { DEFAULT_OUTPUTS } from '@jupyterlab/testutils';
+import { NBTestUtils } from '@jupyterlab/testutils';
 
 describe('outputarea/model', () => {
   let model: OutputAreaModel;
@@ -29,7 +29,7 @@ describe('outputarea/model', () => {
       it('should accept options', () => {
         let contentFactory = new OutputAreaModel.ContentFactory();
         model = new OutputAreaModel({
-          values: DEFAULT_OUTPUTS,
+          values: NBTestUtils.DEFAULT_OUTPUTS,
           contentFactory,
           trusted: true
         });
@@ -49,7 +49,7 @@ describe('outputarea/model', () => {
           expect(args.oldValues.length).to.be(0);
           called = true;
         });
-        model.add(DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         expect(called).to.be(true);
       });
     });
@@ -57,7 +57,7 @@ describe('outputarea/model', () => {
     describe('#stateChanged', () => {
       it('should be emitted when an item changes', () => {
         let called = false;
-        model.add(DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         model.stateChanged.connect((sender, args) => {
           expect(sender).to.be(model);
           expect(args).to.be(void 0);
@@ -72,7 +72,7 @@ describe('outputarea/model', () => {
     describe('#length', () => {
       it('should get the length of the items in the model', () => {
         expect(model.length).to.be(0);
-        model.add(DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         expect(model.length).to.be(1);
       });
     });
@@ -84,8 +84,8 @@ describe('outputarea/model', () => {
 
       it('should cause all of the cells to `set`', () => {
         let called = 0;
-        model.add(DEFAULT_OUTPUTS[0]);
-        model.add(DEFAULT_OUTPUTS[1]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[1]);
         model.changed.connect(() => {
           called++;
         });
@@ -112,7 +112,7 @@ describe('outputarea/model', () => {
 
     describe('#dispose()', () => {
       it('should dispose of the resources used by the model', () => {
-        model.add(DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         model.dispose();
         expect(model.isDisposed).to.be(true);
         expect(model.length).to.be(0);
@@ -127,35 +127,35 @@ describe('outputarea/model', () => {
 
     describe('#get()', () => {
       it('should get the item at the specified index', () => {
-        model.add(DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         let output = model.get(0);
-        expect(output.type).to.be(DEFAULT_OUTPUTS[0].output_type);
+        expect(output.type).to.be(NBTestUtils.DEFAULT_OUTPUTS[0].output_type);
       });
 
       it('should return `undefined` if out of range', () => {
-        model.add(DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         expect(model.get(1)).to.be(void 0);
       });
     });
 
     describe('#add()', () => {
       it('should add an output', () => {
-        model.add(DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         expect(model.length).to.be(1);
       });
 
       it('should consolidate consecutive stream outputs of the same kind', () => {
-        model.add(DEFAULT_OUTPUTS[0]);
-        model.add(DEFAULT_OUTPUTS[1]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[1]);
         expect(model.length).to.be(2);
-        model.add(DEFAULT_OUTPUTS[2]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[2]);
         expect(model.length).to.be(2);
       });
     });
 
     describe('#clear()', () => {
       it('should clear all of the output', () => {
-        for (let output of DEFAULT_OUTPUTS) {
+        for (let output of NBTestUtils.DEFAULT_OUTPUTS) {
           model.add(output);
         }
         model.clear();
@@ -163,10 +163,10 @@ describe('outputarea/model', () => {
       });
 
       it('should wait for next add if requested', () => {
-        model.add(DEFAULT_OUTPUTS[0]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         model.clear(true);
         expect(model.length).to.be(1);
-        model.add(DEFAULT_OUTPUTS[1]);
+        model.add(NBTestUtils.DEFAULT_OUTPUTS[1]);
         expect(model.length).to.be(1);
       });
     });
@@ -174,7 +174,7 @@ describe('outputarea/model', () => {
     describe('#fromJSON()', () => {
       it('should deserialize the model from JSON', () => {
         model.clear();
-        model.fromJSON(DEFAULT_OUTPUTS);
+        model.fromJSON(NBTestUtils.DEFAULT_OUTPUTS);
         expect(model.toJSON().length).to.be(5);
       });
     });
@@ -182,7 +182,7 @@ describe('outputarea/model', () => {
     describe('#toJSON()', () => {
       it('should serialize the model to JSON', () => {
         expect(model.toJSON()).to.eql([]);
-        model.fromJSON(DEFAULT_OUTPUTS);
+        model.fromJSON(NBTestUtils.DEFAULT_OUTPUTS);
         expect(model.toJSON().length).to.be(5);
       });
     });
@@ -192,7 +192,9 @@ describe('outputarea/model', () => {
     describe('#createOutputModel()', () => {
       it('should create an output model', () => {
         let factory = new OutputAreaModel.ContentFactory();
-        let model = factory.createOutputModel({ value: DEFAULT_OUTPUTS[0] });
+        let model = factory.createOutputModel({
+          value: NBTestUtils.DEFAULT_OUTPUTS[0]
+        });
         expect(model).to.be.an(OutputModel);
       });
     });

+ 14 - 9
tests/test-outputarea/src/widget.spec.ts

@@ -20,7 +20,7 @@ import {
 import {
   createClientSession,
   defaultRenderMime,
-  DEFAULT_OUTPUTS
+  NBTestUtils
 } from '@jupyterlab/testutils';
 
 /**
@@ -52,7 +52,10 @@ describe('outputarea/widget', () => {
   let model: OutputAreaModel;
 
   beforeEach(() => {
-    model = new OutputAreaModel({ values: DEFAULT_OUTPUTS, trusted: true });
+    model = new OutputAreaModel({
+      values: NBTestUtils.DEFAULT_OUTPUTS,
+      trusted: true
+    });
     widget = new LogOutputArea({ rendermime, model });
   });
 
@@ -99,7 +102,9 @@ describe('outputarea/widget', () => {
       });
 
       it('should get the number of child widgets', () => {
-        expect(widget.widgets.length).to.be(DEFAULT_OUTPUTS.length - 1);
+        expect(widget.widgets.length).to.be(
+          NBTestUtils.DEFAULT_OUTPUTS.length - 1
+        );
         widget.model.clear();
         expect(widget.widgets.length).to.be(0);
       });
@@ -136,7 +141,7 @@ describe('outputarea/widget', () => {
       });
 
       it('should clear existing outputs', () => {
-        widget.model.fromJSON(DEFAULT_OUTPUTS);
+        widget.model.fromJSON(NBTestUtils.DEFAULT_OUTPUTS);
         return session.kernel.ready
           .then(() => {
             let future = session.kernel.requestExecute({ code: CODE });
@@ -154,13 +159,13 @@ describe('outputarea/widget', () => {
       it('should handle an added output', () => {
         widget.model.clear();
         widget.methods = [];
-        widget.model.add(DEFAULT_OUTPUTS[0]);
+        widget.model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         expect(widget.methods).to.contain('onModelChanged');
         expect(widget.widgets.length).to.be(1);
       });
 
       it('should handle a clear', () => {
-        widget.model.fromJSON(DEFAULT_OUTPUTS);
+        widget.model.fromJSON(NBTestUtils.DEFAULT_OUTPUTS);
         widget.methods = [];
         widget.model.clear();
         expect(widget.methods).to.contain('onModelChanged');
@@ -169,9 +174,9 @@ describe('outputarea/widget', () => {
 
       it('should handle a set', () => {
         widget.model.clear();
-        widget.model.add(DEFAULT_OUTPUTS[0]);
+        widget.model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         widget.methods = [];
-        widget.model.add(DEFAULT_OUTPUTS[0]);
+        widget.model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
         expect(widget.methods).to.contain('onModelChanged');
         expect(widget.widgets.length).to.be(1);
       });
@@ -204,7 +209,7 @@ describe('outputarea/widget', () => {
       });
 
       it('should clear existing outputs', () => {
-        widget.model.fromJSON(DEFAULT_OUTPUTS);
+        widget.model.fromJSON(NBTestUtils.DEFAULT_OUTPUTS);
         return OutputArea.execute(CODE, widget, session).then(reply => {
           expect(reply.content.execution_count).to.be.ok();
           expect(model.length).to.be(1);

+ 3 - 3
tests/test-rendermime/src/outputmodel.spec.ts

@@ -7,7 +7,7 @@ import { nbformat } from '@jupyterlab/coreutils';
 
 import { OutputModel } from '@jupyterlab/rendermime';
 
-import { DEFAULT_OUTPUTS } from '@jupyterlab/testutils';
+import { NBTestUtils } from '@jupyterlab/testutils';
 
 const DEFAULT_EXECUTE: nbformat.IOutput = {
   output_type: 'execute_result',
@@ -67,8 +67,8 @@ describe('rendermime/outputmodel', () => {
 
     describe('.getData()', () => {
       it('should handle all bundle types', () => {
-        for (let i = 0; i < DEFAULT_OUTPUTS.length; i++) {
-          let output = DEFAULT_OUTPUTS[i];
+        for (let i = 0; i < NBTestUtils.DEFAULT_OUTPUTS.length; i++) {
+          let output = NBTestUtils.DEFAULT_OUTPUTS[i];
           let bundle = OutputModel.getData(output);
           expect(Object.keys(bundle).length).to.not.be(0);
         }

+ 2 - 0
testutils/src/index.ts

@@ -20,6 +20,8 @@ import { INotebookModel, NotebookModelFactory } from '@jupyterlab/notebook';
 
 export { NBTestUtils } from './notebook-utils';
 
+export { defaultRenderMime } from './rendermime';
+
 /**
  * Test a single emission from a signal.
  *