Browse Source

Add the test for extractPlugins

Steven Silvester 8 years ago
parent
commit
bec880a26d
2 changed files with 66 additions and 0 deletions
  1. 64 0
      test/src/application/loader.spec.ts
  2. 2 0
      test/src/index.ts

+ 64 - 0
test/src/application/loader.spec.ts

@@ -0,0 +1,64 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+import expect = require('expect.js');
+
+import {
+  ModuleLoader
+} from '../../lib/application/loader';
+
+
+describe('ModuleLoader', () => {
+
+  let loader: ModuleLoader;
+
+  beforeEach(() => {
+    loader = new ModuleLoader();
+  });
+
+  describe('#extractPlugins()', () => {
+
+    it('should pass for a valid plugin array', () => {
+      loader.extractPlugins([{
+        id: 'foo',
+        activate: () => { /* no-op */ }
+      }, {
+        id: 'bar',
+        activate: () => { /* no-op */ }
+      }]);
+    });
+
+    it('should pass for a valid plugin', () => {
+      loader.extractPlugins({
+        id: 'foo',
+        activate: () => { /* no-op */ }
+      });
+    });
+
+    it('should pass for an ES6 default', () => {
+      loader.extractPlugins({
+        __esModule: true,
+        default: {
+          id: 'foo',
+          activate: () => { /* no-op */ }
+        }
+      });
+    });
+
+    it('should fail if it is an empty array', () => {
+      expect(() => { loader.extractPlugins([]); }).to.throwError();
+    });
+
+    it('should fail if a plugin is missing an id', () => {
+      let activate: () => { /* no-op */ };
+      expect(() => { loader.extractPlugins({ activate }); }).to.throwError();
+    });
+
+    it('should fail if a plugin is missing an activate function', () => {
+      expect(() => { loader.extractPlugins({ id: 'foo' }); }).to.throwError();
+    });
+
+  });
+
+
+});

+ 2 - 0
test/src/index.ts

@@ -1,6 +1,8 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
+import './application/loader.spec';
+
 import './commandlinker/commandlinker.spec';
 
 import './common/activitymonitor.spec';