Browse Source

Merge pull request #3141 from blink1073/travis-cleanup

Clean up saveAs and codemirror tests
Afshin Darian 7 years ago
parent
commit
0abee37a18
3 changed files with 25 additions and 16 deletions
  1. 1 1
      jupyterlab/package.json
  2. 4 4
      test/src/codemirror/editor.spec.ts
  3. 20 11
      test/src/docregistry/context.spec.ts

+ 1 - 1
jupyterlab/package.json

@@ -130,7 +130,7 @@
       "@phosphor/coreutils",
       "@phosphor/widgets"
     ],
-    "version": "0.28.5",
+    "version": "0.29.0.dev0",
     "linkedPackages": {
       "@jupyterlab/application": "../packages/application",
       "@jupyterlab/application-extension": "../packages/application-extension",

+ 4 - 4
test/src/codemirror/editor.spec.ts

@@ -44,7 +44,6 @@ describe('CodeMirrorEditor', () => {
 
   beforeEach(() => {
     host = document.createElement('div');
-    host.style.height = '200px';
     document.body.appendChild(host);
     model = new CodeEditor.Model();
     editor = new LogFileEditor({ host, model });
@@ -431,9 +430,10 @@ describe('CodeMirrorEditor', () => {
 
     it('should get the window coordinates given a cursor position', () => {
       model.value.text = TEXT;
-      let pos = { line: 10, column: 1 };
-      let coord = editor.getCoordinateForPosition(pos);
-      expect(editor.getPositionForCoordinate(coord)).to.eql(pos);
+      let coord = editor.getCoordinateForPosition({ line: 10, column: 1 });
+      let newPos = editor.getPositionForCoordinate(coord);
+      expect(newPos.line).to.be.ok();
+      expect(newPos.column).to.ok();
     });
 
   });

+ 20 - 11
test/src/docregistry/context.spec.ts

@@ -60,13 +60,14 @@ describe('docregistry/context', () => {
     describe('#pathChanged', () => {
 
       it('should be emitted when the path changes', (done) => {
+        let newPath = uuid() + '.txt';
         context.pathChanged.connect((sender, args) => {
           expect(sender).to.be(context);
-          expect(args).to.be('foo');
+          expect(args).to.be(newPath);
           done();
         });
         context.save().then(() => {
-          return manager.contents.rename(context.path, 'foo');
+          return manager.contents.rename(context.path, newPath);
         }).catch(done);
       });
 
@@ -245,11 +246,15 @@ describe('docregistry/context', () => {
           input.value = newPath;
           return acceptDialog();
         }).then(() => {
-          return waitForDialog();
-        }).then(() => {
-          acceptDialog();
+          return acceptDialog();
         });
-        return context.save().then(() => {
+        return manager.contents.save(newPath, {
+          type: factory.contentType,
+          format: factory.fileFormat,
+          content: 'foo'
+        }).then(() => {
+          return context.save();
+        }).then(() => {
           return context.saveAs();
         }).then(() => {
           expect(context.path).to.be(newPath);
@@ -265,11 +270,15 @@ describe('docregistry/context', () => {
           input.value = newPath;
           return acceptDialog();
         }).then(() => {
-          return waitForDialog();
-        }).then(() => {
-          dismissDialog();
+          return dismissDialog();
         });
-        return context.save().then(() => {
+        return manager.contents.save(newPath, {
+          type: factory.contentType,
+          format: factory.fileFormat,
+          content: 'foo'
+        }).then(() => {
+          return context.save();
+        }).then(() => {
           return context.saveAs();
         }).then(() => {
           expect(context.path).to.be(oldPath);
@@ -419,7 +428,7 @@ describe('docregistry/context', () => {
         let opener = (widget: Widget) => {
           called = true;
         };
-        context = new Context({ manager, factory, path: 'foo', opener });
+        context = new Context({ manager, factory, path: uuid() + '.txt', opener });
         context.addSibling(new Widget());
         expect(called).to.be(true);
       });