Browse Source

Add application tests

Steven Silvester 8 năm trước cách đây
mục cha
commit
b323a937d7
1 tập tin đã thay đổi với 99 bổ sung0 xóa
  1. 99 0
      test/src/application/index.spec.ts

+ 99 - 0
test/src/application/index.spec.ts

@@ -0,0 +1,99 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+import expect = require('expect.js');
+
+import {
+  JupyterLab, ApplicationShell, ModuleLoader
+} from '../../../lib/application';
+
+
+class LabTest extends JupyterLab {
+
+  createShell(): ApplicationShell {
+    return super.createShell();
+  }
+}
+
+
+describe('JupyterLab', () => {
+
+  let lab: JupyterLab;
+  let loader = new ModuleLoader();
+
+  beforeEach(() => {
+    lab = new JupyterLab();
+  });
+
+  describe('#constructor()', () => {
+
+    it('should create a JupyterLab object', () => {
+      expect(lab).to.be.a(JupyterLab);
+    });
+
+    it('should accept options', () => {
+      lab = new JupyterLab({
+        version: 'foo',
+        gitDescription: 'foo',
+        loader
+      });
+    });
+
+  });
+
+  describe('#started', () => {
+
+    it('should resolve when the application is started', (done) => {
+      lab.started.then(done, done);
+      lab.start();
+    });
+
+  });
+
+  describe('#info', () => {
+
+    it('should be the info about the application', () => {
+      expect(lab.info.version).to.be('unknown');
+      expect(lab.info.gitDescription).to.be('unknown');
+      lab = new JupyterLab({
+        version: 'foo',
+        gitDescription: 'foo'
+      });
+      expect(lab.info.version).to.be('foo');
+      expect(lab.info.gitDescription).to.be('foo');
+    });
+
+  });
+
+  describe('#loader', () => {
+
+    it('should be the loader used by the application', () => {
+      expect(lab.loader).to.be(null);
+      lab = new JupyterLab({ loader });
+      expect(lab.loader).to.be(loader);
+    });
+
+  });
+
+  describe('#start()', () => {
+
+    it('should start the application', (done) => {
+      lab.start().then(done, done);
+    });
+
+    it('should accept options', (done) => {
+      lab.start({ hostID: 'foo' }).then(done, done);
+    });
+
+  });
+
+  describe('#createShell()', () => {
+
+    it('should create the application shell', () => {
+      let test = new LabTest();
+      expect(test.createShell()).to.be.an(ApplicationShell);
+    });
+
+  });
+
+});