Kaynağa Gözat

modernize statusbar tests

Steven Silvester 5 yıl önce
ebeveyn
işleme
618ad99cf8

+ 0 - 1
dev_mode/package.json

@@ -384,7 +384,6 @@
       "@jupyterlab/test-services": "../tests/test-services",
       "@jupyterlab/test-settingregistry": "../tests/test-settingregistry",
       "@jupyterlab/test-statedb": "../tests/test-statedb",
-      "@jupyterlab/test-statusbar": "../tests/test-statusbar",
       "@jupyterlab/test-terminal": "../tests/test-terminal",
       "@jupyterlab/test-ui-components": "../tests/test-ui-components",
       "@jupyterlab/testutils": "../testutils",

+ 11 - 0
packages/statusbar/.vscode/launch.json

@@ -0,0 +1,11 @@
+{
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "type": "node",
+            "request": "attach",
+            "name": "Attach",
+            "port": 9229
+        }
+    ]
+}

+ 0 - 0
tests/test-statusbar/babel.config.js → packages/statusbar/babel.config.js


+ 2 - 0
packages/statusbar/jest.config.js

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

+ 9 - 0
packages/statusbar/package.json

@@ -25,9 +25,14 @@
   },
   "scripts": {
     "build": "tsc -b",
+    "build:test": "tsc --build tsconfig.test.json",
     "clean": "rimraf lib",
     "docs": "typedoc src",
     "prepublishOnly": "npm run build",
+    "test": "jest",
+    "test:cov": "jest --collect-coverage",
+    "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
+    "test:debug:watch": "node --inspect-brk node_modules/.bin/jest --runInBand --watch",
     "watch": "tsc -b --watch"
   },
   "dependencies": {
@@ -48,7 +53,11 @@
     "typestyle": "^2.0.4"
   },
   "devDependencies": {
+    "@jupyterlab/testutils": "^2.1.0",
+    "@types/jest": "^24.0.23",
+    "jest": "^25.2.3",
     "rimraf": "~3.0.0",
+    "ts-jest": "^25.2.1",
     "typescript": "~3.7.3"
   },
   "publishConfig": {

+ 20 - 21
tests/test-statusbar/src/statusbar.spec.ts → packages/statusbar/test/statusbar.spec.ts

@@ -1,7 +1,6 @@
 // Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
 
-import { expect } from 'chai';
+import 'jest';
 
 import { Signal } from '@lumino/signaling';
 
@@ -26,17 +25,17 @@ describe('@jupyterlab/statusbar', () => {
     describe('#constructor()', () => {
       it('should construct a new status bar', () => {
         const statusBar = new StatusBar();
-        expect(statusBar).to.be.an.instanceof(StatusBar);
+        expect(statusBar).toBeInstanceOf(StatusBar);
       });
     });
 
     describe('#registerStatusItem', () => {
       it('should add a new status item to the status bar', () => {
         const item = new Widget();
-        expect(item.isAttached).to.equal(false);
+        expect(item.isAttached).toBe(false);
         statusBar.registerStatusItem('item', { item });
-        expect(item.isAttached).to.be.true;
-        expect(statusBar.contains(item)).to.be.true;
+        expect(item.isAttached).toBe(true);
+        expect(statusBar.contains(item)).toBe(true);
       });
 
       it('should raise an error if the same key is added twice', () => {
@@ -45,7 +44,7 @@ describe('@jupyterlab/statusbar', () => {
         statusBar.registerStatusItem('item', { item: item1 });
         expect(
           statusBar.registerStatusItem.bind(statusBar, 'item', { item: item2 })
-        ).to.throw();
+        ).toThrowError();
       });
 
       it('should put higher rank left items closer to the middle', () => {
@@ -61,7 +60,7 @@ describe('@jupyterlab/statusbar', () => {
           align: 'left',
           rank: 0
         });
-        expect(item2.node.nextSibling).to.equal(item1.node);
+        expect(item2.node.nextSibling).toBe(item1.node);
       });
 
       it('should put higher rank right items closer to the middle', () => {
@@ -79,7 +78,7 @@ describe('@jupyterlab/statusbar', () => {
         });
         // Reverse order than what one might expect, as right-to-left
         // is set in the styling of the right panel.
-        expect(item1.node.nextSibling).to.equal(item2.node);
+        expect(item1.node.nextSibling).toBe(item2.node);
       });
 
       it('should allow insertion of status items in the middle', () => {
@@ -88,7 +87,7 @@ describe('@jupyterlab/statusbar', () => {
           item: item,
           align: 'middle'
         });
-        expect(item.isAttached).to.be.true;
+        expect(item.isAttached).toBe(true);
       });
 
       it('should only show if isActive returns true', () => {
@@ -97,7 +96,7 @@ describe('@jupyterlab/statusbar', () => {
           item,
           isActive: () => false
         });
-        expect(item.isHidden).to.be.true;
+        expect(item.isHidden).toBe(true);
       });
 
       it('should update whether it is shown if activeStateChanged fires', () => {
@@ -110,41 +109,41 @@ describe('@jupyterlab/statusbar', () => {
           isActive,
           activeStateChanged
         });
-        expect(item.isHidden).to.be.true;
+        expect(item.isHidden).toBe(true);
         active = true;
         activeStateChanged.emit(void 0);
-        expect(item.isHidden).to.be.false;
+        expect(item.isHidden).toBe(false);
       });
 
       it('should be removed from the status bar if disposed', () => {
         const item = new Widget();
         const disposable = statusBar.registerStatusItem('item', { item });
-        expect(item.isVisible).to.be.true;
+        expect(item.isVisible).toBe(true);
         disposable.dispose();
-        expect(item.isVisible).to.be.false;
+        expect(item.isVisible).toBe(false);
       });
     });
 
     describe('#dispose', () => {
       it('should dispose of the status bar', () => {
-        expect(statusBar.isDisposed).to.be.false;
+        expect(statusBar.isDisposed).toBe(false);
         statusBar.dispose();
-        expect(statusBar.isDisposed).to.be.true;
+        expect(statusBar.isDisposed).toBe(true);
       });
 
       it('should be safe to call more than once', () => {
         statusBar.dispose();
-        expect(statusBar.isDisposed).to.be.true;
+        expect(statusBar.isDisposed).toBe(true);
         statusBar.dispose();
-        expect(statusBar.isDisposed).to.be.true;
+        expect(statusBar.isDisposed).toBe(true);
       });
 
       it('should dispose of the status items added to it', () => {
         const item = new Widget();
         statusBar.registerStatusItem('item', { item });
-        expect(item.isDisposed).to.be.false;
+        expect(item.isDisposed).toBe(false);
         statusBar.dispose();
-        expect(item.isDisposed).to.be.true;
+        expect(item.isDisposed).toBe(true);
       });
     });
   });

+ 39 - 0
packages/statusbar/tsconfig.test.json

@@ -0,0 +1,39 @@
+{
+  "extends": "../../tsconfigbase.test",
+  "include": ["src/*", "test/*"],
+  "references": [
+    {
+      "path": "../apputils"
+    },
+    {
+      "path": "../codeeditor"
+    },
+    {
+      "path": "../coreutils"
+    },
+    {
+      "path": "../services"
+    },
+    {
+      "path": "../ui-components"
+    },
+    {
+      "path": "../../testutils"
+    },
+    {
+      "path": "../apputils"
+    },
+    {
+      "path": "../codeeditor"
+    },
+    {
+      "path": "../coreutils"
+    },
+    {
+      "path": "../services"
+    },
+    {
+      "path": "../ui-components"
+    }
+  ]
+}

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

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

+ 0 - 30
tests/test-statusbar/package.json

@@ -1,30 +0,0 @@
-{
-  "name": "@jupyterlab/test-statusbar",
-  "version": "2.1.0",
-  "private": true,
-  "scripts": {
-    "build": "tsc -b",
-    "clean": "rimraf build && rimraf coverage",
-    "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/statusbar": "^2.1.0",
-    "@jupyterlab/testutils": "^2.1.0",
-    "@lumino/signaling": "^1.3.5",
-    "@lumino/widgets": "^1.11.1",
-    "chai": "^4.2.0",
-    "jest": "^25.2.3",
-    "ts-jest": "^25.2.1"
-  },
-  "devDependencies": {
-    "@types/chai": "^4.2.7",
-    "@types/jest": "^24.0.23",
-    "puppeteer": "~2.0.0",
-    "rimraf": "~3.0.0",
-    "typescript": "~3.7.3"
-  }
-}

+ 0 - 8
tests/test-statusbar/run.py

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

+ 0 - 18
tests/test-statusbar/tsconfig.json

@@ -1,18 +0,0 @@
-{
-  "extends": "../../tsconfigbase",
-  "compilerOptions": {
-    "outDir": "build",
-    "types": ["jest"],
-    "composite": false,
-    "rootDir": "src"
-  },
-  "include": ["src/*"],
-  "references": [
-    {
-      "path": "../../packages/statusbar"
-    },
-    {
-      "path": "../../testutils"
-    }
-  ]
-}