Browse Source

Fix Typescript 2.0 errors in tests.

Typescript 2.0 intelligently determines that a property with only a getter is read-only, so our read-only tests turned into compile-time errors. Since our tests are also testing the behavior of the generated javascript code, we avoid the type-checking to make sure that the javascript code still has the correct behavior.
Jason Grout 8 years ago
parent
commit
222e15186e

+ 1 - 1
test/src/common/activitymonitor.spec.ts

@@ -170,7 +170,7 @@ describe('common/activitymonitor', () => {
 
       it('should be read-only', () => {
         let monitor = new ActivityMonitor<TestObject, number>({ signal });
-        expect(() => { monitor.isDisposed = false; }).to.throwError();
+        expect(() => { (monitor as any).isDisposed = false; }).to.throwError();
       });
 
     });

+ 1 - 1
test/src/common/observablelist.spec.ts

@@ -106,7 +106,7 @@ describe('common/observablelist', () => {
 
       it('should be read-only', () => {
         let list = new ObservableList<number>();
-        expect(() => { list.length = 2; }).to.throwError();
+        expect(() => { (list as any).length = 2; }).to.throwError();
       });
 
     });

+ 1 - 1
test/src/console/history.spec.ts

@@ -71,7 +71,7 @@ describe('console/history', () => {
 
       it('should be read-only', () => {
         let history = new ConsoleHistory();
-        expect(() => history.isDisposed = false).to.throwError();
+        expect(() => (history as any).isDisposed = false).to.throwError();
       });
 
     });

+ 11 - 11
test/src/docregistry/default.spec.ts

@@ -44,7 +44,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let factory = new WidgetFactory();
-        expect(() => { factory.isDisposed = false; }).to.throwError();
+        expect(() => { (factory as any).isDisposed = false; }).to.throwError();
       });
 
     });
@@ -91,7 +91,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let factory = new Base64ModelFactory();
-        expect(() => { factory.name = ''; }).to.throwError();
+        expect(() => { (factory as any).name = ''; }).to.throwError();
       });
 
     });
@@ -105,7 +105,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let factory = new Base64ModelFactory();
-        expect(() => { factory.fileType = 'file'; }).to.throwError();
+        expect(() => { (factory as any).fileType = 'file'; }).to.throwError();
       });
 
     });
@@ -119,7 +119,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let factory = new Base64ModelFactory();
-        expect(() => { factory.fileFormat = 'base64'; }).to.throwError();
+        expect(() => { (factory as any).fileFormat = 'base64'; }).to.throwError();
       });
 
     });
@@ -153,7 +153,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let model = new DocumentModel();
-        expect(() => { model.isDisposed = false; }).to.throwError();
+        expect(() => { (model as any).isDisposed = false; }).to.throwError();
       });
 
     });
@@ -279,7 +279,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let model = new DocumentModel();
-        expect(() => { model.defaultKernelName = ''; }).to.throwError();
+        expect(() => { (model as any).defaultKernelName = ''; }).to.throwError();
       });
 
     });
@@ -298,7 +298,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let model = new DocumentModel();
-        expect(() => { model.defaultKernelLanguage = ''; }).to.throwError();
+        expect(() => { (model as any).defaultKernelLanguage = ''; }).to.throwError();
       });
 
     });
@@ -371,7 +371,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let factory = new TextModelFactory();
-        expect(() => { factory.name = ''; }).to.throwError();
+        expect(() => { (factory as any).name = ''; }).to.throwError();
       });
 
     });
@@ -385,7 +385,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let factory = new TextModelFactory();
-        expect(() => { factory.fileType = 'file'; }).to.throwError();
+        expect(() => { (factory as any).fileType = 'file'; }).to.throwError();
       });
 
     });
@@ -399,7 +399,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let factory = new TextModelFactory();
-        expect(() => { factory.fileFormat = 'text'; }).to.throwError();
+        expect(() => { (factory as any).fileFormat = 'text'; }).to.throwError();
       });
 
     });
@@ -415,7 +415,7 @@ describe('docmanager/default', () => {
 
       it('should be read-only', () => {
         let factory = new TextModelFactory();
-        expect(() => { factory.isDisposed = false; }).to.throwError();
+        expect(() => { (factory as any).isDisposed = false; }).to.throwError();
       });
 
     });

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

@@ -60,7 +60,7 @@ describe('docregistry/registry', () => {
       });
 
       it('should be read-only', () => {
-        expect(() => { registry.isDisposed = false; }).to.throwError();
+        expect(() => { (registry as any).isDisposed = false; }).to.throwError();
       });
 
     });

+ 1 - 1
test/src/notebook/cells/widget.spec.ts

@@ -245,7 +245,7 @@ describe('notebook/cells/widget', () => {
         let widget = new BaseCellWidget({
           renderer: CodeMirrorCodeCellWidgetRenderer.defaultRenderer
         });
-        expect(() => { widget.editor = null; }).to.throwError();
+        expect(() => { (widget as any).editor = null; }).to.throwError();
       });
 
     });

+ 6 - 6
test/src/notebook/notebook/model.spec.ts

@@ -121,7 +121,7 @@ describe('notebook/notebook/model', () => {
 
       it('should be read-only', () => {
         let model = new NotebookModel();
-        expect(() => { model.cells = null; }).to.throwError();
+        expect(() => { (model as any).cells = null; }).to.throwError();
       });
 
       context('cells `changed` signal', () => {
@@ -204,7 +204,7 @@ describe('notebook/notebook/model', () => {
 
       it('should be read-only', () => {
         let model = new NotebookModel();
-        expect(() => { model.factory = null; }).to.throwError();
+        expect(() => { (model as any).factory = null; }).to.throwError();
       });
 
       context('createCodeCell()', () => {
@@ -297,7 +297,7 @@ describe('notebook/notebook/model', () => {
 
       it('should be read-only', () => {
         let model = new NotebookModel();
-        expect(() => { model.nbformat = 0; }).to.throwError();
+        expect(() => { (model as any).nbformat = 0; }).to.throwError();
       });
 
     });
@@ -312,7 +312,7 @@ describe('notebook/notebook/model', () => {
 
       it('should be read-only', () => {
         let model = new NotebookModel();
-        expect(() => { model.nbformatMinor = 0; }).to.throwError();
+        expect(() => { (model as any).nbformatMinor = 0; }).to.throwError();
       });
 
     });
@@ -332,7 +332,7 @@ describe('notebook/notebook/model', () => {
 
       it('should be read-only', () => {
         let model = new NotebookModel();
-        expect(() => { model.defaultKernelName = ''; }).to.throwError();
+        expect(() => { (model as any).defaultKernelName = ''; }).to.throwError();
       });
 
     });
@@ -357,7 +357,7 @@ describe('notebook/notebook/model', () => {
 
       it('should be read-only', () => {
         let model = new NotebookModel();
-        expect(() => { model.defaultKernelLanguage = ''; }).to.throwError();
+        expect(() => { (model as any).defaultKernelLanguage = ''; }).to.throwError();
       });
 
     });

+ 4 - 4
test/src/notebook/notebook/modelfactory.spec.ts

@@ -25,7 +25,7 @@ describe('notebook/notebook/modelfactory', () => {
 
       it('should be read-only', () => {
         let factory = new NotebookModelFactory();
-        expect(() => { factory.name = ''; }).to.throwError();
+        expect(() => { (factory as any).name = ''; }).to.throwError();
       });
 
     });
@@ -39,7 +39,7 @@ describe('notebook/notebook/modelfactory', () => {
 
       it('should be read-only', () => {
         let factory = new NotebookModelFactory();
-        expect(() => { factory.fileType = 'notebook'; }).to.throwError();
+        expect(() => { (factory as any).fileType = 'notebook'; }).to.throwError();
       });
 
     });
@@ -53,7 +53,7 @@ describe('notebook/notebook/modelfactory', () => {
 
       it('should be read-only', () => {
         let factory = new NotebookModelFactory();
-        expect(() => { factory.fileFormat = 'json'; }).to.throwError();
+        expect(() => { (factory as any).fileFormat = 'json'; }).to.throwError();
       });
 
     });
@@ -69,7 +69,7 @@ describe('notebook/notebook/modelfactory', () => {
 
       it('should be read-only', () => {
         let factory = new NotebookModelFactory();
-        expect(() => { factory.isDisposed = false; }).to.throwError();
+        expect(() => { (factory as any).isDisposed = false; }).to.throwError();
       });
 
     });

+ 7 - 7
test/src/notebook/notebook/panel.spec.ts

@@ -174,7 +174,7 @@ describe('notebook/notebook/panel', () => {
 
       it('should be read-only', () => {
         let panel = new NotebookPanel({ rendermime, clipboard, renderer });
-        expect(() => { panel.toolbar = null; }).to.throwError();
+        expect(() => { (panel as any).toolbar = null; }).to.throwError();
       });
 
     });
@@ -188,7 +188,7 @@ describe('notebook/notebook/panel', () => {
 
       it('should be read-only', () => {
         let panel = new NotebookPanel({ rendermime, clipboard, renderer });
-        expect(() => { panel.content = null; }).to.throwError();
+        expect(() => { (panel as any).content = null; }).to.throwError();
       });
 
     });
@@ -204,7 +204,7 @@ describe('notebook/notebook/panel', () => {
 
       it('should be read-only', () => {
         let panel = new NotebookPanel({ rendermime, clipboard, renderer });
-        expect(() => { panel.kernel = null; }).to.throwError();
+        expect(() => { (panel as any).kernel = null; }).to.throwError();
       });
 
     });
@@ -218,7 +218,7 @@ describe('notebook/notebook/panel', () => {
 
       it('should be read-only', () => {
         let panel = new NotebookPanel({ rendermime, clipboard, renderer });
-        expect(() => { panel.rendermime = null; }).to.throwError();
+        expect(() => { (panel as any).rendermime = null; }).to.throwError();
       });
 
     });
@@ -233,7 +233,7 @@ describe('notebook/notebook/panel', () => {
 
       it('should be read-only', () => {
         let panel = new NotebookPanel({ rendermime, clipboard, renderer });
-        expect(() => { panel.renderer = null; });
+        expect(() => { (panel as any).renderer = null; });
       });
 
     });
@@ -247,7 +247,7 @@ describe('notebook/notebook/panel', () => {
 
       it('should be read-only', () => {
         let panel = new NotebookPanel({ rendermime, clipboard, renderer });
-        expect(() => { panel.clipboard = null; }).to.throwError();
+        expect(() => { (panel as any).clipboard = null; }).to.throwError();
       });
 
     });
@@ -266,7 +266,7 @@ describe('notebook/notebook/panel', () => {
 
       it('should be read-only', () => {
         let panel = new NotebookPanel({ rendermime, clipboard, renderer });
-        expect(() => { panel.model = null; }).to.throwError();
+        expect(() => { (panel as any).model = null; }).to.throwError();
       });
 
     });

+ 3 - 3
test/src/notebook/notebook/widget.spec.ts

@@ -335,7 +335,7 @@ describe('notebook/notebook/widget', () => {
 
       it('should be read-only', () => {
         let widget = createWidget();
-        expect(() => { widget.rendermime = null; }).to.throwError();
+        expect(() => { (widget as any).rendermime = null; }).to.throwError();
       });
 
     });
@@ -349,7 +349,7 @@ describe('notebook/notebook/widget', () => {
 
       it('should be read-only', () => {
         let widget = createWidget();
-        expect(() => { widget.renderer = null; }).to.throwError();
+        expect(() => { (widget as any).renderer = null; }).to.throwError();
       });
 
     });
@@ -815,7 +815,7 @@ describe('notebook/notebook/widget', () => {
 
       it('should be read-only', () => {
         let widget = createActiveWidget();
-        expect(() => { widget.activeCell = null; }).to.throwError();
+        expect(() => { (widget as any).activeCell = null; }).to.throwError();
       });
 
     });

+ 1 - 1
test/src/notebook/notebook/widgetfactory.spec.ts

@@ -61,7 +61,7 @@ describe('notebook/notebook/widgetfactory', () => {
 
       it('should be read-only', () => {
         let factory = new NotebookWidgetFactory(rendermime, clipboard, renderer);
-        expect(() => { factory.isDisposed = false; }).to.throwError();
+        expect(() => { (factory as any).isDisposed = false; }).to.throwError();
       });
 
     });

+ 2 - 2
test/src/notebook/output-area/model.spec.ts

@@ -113,7 +113,7 @@ describe('notebook/output-area/model', () => {
 
       it('should be read-only', () => {
         let model = new OutputAreaModel();
-        expect(() => { model.length = 0; }).to.throwError();
+        expect(() => { (model as any).length = 0; }).to.throwError();
       });
 
     });
@@ -129,7 +129,7 @@ describe('notebook/output-area/model', () => {
 
       it('should be read-only', () => {
         let model = new OutputAreaModel();
-        expect(() => { model.isDisposed = true; }).to.throwError();
+        expect(() => { (model as any).isDisposed = true; }).to.throwError();
       });
 
     });

+ 4 - 4
test/src/notebook/output-area/widget.spec.ts

@@ -190,7 +190,7 @@ describe('notebook/output-area/widget', () => {
 
       it('should be read-only', () => {
         let widget = new OutputAreaWidget({ rendermime });
-        expect(() => { widget.rendermime = null; }).to.throwError();
+        expect(() => { (widget as any).rendermime = null; }).to.throwError();
       });
 
     });
@@ -205,7 +205,7 @@ describe('notebook/output-area/widget', () => {
 
       it('should be read-only', () => {
         let widget = new OutputAreaWidget({ rendermime });
-        expect(() => { widget.renderer = null; }).to.throwError();
+        expect(() => { (widget as any).renderer = null; }).to.throwError();
       });
 
     });
@@ -395,7 +395,7 @@ describe('notebook/output-area/widget', () => {
 
       it('should be read-only', () => {
         let widget = new OutputWidget({ rendermime });
-        expect(() => { widget.prompt = null; }).to.throwError();
+        expect(() => { (widget as any).prompt = null; }).to.throwError();
       });
 
     });
@@ -409,7 +409,7 @@ describe('notebook/output-area/widget', () => {
 
       it('should be read-only', () => {
         let widget = new OutputWidget({ rendermime });
-        expect(() => { widget.output = null; }).to.throwError();
+        expect(() => { (widget as any).output = null; }).to.throwError();
       });
 
     });