Browse Source

Merge pull request #8315 from blink1073/modernize-observables

Modernize observables tests
Steven Silvester 5 years ago
parent
commit
c7614a284b

+ 0 - 1
dev_mode/package.json

@@ -374,7 +374,6 @@
       "@jupyterlab/test-logconsole": "../tests/test-logconsole",
       "@jupyterlab/test-mainmenu": "../tests/test-mainmenu",
       "@jupyterlab/test-notebook": "../tests/test-notebook",
-      "@jupyterlab/test-observables": "../tests/test-observables",
       "@jupyterlab/test-outputarea": "../tests/test-outputarea",
       "@jupyterlab/test-settingregistry": "../tests/test-settingregistry",
       "@jupyterlab/test-statedb": "../tests/test-statedb",

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

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

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


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

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

+ 9 - 0
packages/observables/package.json

@@ -26,9 +26,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": {
@@ -39,7 +44,11 @@
     "@lumino/signaling": "^1.3.5"
   },
   "devDependencies": {
+    "@jupyterlab/testutils": "^2.1.0",
+    "@types/jest": "^24.0.23",
+    "jest": "^25.2.3",
     "rimraf": "~3.0.0",
+    "ts-jest": "^25.2.1",
     "typedoc": "^0.15.4",
     "typescript": "~3.7.3"
   },

+ 68 - 69
tests/test-observables/src/modeldb.spec.ts → packages/observables/test/modeldb.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 { JSONExt } from '@lumino/coreutils';
 
@@ -18,31 +17,31 @@ describe('@jupyterlab/observables', () => {
     describe('#constructor', () => {
       it('should accept no arguments', () => {
         const value = new ObservableValue();
-        expect(value instanceof ObservableValue).to.equal(true);
-        expect(value.get()).to.be.null;
+        expect(value instanceof ObservableValue).toBe(true);
+        expect(value.get()).toBeNull();
       });
 
       it('should accept an initial JSON value', () => {
         const value = new ObservableValue('value');
-        expect(value instanceof ObservableValue).to.equal(true);
+        expect(value instanceof ObservableValue).toBe(true);
         const value2 = new ObservableValue({ one: 'one', two: 2 });
-        expect(value2 instanceof ObservableValue).to.equal(true);
+        expect(value2 instanceof ObservableValue).toBe(true);
       });
     });
 
     describe('#type', () => {
       it('should return `Value`', () => {
         const value = new ObservableValue();
-        expect(value.type).to.equal('Value');
+        expect(value.type).toBe('Value');
       });
     });
 
     describe('#isDisposed', () => {
       it('should test whether the value is disposed', () => {
         const value = new ObservableValue();
-        expect(value.isDisposed).to.equal(false);
+        expect(value.isDisposed).toBe(false);
         value.dispose();
-        expect(value.isDisposed).to.equal(true);
+        expect(value.isDisposed).toBe(true);
       });
     });
 
@@ -54,31 +53,31 @@ describe('@jupyterlab/observables', () => {
           called = true;
         });
         value.set('set');
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
 
       it('should have value changed args', () => {
         let called = false;
         const value = new ObservableValue();
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.newValue).to.equal('set');
-          expect(args.oldValue).to.be.null;
+          expect(sender).toBe(value);
+          expect(args.newValue).toBe('set');
+          expect(args.oldValue).toBeNull();
           called = true;
         });
         value.set('set');
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
     describe('#get', () => {
       it('should get the value of the object', () => {
         const value = new ObservableValue('value');
-        expect(value.get()).to.equal('value');
+        expect(value.get()).toBe('value');
         const value2 = new ObservableValue({ one: 'one', two: 2 });
-        expect(
-          JSONExt.deepEqual(value2.get(), { one: 'one', two: 2 })
-        ).to.equal(true);
+        expect(JSONExt.deepEqual(value2.get(), { one: 'one', two: 2 })).toBe(
+          true
+        );
       });
     });
 
@@ -86,7 +85,7 @@ describe('@jupyterlab/observables', () => {
       it('should set the value of the object', () => {
         const value = new ObservableValue();
         value.set('value');
-        expect(value.get()).to.equal('value');
+        expect(value.get()).toBe('value');
       });
     });
   });
@@ -95,53 +94,53 @@ describe('@jupyterlab/observables', () => {
     describe('#constructor()', () => {
       it('should accept no arguments', () => {
         const db = new ModelDB();
-        expect(db instanceof ModelDB).to.equal(true);
+        expect(db instanceof ModelDB).toBe(true);
       });
 
       it('should accept a basePath', () => {
         const db = new ModelDB({ basePath: 'base' });
-        expect(db instanceof ModelDB).to.equal(true);
+        expect(db instanceof ModelDB).toBe(true);
       });
 
       it('should accept a baseDB', () => {
         const base = new ModelDB();
         const db = new ModelDB({ baseDB: base });
-        expect(db instanceof ModelDB).to.equal(true);
+        expect(db instanceof ModelDB).toBe(true);
       });
     });
 
     describe('#isDisposed', () => {
       it('should test whether it is disposed', () => {
         const db = new ModelDB();
-        expect(db.isDisposed).to.equal(false);
+        expect(db.isDisposed).toBe(false);
         db.dispose();
-        expect(db.isDisposed).to.equal(true);
+        expect(db.isDisposed).toBe(true);
       });
     });
 
     describe('#basePath', () => {
       it('should return an empty string for a model without a baseDB', () => {
         const db = new ModelDB();
-        expect(db.basePath).to.equal('');
+        expect(db.basePath).toBe('');
       });
 
       it('should return the base path', () => {
         const db = new ModelDB({ basePath: 'base' });
-        expect(db.basePath).to.equal('base');
+        expect(db.basePath).toBe('base');
       });
     });
 
     describe('#isPrepopulated', () => {
       it('should return false for an in-memory database', () => {
         const db = new ModelDB();
-        expect(db.isPrepopulated).to.equal(false);
+        expect(db.isPrepopulated).toBe(false);
       });
     });
 
     describe('#isCollaborative', () => {
       it('should return false for an in-memory database', () => {
         const db = new ModelDB();
-        expect(db.isCollaborative).to.equal(false);
+        expect(db.isCollaborative).toBe(false);
       });
     });
 
@@ -157,12 +156,12 @@ describe('@jupyterlab/observables', () => {
         const db = new ModelDB();
         const value = db.createValue('value');
         const value2 = db.get('value');
-        expect(value2).to.equal(value);
+        expect(value2).toBe(value);
       });
 
       it('should return undefined for a value that does not exist', () => {
         const db = new ModelDB();
-        expect(db.get('value')).to.be.undefined;
+        expect(db.get('value')).toBeUndefined();
       });
     });
 
@@ -170,12 +169,12 @@ describe('@jupyterlab/observables', () => {
       it('should return true if a value exists at a path', () => {
         const db = new ModelDB();
         db.createValue('value');
-        expect(db.has('value')).to.equal(true);
+        expect(db.has('value')).toBe(true);
       });
 
       it('should return false for a value that does not exist', () => {
         const db = new ModelDB();
-        expect(db.has('value')).to.equal(false);
+        expect(db.has('value')).toBe(false);
       });
     });
 
@@ -183,13 +182,13 @@ describe('@jupyterlab/observables', () => {
       it('should create an ObservableString`', () => {
         const db = new ModelDB();
         const str = db.createString('str');
-        expect(str instanceof ObservableString).to.equal(true);
+        expect(str instanceof ObservableString).toBe(true);
       });
 
       it('should be able to retrieve that string using `get`', () => {
         const db = new ModelDB();
         const str = db.createString('str');
-        expect(db.get('str')).to.equal(str);
+        expect(db.get('str')).toBe(str);
       });
     });
 
@@ -197,13 +196,13 @@ describe('@jupyterlab/observables', () => {
       it('should create an ObservableUndoableList`', () => {
         const db = new ModelDB();
         const str = db.createList('vec');
-        expect(str instanceof ObservableUndoableList).to.equal(true);
+        expect(str instanceof ObservableUndoableList).toBe(true);
       });
 
       it('should be able to retrieve that vector using `get`', () => {
         const db = new ModelDB();
         const vec = db.createList('vec');
-        expect(db.get('vec')).to.equal(vec);
+        expect(db.get('vec')).toBe(vec);
       });
     });
 
@@ -211,13 +210,13 @@ describe('@jupyterlab/observables', () => {
       it('should create an ObservableMap`', () => {
         const db = new ModelDB();
         const map = db.createMap('map');
-        expect(map instanceof ObservableJSON).to.equal(true);
+        expect(map instanceof ObservableJSON).toBe(true);
       });
 
       it('should be able to retrieve that map using `get`', () => {
         const db = new ModelDB();
         const map = db.createMap('map');
-        expect(db.get('map')).to.equal(map);
+        expect(db.get('map')).toBe(map);
       });
     });
 
@@ -225,13 +224,13 @@ describe('@jupyterlab/observables', () => {
       it('should create an ObservableValue`', () => {
         const db = new ModelDB();
         const value = db.createValue('value');
-        expect(value instanceof ObservableValue).to.equal(true);
+        expect(value instanceof ObservableValue).toBe(true);
       });
 
       it('should be able to retrieve that value using `get`', () => {
         const db = new ModelDB();
         const value = db.createString('value');
-        expect(db.get('value')).to.equal(value);
+        expect(db.get('value')).toBe(value);
       });
     });
 
@@ -240,7 +239,7 @@ describe('@jupyterlab/observables', () => {
         const db = new ModelDB();
         const value = db.createValue('value');
         db.setValue('value', 'set');
-        expect(value.get()).to.equal('set');
+        expect(value.get()).toBe('set');
       });
     });
 
@@ -249,7 +248,7 @@ describe('@jupyterlab/observables', () => {
         const db = new ModelDB();
         const value = db.createValue('value');
         value.set('set');
-        expect(db.getValue('value')).to.equal('set');
+        expect(db.getValue('value')).toBe('set');
       });
     });
 
@@ -257,14 +256,14 @@ describe('@jupyterlab/observables', () => {
       it('should should return a ModelDB', () => {
         const db = new ModelDB();
         const view = db.view('');
-        expect(view instanceof ModelDB).to.equal(true);
-        expect(view === db).to.equal(false);
+        expect(view instanceof ModelDB).toBe(true);
+        expect(view === db).toBe(false);
       });
 
       it('should set the baseDB path on the view', () => {
         const db = new ModelDB();
         const view = db.view('base');
-        expect(view.basePath).to.equal('base');
+        expect(view.basePath).toBe('base');
       });
 
       it('should return a view onto the base ModelDB', () => {
@@ -272,10 +271,10 @@ describe('@jupyterlab/observables', () => {
         const view = db.view('base');
 
         db.createString('base.str1');
-        expect(db.get('base.str1')).to.equal(view.get('str1'));
+        expect(db.get('base.str1')).toBe(view.get('str1'));
 
         view.createString('str2');
-        expect(db.get('base.str2')).to.equal(view.get('str2'));
+        expect(db.get('base.str2')).toBe(view.get('str2'));
       });
 
       it('should be stackable', () => {
@@ -283,12 +282,12 @@ describe('@jupyterlab/observables', () => {
         const view = db.view('one');
         const viewView = view.view('two');
 
-        expect(view.basePath).to.equal('one');
-        expect(viewView.basePath).to.equal('two');
+        expect(view.basePath).toBe('one');
+        expect(viewView.basePath).toBe('two');
 
         viewView.createString('str');
-        expect(viewView.get('str')).to.equal(view.get('two.str'));
-        expect(viewView.get('str')).to.equal(db.get('one.two.str'));
+        expect(viewView.get('str')).toBe(view.get('two.str'));
+        expect(viewView.get('str')).toBe(db.get('one.two.str'));
       });
     });
 
@@ -298,15 +297,15 @@ describe('@jupyterlab/observables', () => {
         const str = db.createString('str');
         const view = db.view('base');
         const str2 = view.createString('str');
-        expect(db.isDisposed).to.equal(false);
-        expect(str.isDisposed).to.equal(false);
-        expect(view.isDisposed).to.equal(false);
-        expect(str2.isDisposed).to.equal(false);
+        expect(db.isDisposed).toBe(false);
+        expect(str.isDisposed).toBe(false);
+        expect(view.isDisposed).toBe(false);
+        expect(str2.isDisposed).toBe(false);
         db.dispose();
-        expect(db.isDisposed).to.equal(true);
-        expect(str.isDisposed).to.equal(true);
-        expect(view.isDisposed).to.equal(true);
-        expect(str2.isDisposed).to.equal(true);
+        expect(db.isDisposed).toBe(true);
+        expect(str.isDisposed).toBe(true);
+        expect(view.isDisposed).toBe(true);
+        expect(str2.isDisposed).toBe(true);
       });
 
       it('should not dispose of resources in base databases', () => {
@@ -314,22 +313,22 @@ describe('@jupyterlab/observables', () => {
         const view = db.view('base');
         const str = db.createString('str');
         const str2 = view.createString('str');
-        expect(db.isDisposed).to.equal(false);
-        expect(str.isDisposed).to.equal(false);
-        expect(view.isDisposed).to.equal(false);
-        expect(str2.isDisposed).to.equal(false);
+        expect(db.isDisposed).toBe(false);
+        expect(str.isDisposed).toBe(false);
+        expect(view.isDisposed).toBe(false);
+        expect(str2.isDisposed).toBe(false);
         view.dispose();
-        expect(view.isDisposed).to.equal(true);
-        expect(str2.isDisposed).to.equal(true);
-        expect(db.isDisposed).to.equal(false);
-        expect(str.isDisposed).to.equal(false);
+        expect(view.isDisposed).toBe(true);
+        expect(str2.isDisposed).toBe(true);
+        expect(db.isDisposed).toBe(false);
+        expect(str.isDisposed).toBe(false);
       });
 
       it('should be safe to call more than once', () => {
         const db = new ModelDB();
-        expect(db.isDisposed).to.equal(false);
+        expect(db.isDisposed).toBe(false);
         db.dispose();
-        expect(db.isDisposed).to.equal(true);
+        expect(db.isDisposed).toBe(true);
       });
     });
   });

+ 7 - 8
tests/test-observables/src/observablejson.spec.ts → packages/observables/test/observablejson.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 { IObservableJSON, ObservableJSON } from '@jupyterlab/observables';
 
@@ -10,14 +9,14 @@ describe('@jupyterlab/observables', () => {
     describe('#constructor()', () => {
       it('should create an observable JSON object', () => {
         const item = new ObservableJSON();
-        expect(item).to.be.an.instanceof(ObservableJSON);
+        expect(item).toBeInstanceOf(ObservableJSON);
       });
 
       it('should accept initial values', () => {
         const item = new ObservableJSON({
           values: { foo: 1, bar: 'baz' }
         });
-        expect(item).to.be.an.instanceof(ObservableJSON);
+        expect(item).toBeInstanceOf(ObservableJSON);
       });
     });
 
@@ -25,7 +24,7 @@ describe('@jupyterlab/observables', () => {
       it('should serialize the model to JSON', () => {
         const item = new ObservableJSON();
         item.set('foo', 1);
-        expect(item.toJSON()['foo']).to.equal(1);
+        expect(item.toJSON()['foo']).toBe(1);
       });
 
       it('should return a copy of the data', () => {
@@ -33,7 +32,7 @@ describe('@jupyterlab/observables', () => {
         item.set('foo', { bar: 1 });
         const value = item.toJSON();
         value['bar'] = 2;
-        expect((item.get('foo') as any)['bar']).to.equal(1);
+        expect((item.get('foo') as any)['bar']).toBe(1);
       });
     });
   });
@@ -47,7 +46,7 @@ describe('@jupyterlab/observables', () => {
           oldValue: 1,
           newValue: 2
         });
-        expect(message).to.be.an.instanceof(ObservableJSON.ChangeMessage);
+        expect(message).toBeInstanceOf(ObservableJSON.ChangeMessage);
       });
     });
 
@@ -63,7 +62,7 @@ describe('@jupyterlab/observables', () => {
           'jsonvalue-changed',
           args
         );
-        expect(message.args).to.equal(args);
+        expect(message.args).toBe(args);
       });
     });
   });

+ 106 - 107
tests/test-observables/src/observablelist.spec.ts → packages/observables/test/observablelist.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 { toArray } from '@lumino/algorithm';
 
@@ -12,20 +11,20 @@ describe('@jupyterlab/observables', () => {
     describe('#constructor()', () => {
       it('should accept no arguments', () => {
         const value = new ObservableList<number>();
-        expect(value instanceof ObservableList).to.equal(true);
+        expect(value instanceof ObservableList).toBe(true);
       });
 
       it('should accept an array argument', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
-        expect(value instanceof ObservableList).to.equal(true);
-        expect(toArray(value)).to.deep.equal([1, 2, 3]);
+        expect(value instanceof ObservableList).toBe(true);
+        expect(toArray(value)).toEqual([1, 2, 3]);
       });
     });
 
     describe('#type', () => {
       it('should return `List`', () => {
         const value = new ObservableList<number>();
-        expect(value.type).to.equal('List');
+        expect(value.type).toBe('List');
       });
     });
 
@@ -37,32 +36,32 @@ describe('@jupyterlab/observables', () => {
           called = true;
         });
         value.insert(0, 1);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
 
       it('should have value changed args', () => {
         let called = false;
         const value = new ObservableList<number>();
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('add');
-          expect(args.newIndex).to.equal(0);
-          expect(args.oldIndex).to.equal(-1);
-          expect(args.newValues[0]).to.equal(1);
-          expect(args.oldValues.length).to.equal(0);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('add');
+          expect(args.newIndex).toBe(0);
+          expect(args.oldIndex).toBe(-1);
+          expect(args.newValues[0]).toBe(1);
+          expect(args.oldValues.length).toBe(0);
           called = true;
         });
         value.push(1);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
     describe('#isDisposed', () => {
       it('should test whether the list is disposed', () => {
         const value = new ObservableList<number>();
-        expect(value.isDisposed).to.equal(false);
+        expect(value.isDisposed).toBe(false);
         value.dispose();
-        expect(value.isDisposed).to.equal(true);
+        expect(value.isDisposed).toBe(true);
       });
     });
 
@@ -70,14 +69,14 @@ describe('@jupyterlab/observables', () => {
       it('should dispose of the resources held by the list', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.dispose();
-        expect(value.isDisposed).to.equal(true);
+        expect(value.isDisposed).toBe(true);
       });
     });
 
     describe('#get()', () => {
       it('should get the value at the specified index', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
-        expect(value.get(1)).to.equal(2);
+        expect(value.get(1)).toBe(2);
       });
     });
 
@@ -85,23 +84,23 @@ describe('@jupyterlab/observables', () => {
       it('should set the item at a specific index', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.set(1, 4);
-        expect(toArray(value)).to.deep.equal([1, 4, 3]);
+        expect(toArray(value)).toEqual([1, 4, 3]);
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('set');
-          expect(args.newIndex).to.equal(1);
-          expect(args.oldIndex).to.equal(1);
-          expect(args.oldValues[0]).to.equal(2);
-          expect(args.newValues[0]).to.equal(4);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('set');
+          expect(args.newIndex).toBe(1);
+          expect(args.oldIndex).toBe(1);
+          expect(args.oldValues[0]).toBe(2);
+          expect(args.newValues[0]).toBe(4);
           called = true;
         });
         value.set(1, 4);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -109,28 +108,28 @@ describe('@jupyterlab/observables', () => {
       it('should add an item to the end of the list', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.push(4);
-        expect(toArray(value)).to.deep.equal([1, 2, 3, 4]);
+        expect(toArray(value)).toEqual([1, 2, 3, 4]);
       });
 
       it('should return the new length of the list', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
-        expect(value.push(4)).to.equal(4);
+        expect(value.push(4)).toBe(4);
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('add');
-          expect(args.newIndex).to.equal(3);
-          expect(args.oldIndex).to.equal(-1);
-          expect(args.oldValues.length).to.equal(0);
-          expect(args.newValues[0]).to.equal(4);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('add');
+          expect(args.newIndex).toBe(3);
+          expect(args.oldIndex).toBe(-1);
+          expect(args.oldValues.length).toBe(0);
+          expect(args.newValues[0]).toBe(4);
           called = true;
         });
         value.push(4);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -138,23 +137,23 @@ describe('@jupyterlab/observables', () => {
       it('should insert an item into the list at a specific index', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.insert(1, 4);
-        expect(toArray(value)).to.deep.equal([1, 4, 2, 3]);
+        expect(toArray(value)).toEqual([1, 4, 2, 3]);
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('add');
-          expect(args.newIndex).to.equal(1);
-          expect(args.oldIndex).to.equal(-1);
-          expect(args.oldValues.length).to.equal(0);
-          expect(args.newValues[0]).to.equal(4);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('add');
+          expect(args.newIndex).toBe(1);
+          expect(args.oldIndex).toBe(-1);
+          expect(args.oldValues.length).toBe(0);
+          expect(args.newValues[0]).toBe(4);
           called = true;
         });
         value.insert(1, 4);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -162,9 +161,9 @@ describe('@jupyterlab/observables', () => {
       it('should move an item from one index to another', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.move(1, 2);
-        expect(toArray(value)).to.deep.equal([1, 3, 2]);
+        expect(toArray(value)).toEqual([1, 3, 2]);
         value.move(2, 0);
-        expect(toArray(value)).to.deep.equal([2, 1, 3]);
+        expect(toArray(value)).toEqual([2, 1, 3]);
       });
 
       it('should trigger a changed signal', () => {
@@ -172,16 +171,16 @@ describe('@jupyterlab/observables', () => {
         const values = [1, 2, 3, 4, 5, 6];
         const value = new ObservableList<number>({ values });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('move');
-          expect(args.newIndex).to.equal(1);
-          expect(args.oldIndex).to.equal(0);
-          expect(args.oldValues[0]).to.equal(1);
-          expect(args.newValues[0]).to.equal(1);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('move');
+          expect(args.newIndex).toBe(1);
+          expect(args.oldIndex).toBe(0);
+          expect(args.oldValues[0]).toBe(1);
+          expect(args.newValues[0]).toBe(1);
           called = true;
         });
         value.move(0, 1);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -189,17 +188,17 @@ describe('@jupyterlab/observables', () => {
       it('should remove the first occurrence of a specific item from the list', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.removeValue(1);
-        expect(toArray(value)).to.deep.equal([2, 3]);
+        expect(toArray(value)).toEqual([2, 3]);
       });
 
       it('should return the index occupied by the item', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
-        expect(value.removeValue(1)).to.equal(0);
+        expect(value.removeValue(1)).toBe(0);
       });
 
       it('should return `-1` if the item is not in the list', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
-        expect(value.removeValue(10)).to.equal(-1);
+        expect(value.removeValue(10)).toBe(-1);
       });
 
       it('should trigger a changed signal', () => {
@@ -207,16 +206,16 @@ describe('@jupyterlab/observables', () => {
         const values = [1, 2, 3, 4, 5, 6];
         const value = new ObservableList<number>({ values });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('remove');
-          expect(args.newIndex).to.equal(-1);
-          expect(args.oldIndex).to.equal(1);
-          expect(args.oldValues[0]).to.equal(2);
-          expect(args.newValues.length).to.equal(0);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('remove');
+          expect(args.newIndex).toBe(-1);
+          expect(args.oldIndex).toBe(1);
+          expect(args.oldValues[0]).toBe(2);
+          expect(args.newValues.length).toBe(0);
           called = true;
         });
         value.removeValue(2);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -224,17 +223,17 @@ describe('@jupyterlab/observables', () => {
       it('should remove the item at a specific index', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.remove(1);
-        expect(toArray(value)).to.deep.equal([1, 3]);
+        expect(toArray(value)).toEqual([1, 3]);
       });
 
       it('should return the item at the specified index', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
-        expect(value.remove(1)).to.equal(2);
+        expect(value.remove(1)).toBe(2);
       });
 
       it('should return `undefined` if the index is out of range', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
-        expect(value.remove(10)).to.be.undefined;
+        expect(value.remove(10)).toBeUndefined();
       });
 
       it('should trigger a changed signal', () => {
@@ -242,16 +241,16 @@ describe('@jupyterlab/observables', () => {
         const values = [1, 2, 3, 4, 5, 6];
         const value = new ObservableList<number>({ values });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('remove');
-          expect(args.newIndex).to.equal(-1);
-          expect(args.oldIndex).to.equal(1);
-          expect(args.oldValues[0]).to.equal(2);
-          expect(args.newValues.length).to.equal(0);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('remove');
+          expect(args.newIndex).toBe(-1);
+          expect(args.oldIndex).toBe(1);
+          expect(args.oldValues[0]).toBe(2);
+          expect(args.newValues.length).toBe(0);
           called = true;
         });
         value.remove(1);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -260,9 +259,9 @@ describe('@jupyterlab/observables', () => {
         const values = [1, 2, 3, 4, 5, 6];
         const value = new ObservableList<number>({ values });
         value.clear();
-        expect(value.length).to.equal(0);
+        expect(value.length).toBe(0);
         value.clear();
-        expect(value.length).to.equal(0);
+        expect(value.length).toBe(0);
       });
 
       it('should trigger a changed signal', () => {
@@ -270,16 +269,16 @@ describe('@jupyterlab/observables', () => {
         const values = [1, 2, 3, 4, 5, 6];
         const value = new ObservableList<number>({ values });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('remove');
-          expect(args.newIndex).to.equal(0);
-          expect(args.oldIndex).to.equal(0);
-          expect(toArray(args.oldValues)).to.deep.equal(values);
-          expect(args.newValues.length).to.equal(0);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('remove');
+          expect(args.newIndex).toBe(0);
+          expect(args.oldIndex).toBe(0);
+          expect(toArray(args.oldValues)).toEqual(values);
+          expect(args.newValues.length).toBe(0);
           called = true;
         });
         value.clear();
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -287,28 +286,28 @@ describe('@jupyterlab/observables', () => {
       it('should push an array of items to the end of the list', () => {
         const value = new ObservableList<number>({ values: [1] });
         value.pushAll([2, 3, 4]);
-        expect(toArray(value)).to.deep.equal([1, 2, 3, 4]);
+        expect(toArray(value)).toEqual([1, 2, 3, 4]);
       });
 
       it('should return the new length of the list', () => {
         const value = new ObservableList<number>({ values: [1] });
-        expect(value.pushAll([2, 3, 4])).to.equal(4);
+        expect(value.pushAll([2, 3, 4])).toBe(4);
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('add');
-          expect(args.newIndex).to.equal(3);
-          expect(args.oldIndex).to.equal(-1);
-          expect(toArray(args.newValues)).to.deep.equal([4, 5, 6]);
-          expect(args.oldValues.length).to.equal(0);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('add');
+          expect(args.newIndex).toBe(3);
+          expect(args.oldIndex).toBe(-1);
+          expect(toArray(args.newValues)).toEqual([4, 5, 6]);
+          expect(args.oldValues.length).toBe(0);
           called = true;
         });
         value.pushAll([4, 5, 6]);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -316,23 +315,23 @@ describe('@jupyterlab/observables', () => {
       it('should push an array of items into a list', () => {
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.insertAll(1, [2, 3, 4]);
-        expect(toArray(value)).to.deep.equal([1, 2, 3, 4, 2, 3]);
+        expect(toArray(value)).toEqual([1, 2, 3, 4, 2, 3]);
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableList<number>({ values: [1, 2, 3] });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('add');
-          expect(args.newIndex).to.equal(1);
-          expect(args.oldIndex).to.equal(-1);
-          expect(toArray(args.newValues)).to.deep.equal([4, 5, 6]);
-          expect(args.oldValues.length).to.equal(0);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('add');
+          expect(args.newIndex).toBe(1);
+          expect(args.oldIndex).toBe(-1);
+          expect(toArray(args.newValues)).toEqual([4, 5, 6]);
+          expect(args.oldValues.length).toBe(0);
           called = true;
         });
         value.insertAll(1, [4, 5, 6]);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -341,13 +340,13 @@ describe('@jupyterlab/observables', () => {
         const values = [1, 2, 3, 4, 5, 6];
         const value = new ObservableList<number>({ values });
         value.removeRange(1, 3);
-        expect(toArray(value)).to.deep.equal([1, 4, 5, 6]);
+        expect(toArray(value)).toEqual([1, 4, 5, 6]);
       });
 
       it('should return the new length of the list', () => {
         const values = [1, 2, 3, 4, 5, 6];
         const value = new ObservableList<number>({ values });
-        expect(value.removeRange(1, 3)).to.equal(4);
+        expect(value.removeRange(1, 3)).toBe(4);
       });
 
       it('should trigger a changed signal', () => {
@@ -355,16 +354,16 @@ describe('@jupyterlab/observables', () => {
         const values = [1, 2, 3, 4];
         const value = new ObservableList<number>({ values });
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('remove');
-          expect(args.newIndex).to.equal(-1);
-          expect(args.oldIndex).to.equal(1);
-          expect(toArray(args.oldValues)).to.deep.equal([2, 3]);
-          expect(args.newValues.length).to.equal(0);
+          expect(sender).toBe(value);
+          expect(args.type).toBe('remove');
+          expect(args.newIndex).toBe(-1);
+          expect(args.oldIndex).toBe(1);
+          expect(toArray(args.oldValues)).toEqual([2, 3]);
+          expect(args.newValues.length).toBe(0);
           called = true;
         });
         value.removeRange(1, 3);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
   });

+ 52 - 53
tests/test-observables/src/observablemap.spec.ts → packages/observables/test/observablemap.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 { ObservableMap } from '@jupyterlab/observables';
 
@@ -10,14 +9,14 @@ describe('@jupyterlab/observables', () => {
     describe('#constructor()', () => {
       it('should accept no arguments', () => {
         const value = new ObservableMap<number>();
-        expect(value instanceof ObservableMap).to.equal(true);
+        expect(value instanceof ObservableMap).toBe(true);
       });
     });
 
     describe('#type', () => {
       it('should return `Map`', () => {
         const value = new ObservableMap<number>();
-        expect(value.type).to.equal('Map');
+        expect(value.type).toBe('Map');
       });
     });
 
@@ -26,7 +25,7 @@ describe('@jupyterlab/observables', () => {
         const value = new ObservableMap<number>();
         value.set('one', 1);
         value.set('two', 2);
-        expect(value.size).to.equal(2);
+        expect(value.size).toBe(2);
       });
     });
 
@@ -38,31 +37,31 @@ describe('@jupyterlab/observables', () => {
           called = true;
         });
         value.set('entry', 1);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
 
       it('should have value changed args', () => {
         let called = false;
         const value = new ObservableMap<number>();
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('add');
-          expect(args.newValue).to.equal(0);
-          expect(args.oldValue).to.be.undefined;
-          expect(args.key).to.equal('entry');
+          expect(sender).toBe(value);
+          expect(args.type).toBe('add');
+          expect(args.newValue).toBe(0);
+          expect(args.oldValue).toBeUndefined();
+          expect(args.key).toBe('entry');
           called = true;
         });
         value.set('entry', 0);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
     describe('#isDisposed', () => {
       it('should test whether the map is disposed', () => {
         const value = new ObservableMap<number>();
-        expect(value.isDisposed).to.equal(false);
+        expect(value.isDisposed).toBe(false);
         value.dispose();
-        expect(value.isDisposed).to.equal(true);
+        expect(value.isDisposed).toBe(true);
       });
     });
 
@@ -72,7 +71,7 @@ describe('@jupyterlab/observables', () => {
         value.set('one', 1);
         value.set('two', 2);
         value.dispose();
-        expect(value.isDisposed).to.equal(true);
+        expect(value.isDisposed).toBe(true);
       });
     });
 
@@ -80,29 +79,29 @@ describe('@jupyterlab/observables', () => {
       it('should set the item at a specific key', () => {
         const value = new ObservableMap<number>();
         value.set('one', 1);
-        expect(value.get('one')).to.equal(1);
+        expect(value.get('one')).toBe(1);
       });
 
       it('should return the old value for that key', () => {
         const value = new ObservableMap<number>();
         value.set('one', 1);
         const x = value.set('one', 1.01);
-        expect(x).to.equal(1);
+        expect(x).toBe(1);
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableMap<number>();
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('add');
-          expect(args.newValue).to.equal(1);
-          expect(args.oldValue).to.be.undefined;
-          expect(args.key).to.equal('one');
+          expect(sender).toBe(value);
+          expect(args.type).toBe('add');
+          expect(args.newValue).toBe(1);
+          expect(args.oldValue).toBeUndefined();
+          expect(args.key).toBe('one');
           called = true;
         });
         value.set('one', 1);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -110,13 +109,13 @@ describe('@jupyterlab/observables', () => {
       it('should get the value for a key', () => {
         const value = new ObservableMap<number>();
         value.set('one', 1);
-        expect(value.get('one')).to.equal(1);
+        expect(value.get('one')).toBe(1);
       });
 
       it('should return undefined if the key does not exist', () => {
         const value = new ObservableMap<number>();
         value.set('one', 1);
-        expect(value.get('two')).to.be.undefined;
+        expect(value.get('two')).toBeUndefined();
       });
     });
 
@@ -124,8 +123,8 @@ describe('@jupyterlab/observables', () => {
       it('should whether the key exists in a map', () => {
         const value = new ObservableMap<number>();
         value.set('one', 1);
-        expect(value.has('one')).to.equal(true);
-        expect(value.has('two')).to.equal(false);
+        expect(value.has('one')).toBe(true);
+        expect(value.has('two')).toBe(false);
       });
     });
 
@@ -136,7 +135,7 @@ describe('@jupyterlab/observables', () => {
         value.set('two', 2);
         value.set('three', 3);
         const keys = value.keys();
-        expect(keys).to.deep.equal(['one', 'two', 'three']);
+        expect(keys).toEqual(['one', 'two', 'three']);
       });
     });
 
@@ -147,7 +146,7 @@ describe('@jupyterlab/observables', () => {
         value.set('two', 2);
         value.set('three', 3);
         const keys = value.values();
-        expect(keys).to.deep.equal([1, 2, 3]);
+        expect(keys).toEqual([1, 2, 3]);
       });
     });
 
@@ -157,16 +156,16 @@ describe('@jupyterlab/observables', () => {
         value.set('one', 1);
         value.set('two', 2);
         value.set('three', 3);
-        expect(value.get('two')).to.equal(2);
+        expect(value.get('two')).toBe(2);
         value.delete('two');
-        expect(value.get('two')).to.be.undefined;
+        expect(value.get('two')).toBeUndefined();
       });
 
       it('should return the value of the key it removed', () => {
         const value = new ObservableMap<number>();
         value.set('one', 1);
-        expect(value.delete('one')).to.equal(1);
-        expect(value.delete('one')).to.be.undefined;
+        expect(value.delete('one')).toBe(1);
+        expect(value.delete('one')).toBeUndefined();
       });
 
       it('should trigger a changed signal if actually removed', () => {
@@ -177,15 +176,15 @@ describe('@jupyterlab/observables', () => {
         let called = false;
 
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('remove');
-          expect(args.key).to.equal('two');
-          expect(args.oldValue).to.equal(2);
-          expect(args.newValue).to.be.undefined;
+          expect(sender).toBe(value);
+          expect(args.type).toBe('remove');
+          expect(args.key).toBe('two');
+          expect(args.oldValue).toBe(2);
+          expect(args.newValue).toBeUndefined();
           called = true;
         });
         value.delete('two');
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
 
       it('should not trigger a changed signal if not actually removed', () => {
@@ -195,17 +194,17 @@ describe('@jupyterlab/observables', () => {
         let called = false;
 
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('remove');
-          expect(args.key).to.equal('two');
-          expect(args.oldValue).to.equal(2);
-          expect(args.newValue).to.be.undefined;
+          expect(sender).toBe(value);
+          expect(args.type).toBe('remove');
+          expect(args.key).toBe('two');
+          expect(args.oldValue).toBe(2);
+          expect(args.newValue).toBeUndefined();
           called = true;
         });
 
         // 'two' is not in the map
         value.delete('two');
-        expect(called).to.equal(false);
+        expect(called).toBe(false);
       });
     });
 
@@ -216,9 +215,9 @@ describe('@jupyterlab/observables', () => {
         value.set('two', 2);
         value.set('three', 3);
         value.clear();
-        expect(value.size).to.equal(0);
+        expect(value.size).toBe(0);
         value.clear();
-        expect(value.size).to.equal(0);
+        expect(value.size).toBe(0);
       });
 
       it('should trigger a changed signal', () => {
@@ -226,15 +225,15 @@ describe('@jupyterlab/observables', () => {
         value.set('one', 1);
         let called = false;
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('remove');
-          expect(args.key).to.equal('one');
-          expect(args.oldValue).to.equal(1);
-          expect(args.newValue).to.be.undefined;
+          expect(sender).toBe(value);
+          expect(args.type).toBe('remove');
+          expect(args.key).toBe('one');
+          expect(args.oldValue).toBe(1);
+          expect(args.newValue).toBeUndefined();
           called = true;
         });
         value.clear();
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
   });

+ 43 - 44
tests/test-observables/src/observablestring.spec.ts → packages/observables/test/observablestring.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 { ObservableString } from '@jupyterlab/observables';
 
@@ -10,24 +9,24 @@ describe('@jupyterlab/observables', () => {
     describe('#constructor()', () => {
       it('should accept no arguments', () => {
         const value = new ObservableString();
-        expect(value instanceof ObservableString).to.equal(true);
+        expect(value instanceof ObservableString).toBe(true);
       });
 
       it('should accept a string argument', () => {
         const value = new ObservableString('hello');
-        expect(value instanceof ObservableString).to.equal(true);
+        expect(value instanceof ObservableString).toBe(true);
       });
 
       it('should initialize the string value', () => {
         const value = new ObservableString('hello');
-        expect(value.text).to.deep.equal('hello');
+        expect(value.text).toEqual('hello');
       });
     });
 
     describe('#type', () => {
       it('should return `String`', () => {
         const value = new ObservableString();
-        expect(value.type).to.equal('String');
+        expect(value.type).toBe('String');
       });
     });
 
@@ -39,31 +38,31 @@ describe('@jupyterlab/observables', () => {
           called = true;
         });
         value.text = 'change';
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
 
       it('should have value changed args', () => {
         let called = false;
         const value = new ObservableString();
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('set');
-          expect(args.start).to.equal(0);
-          expect(args.end).to.equal(3);
-          expect(args.value).to.equal('new');
+          expect(sender).toBe(value);
+          expect(args.type).toBe('set');
+          expect(args.start).toBe(0);
+          expect(args.end).toBe(3);
+          expect(args.value).toBe('new');
           called = true;
         });
         value.text = 'new';
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
     describe('#isDisposed', () => {
       it('should test whether the string is disposed', () => {
         const value = new ObservableString();
-        expect(value.isDisposed).to.equal(false);
+        expect(value.isDisposed).toBe(false);
         value.dispose();
-        expect(value.isDisposed).to.equal(true);
+        expect(value.isDisposed).toBe(true);
       });
     });
 
@@ -71,22 +70,22 @@ describe('@jupyterlab/observables', () => {
       it('should set the item at a specific index', () => {
         const value = new ObservableString('old');
         value.text = 'new';
-        expect(value.text).to.deep.equal('new');
+        expect(value.text).toEqual('new');
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableString('old');
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('set');
-          expect(args.start).to.equal(0);
-          expect(args.end).to.equal(3);
-          expect(args.value).to.equal('new');
+          expect(sender).toBe(value);
+          expect(args.type).toBe('set');
+          expect(args.start).toBe(0);
+          expect(args.end).toBe(3);
+          expect(args.value).toBe('new');
           called = true;
         });
         value.text = 'new';
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -94,22 +93,22 @@ describe('@jupyterlab/observables', () => {
       it('should insert an substring into the string at a specific index', () => {
         const value = new ObservableString('one three');
         value.insert(4, 'two ');
-        expect(value.text).to.deep.equal('one two three');
+        expect(value.text).toEqual('one two three');
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableString('one three');
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('insert');
-          expect(args.start).to.equal(4);
-          expect(args.end).to.equal(8);
-          expect(args.value).to.equal('two ');
+          expect(sender).toBe(value);
+          expect(args.type).toBe('insert');
+          expect(args.start).toBe(4);
+          expect(args.end).toBe(8);
+          expect(args.value).toBe('two ');
           called = true;
         });
         value.insert(4, 'two ');
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -117,22 +116,22 @@ describe('@jupyterlab/observables', () => {
       it('should remove a substring from the string', () => {
         const value = new ObservableString('one two two three');
         value.remove(4, 8);
-        expect(value.text).to.deep.equal('one two three');
+        expect(value.text).toEqual('one two three');
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableString('one two two three');
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('remove');
-          expect(args.start).to.equal(4);
-          expect(args.end).to.equal(8);
-          expect(args.value).to.equal('two ');
+          expect(sender).toBe(value);
+          expect(args.type).toBe('remove');
+          expect(args.start).toBe(4);
+          expect(args.end).toBe(8);
+          expect(args.value).toBe('two ');
           called = true;
         });
         value.remove(4, 8);
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
 
@@ -140,23 +139,23 @@ describe('@jupyterlab/observables', () => {
       it('should empty the string', () => {
         const value = new ObservableString('full');
         value.clear();
-        expect(value.text.length).to.equal(0);
-        expect(value.text).to.equal('');
+        expect(value.text.length).toBe(0);
+        expect(value.text).toBe('');
       });
 
       it('should trigger a changed signal', () => {
         let called = false;
         const value = new ObservableString('full');
         value.changed.connect((sender, args) => {
-          expect(sender).to.equal(value);
-          expect(args.type).to.equal('set');
-          expect(args.start).to.equal(0);
-          expect(args.end).to.equal(0);
-          expect(args.value).to.equal('');
+          expect(sender).toBe(value);
+          expect(args.type).toBe('set');
+          expect(args.start).toBe(0);
+          expect(args.end).toBe(0);
+          expect(args.value).toBe('');
           called = true;
         });
         value.clear();
-        expect(called).to.equal(true);
+        expect(called).toBe(true);
       });
     });
   });

+ 24 - 29
tests/test-observables/src/undoablelist.spec.ts → packages/observables/test/undoablelist.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 { JSONObject } from '@lumino/coreutils';
 
@@ -40,34 +39,34 @@ describe('@jupyterlab/observables', () => {
     describe('#constructor', () => {
       it('should create a new ObservableUndoableList', () => {
         const list = new ObservableUndoableList(serializer);
-        expect(list).to.be.an.instanceof(ObservableUndoableList);
+        expect(list).toBeInstanceOf(ObservableUndoableList);
       });
     });
 
     describe('#canRedo', () => {
       it('should return false if there is no history', () => {
         const list = new ObservableUndoableList(serializer);
-        expect(list.canRedo).to.equal(false);
+        expect(list.canRedo).toBe(false);
       });
 
       it('should return true if there is an undo that can be redone', () => {
         const list = new ObservableUndoableList(serializer);
         list.push(new Test(value));
         list.undo();
-        expect(list.canRedo).to.equal(true);
+        expect(list.canRedo).toBe(true);
       });
     });
 
     describe('#canUndo', () => {
       it('should return false if there is no history', () => {
         const list = new ObservableUndoableList(serializer);
-        expect(list.canUndo).to.equal(false);
+        expect(list.canUndo).toBe(false);
       });
 
       it('should return true if there is a change that can be undone', () => {
         const list = new ObservableUndoableList(serializer);
         list.push(serializer.fromJSON(value));
-        expect(list.canUndo).to.equal(true);
+        expect(list.canUndo).toBe(true);
       });
     });
 
@@ -75,9 +74,9 @@ describe('@jupyterlab/observables', () => {
       it('should dispose of the resources used by the list', () => {
         const list = new ObservableUndoableList(serializer);
         list.dispose();
-        expect(list.isDisposed).to.equal(true);
+        expect(list.isDisposed).toBe(true);
         list.dispose();
-        expect(list.isDisposed).to.equal(true);
+        expect(list.isDisposed).toBe(true);
       });
     });
 
@@ -88,9 +87,9 @@ describe('@jupyterlab/observables', () => {
         list.push(serializer.fromJSON(value));
         list.push(serializer.fromJSON(value));
         list.endCompoundOperation();
-        expect(list.canUndo).to.equal(true);
+        expect(list.canUndo).toBe(true);
         list.undo();
-        expect(list.canUndo).to.equal(false);
+        expect(list.canUndo).toBe(false);
       });
 
       it('should not be undoable if isUndoAble is set to false', () => {
@@ -99,7 +98,7 @@ describe('@jupyterlab/observables', () => {
         list.push(serializer.fromJSON(value));
         list.push(serializer.fromJSON(value));
         list.endCompoundOperation();
-        expect(list.canUndo).to.equal(false);
+        expect(list.canUndo).toBe(false);
       });
     });
 
@@ -110,9 +109,9 @@ describe('@jupyterlab/observables', () => {
         list.push(serializer.fromJSON(value));
         list.push(serializer.fromJSON(value));
         list.endCompoundOperation();
-        expect(list.canUndo).to.equal(true);
+        expect(list.canUndo).toBe(true);
         list.undo();
-        expect(list.canUndo).to.equal(false);
+        expect(list.canUndo).toBe(false);
       });
     });
 
@@ -121,14 +120,14 @@ describe('@jupyterlab/observables', () => {
         const list = new ObservableUndoableList(serializer);
         list.push(serializer.fromJSON(value));
         list.undo();
-        expect(list.length).to.equal(0);
+        expect(list.length).toBe(0);
       });
 
       it('should undo a pushAll', () => {
         const list = new ObservableUndoableList(serializer);
         list.pushAll([serializer.fromJSON(value), serializer.fromJSON(value)]);
         list.undo();
-        expect(list.length).to.equal(0);
+        expect(list.length).toBe(0);
       });
 
       it('should undo a remove', () => {
@@ -136,7 +135,7 @@ describe('@jupyterlab/observables', () => {
         list.pushAll([serializer.fromJSON(value), serializer.fromJSON(value)]);
         list.remove(0);
         list.undo();
-        expect(list.length).to.equal(2);
+        expect(list.length).toBe(2);
       });
 
       it('should undo a removeRange', () => {
@@ -151,7 +150,7 @@ describe('@jupyterlab/observables', () => {
         ]);
         list.removeRange(1, 3);
         list.undo();
-        expect(list.length).to.equal(6);
+        expect(list.length).toBe(6);
       });
 
       it('should undo a move', () => {
@@ -164,9 +163,7 @@ describe('@jupyterlab/observables', () => {
         list.pushAll(items);
         list.move(1, 2);
         list.undo();
-        expect((list.get(1) as any)['count']).to.equal(
-          (items[1] as any)['count']
-        );
+        expect((list.get(1) as any)['count']).toBe((items[1] as any)['count']);
       });
     });
 
@@ -176,7 +173,7 @@ describe('@jupyterlab/observables', () => {
         list.push(serializer.fromJSON(value));
         list.undo();
         list.redo();
-        expect(list.length).to.equal(1);
+        expect(list.length).toBe(1);
       });
 
       it('should redo a pushAll', () => {
@@ -184,7 +181,7 @@ describe('@jupyterlab/observables', () => {
         list.pushAll([serializer.fromJSON(value), serializer.fromJSON(value)]);
         list.undo();
         list.redo();
-        expect(list.length).to.equal(2);
+        expect(list.length).toBe(2);
       });
 
       it('should redo a remove', () => {
@@ -193,7 +190,7 @@ describe('@jupyterlab/observables', () => {
         list.remove(0);
         list.undo();
         list.redo();
-        expect(list.length).to.equal(1);
+        expect(list.length).toBe(1);
       });
 
       it('should redo a removeRange', () => {
@@ -209,7 +206,7 @@ describe('@jupyterlab/observables', () => {
         list.removeRange(1, 3);
         list.undo();
         list.redo();
-        expect(list.length).to.equal(4);
+        expect(list.length).toBe(4);
       });
 
       it('should undo a move', () => {
@@ -223,9 +220,7 @@ describe('@jupyterlab/observables', () => {
         list.move(1, 2);
         list.undo();
         list.redo();
-        expect((list.get(2) as any)['count']).to.equal(
-          (items[1] as any)['count']
-        );
+        expect((list.get(2) as any)['count']).toBe((items[1] as any)['count']);
       });
     });
 
@@ -234,7 +229,7 @@ describe('@jupyterlab/observables', () => {
         const list = new ObservableUndoableList(serializer);
         list.push(serializer.fromJSON(value));
         list.clearUndo();
-        expect(list.canUndo).to.equal(false);
+        expect(list.canUndo).toBe(false);
       });
     });
   });

+ 9 - 0
packages/observables/tsconfig.test.json

@@ -0,0 +1,9 @@
+{
+  "extends": "../../tsconfigbase.test",
+  "include": ["src/*", "test/*"],
+  "references": [
+    {
+      "path": "../../testutils"
+    }
+  ]
+}

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

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

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

@@ -1,30 +0,0 @@
-{
-  "name": "@jupyterlab/test-observables",
-  "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/observables": "^3.1.0",
-    "@jupyterlab/testutils": "^2.1.0",
-    "@lumino/algorithm": "^1.2.3",
-    "@lumino/coreutils": "^1.4.2",
-    "chai": "^4.2.0",
-    "jest": "^25.2.3",
-    "jest-junit": "^10.0.0",
-    "ts-jest": "^25.2.1"
-  },
-  "devDependencies": {
-    "@types/chai": "^4.2.7",
-    "@types/jest": "^24.0.23",
-    "rimraf": "~3.0.0",
-    "typescript": "~3.7.3"
-  }
-}

+ 0 - 8
tests/test-observables/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-observables/tsconfig.json

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