浏览代码

Undo test changes

Steven Silvester 5 年之前
父节点
当前提交
28674ec7e5
共有 3 个文件被更改,包括 18 次插入8 次删除
  1. 2 1
      .eslintrc.js
  2. 5 3
      packages/application/test/layoutrestorer.spec.ts
  3. 11 4
      packages/filebrowser/test/model.spec.ts

+ 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(() => {