Browse Source

Undo test changes

Steven Silvester 5 years ago
parent
commit
28674ec7e5

+ 2 - 1
.eslintrc.js

@@ -46,7 +46,8 @@ module.exports = {
     'no-useless-escape': 'off',
     'prefer-const': 'off',
     'jest/no-jest-import': 'off',
-    'jest/no-export': 'warn'
+    'jest/no-export': 'warn',
+    'jest/no-try-expect': 'warn'
   },
   settings: {
     react: {

+ 5 - 3
packages/application/test/layoutrestorer.spec.ts

@@ -159,9 +159,11 @@ describe('apputils', () => {
           leftArea: { currentWidget: null, collapsed: true, widgets: null },
           rightArea: { collapsed: true, currentWidget: null, widgets: null }
         };
-        await expect(restorer.save(dehydrated)).rejects.toThrow(
-          'save() was called prematurely.'
-        );
+        try {
+          await restorer.save(dehydrated);
+        } catch (e) {
+          expect(e).toBe('save() was called prematurely.');
+        }
       });
 
       it('should save data', async () => {

+ 11 - 4
packages/filebrowser/test/model.spec.ts

@@ -350,7 +350,11 @@ describe('filebrowser/model', () => {
         expect(contents.name).toBe(fname);
         const promise = model.upload(file);
         await dismissDialog();
-        await expect(promise).rejects.toThrow('File not uploaded');
+        try {
+          await promise;
+        } catch (e) {
+          expect(e).toBe('File not uploaded');
+        }
       });
 
       it('should emit the fileChanged signal', async () => {
@@ -383,9 +387,12 @@ describe('filebrowser/model', () => {
         it('should not upload large file', async () => {
           const fname = UUID.uuid4() + '.html';
           const file = new File([new ArrayBuffer(LARGE_FILE_SIZE + 1)], fname);
-          await expect(model.upload(file)).rejects.toThrow(
-            `Cannot upload file (>15 MB). ${fname}`
-          );
+          try {
+            await model.upload(file);
+            throw new Error('Upload should have failed');
+          } catch (err) {
+            expect(err).toBe(`Cannot upload file (>15 MB). ${fname}`);
+          }
         });
 
         afterAll(() => {