瀏覽代碼

convert docregistry

Steven Silvester 6 年之前
父節點
當前提交
e87915f416

+ 2 - 0
tests/test-docregistry/jest.config.js

@@ -0,0 +1,2 @@
+const func = require('@jupyterlab/testutils/lib/jest-config');
+module.exports = func('docregistry', __dirname);

+ 0 - 1
tests/test-docregistry/karma-cov.conf.js

@@ -1 +0,0 @@
-module.exports = require('../karma-cov.conf');

+ 0 - 1
tests/test-docregistry/karma.conf.js

@@ -1 +0,0 @@
-module.exports = require('../karma.conf');

+ 9 - 13
tests/test-docregistry/package.json

@@ -5,15 +5,11 @@
   "scripts": {
     "build": "tsc -b",
     "clean": "rimraf build && rimraf coverage",
-    "coverage": "python run-test.py --browsers=ChromeHeadless karma-cov.conf.js",
-    "test": "jlpm run test:firefox",
-    "test:chrome": "python run-test.py --browsers=Chrome karma.conf.js",
-    "test:chrome-headless": "python run-test.py --browsers=ChromeHeadless karma.conf.js",
-    "test:debug": "python run-test.py  --browsers=Chrome --singleRun=false --debug=true --browserNoActivityTimeout=10000000 karma.conf.js",
-    "test:firefox": "python run-test.py --browsers=Firefox karma.conf.js",
-    "test:ie": "python run-test.py  --browsers=IE karma.conf.js",
-    "watch": "tsc -b --watch",
-    "watch:src": "tsp -p src --watch"
+    "coverage": "python run.py --coverage",
+    "test": "python run.py",
+    "watch": "python run.py --debug",
+    "watch:all": "python run.py --debug --watchAll",
+    "watch:src": "tsc -b --watch"
   },
   "dependencies": {
     "@jupyterlab/docregistry": "^0.19.1-alpha.0",
@@ -25,13 +21,13 @@
     "@phosphor/disposable": "^1.1.2",
     "@phosphor/messaging": "^1.2.2",
     "@phosphor/widgets": "^1.6.0",
-    "chai": "~4.1.2"
+    "chai": "~4.1.2",
+    "jest": "^23.5.0",
+    "ts-jest": "^23.1.4"
   },
   "devDependencies": {
     "@types/chai": "~4.0.10",
-    "karma": "~2.0.4",
-    "karma-chrome-launcher": "~2.2.0",
-    "puppeteer": "^1.5.0",
+    "@types/jest": "^23.3.1",
     "rimraf": "~2.6.2",
     "typescript": "~3.1.1"
   }

+ 3 - 5
tests/test-docregistry/run-test.py → tests/test-docregistry/run.py

@@ -1,10 +1,8 @@
 # Copyright (c) Jupyter Development Team.
 # Distributed under the terms of the Modified BSD License.
 
-import os
-from jupyterlab.tests.test_app import run_karma
-
-HERE = os.path.realpath(os.path.dirname(__file__))
+import os.path as osp
+from jupyterlab.tests.test_app import run_jest
 
 if __name__ == '__main__':
-    run_karma(HERE)
+    run_jest(osp.dirname(osp.realpath(__file__)))

+ 2 - 2
tests/test-docregistry/src/context.spec.ts

@@ -13,7 +13,7 @@ import {
   Context,
   DocumentRegistry,
   TextModelFactory
-} from '@jupyterlab/docregistry';
+} from '@jupyterlab/docregistry/src';
 
 import { RenderMimeRegistry } from '@jupyterlab/rendermime';
 
@@ -29,7 +29,7 @@ describe('docregistry/context', () => {
   let manager: ServiceManager.IManager;
   const factory = new TextModelFactory();
 
-  before(() => {
+  beforeAll(() => {
     manager = new ServiceManager();
     return manager.ready;
   });

+ 2 - 2
tests/test-docregistry/src/default.spec.ts

@@ -18,7 +18,7 @@ import {
   IDocumentWidget,
   TextModelFactory,
   Context
-} from '@jupyterlab/docregistry';
+} from '@jupyterlab/docregistry/src';
 
 import { ServiceManager } from '@jupyterlab/services';
 
@@ -543,7 +543,7 @@ describe('docregistry/default', () => {
       widget = new DocumentWidget({ context, content });
     };
 
-    before(async () => {
+    beforeAll(async () => {
       manager = new ServiceManager();
       await manager.ready;
     });

+ 2 - 2
tests/test-docregistry/src/mimedocument.spec.ts

@@ -13,7 +13,7 @@ import {
   MimeContent,
   MimeDocument,
   MimeDocumentFactory
-} from '@jupyterlab/docregistry';
+} from '@jupyterlab/docregistry/src';
 
 import { RenderedText, IRenderMime } from '@jupyterlab/rendermime';
 
@@ -107,7 +107,7 @@ describe('docregistry/mimedocument', () => {
       });
     });
 
-    context('contents changed', () => {
+    describe('contents changed', () => {
       it('should change the document contents', async () => {
         RENDERMIME.addFactory(fooFactory);
         await dContext.initialize(true);

+ 1 - 1
tests/test-docregistry/src/registry.spec.ts

@@ -17,7 +17,7 @@ import {
   DocumentRegistry,
   DocumentWidget,
   IDocumentWidget
-} from '@jupyterlab/docregistry';
+} from '@jupyterlab/docregistry/src';
 
 class WidgetFactory extends ABCWidgetFactory<IDocumentWidget> {
   protected createNewWidget(

+ 1 - 1
tests/test-docregistry/tsconfig.json

@@ -2,7 +2,7 @@
   "extends": "../../tsconfigbase",
   "compilerOptions": {
     "outDir": "build",
-    "types": ["mocha"],
+    "types": ["jest"],
     "composite": false,
     "rootDir": "src"
   },

+ 12 - 4
testutils/src/jest-shim.ts

@@ -5,7 +5,9 @@ const fetchMod = ((window as any).fetch = require('node-fetch')); // tslint:disa
 (window as any).Headers = fetchMod.Headers;
 
 (global as any).Image = (window as any).Image;
-(global as any).Range = function Range() {};
+(global as any).Range = function Range() {
+  /* no-op */
+};
 
 const createContextualFragment = (html: string) => {
   const div = document.createElement('div');
@@ -16,13 +18,19 @@ const createContextualFragment = (html: string) => {
 (global as any).Range.prototype.createContextualFragment = (html: string) =>
   createContextualFragment(html);
 
-window.focus = () => {};
+window.focus = () => {
+  /* no-op */
+};
 
 // HACK: Polyfill that allows codemirror to render in a JSDOM env.
 (window as any).document.createRange = function createRange() {
   return {
-    setEnd: () => {},
-    setStart: () => {},
+    setEnd: () => {
+      /* no-op */
+    },
+    setStart: () => {
+      /* no-op */
+    },
     getBoundingClientRect: () => ({ right: 0 }),
     getClientRects: (): ClientRect[] => [],
     createContextualFragment