Jelajahi Sumber

test: cleanup eslint jest rules and files

RedTn 4 tahun lalu
induk
melakukan
a656cda1b8

+ 0 - 4
.eslintrc.js

@@ -55,10 +55,6 @@ module.exports = {
     'no-case-declarations': 'warn',
     'no-useless-escape': 'off',
     'prefer-const': 'off',
-    'jest/no-jest-import': 'off',
-    'jest/no-export': 'warn',
-    'jest/no-try-expect': 'warn',
-    'jest/expect-expect': 'off',
     'react/prop-types': 'warn'
   },
   settings: {

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

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

+ 0 - 2
packages/apputils/test/commandpalette.spec.ts

@@ -1,6 +1,4 @@
 // Copyright (c) Jupyter Development Team.
-
-import 'jest';
 // Distributed under the terms of the Modified BSD License.
 
 // import { expect } from 'chai';

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

@@ -360,11 +360,8 @@ describe('filebrowser/model', () => {
         expect(contents.name).toBe(fname);
         const promise = model.upload(file);
         await dismissDialog();
-        try {
-          await promise;
-        } catch (e) {
-          expect(e).toBe('File not uploaded');
-        }
+
+        await expect(promise).rejects.toBe('File not uploaded');
       });
 
       it('should emit the fileChanged signal', async () => {
@@ -397,12 +394,10 @@ 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);
-          try {
-            await model.upload(file);
-            throw new Error('Upload should have failed');
-          } catch (err) {
-            expect(err).toBe(`Cannot upload file (>15 MB). ${fname}`);
-          }
+
+          await expect(model.upload(file)).rejects.toBe(
+            `Cannot upload file (>15 MB). ${fname}`
+          );
         });
 
         afterAll(() => {

+ 2 - 0
testutils/src/flakyIt.ts

@@ -32,6 +32,7 @@ async function runTest(fn: any): Promise<void> {
  * @param retries The number of retries
  * @param wait The time to wait in milliseconds between retries
  */
+/* eslint-disable jest/no-export */
 export function flakyIt(name: string, fn: any, retries = 3, wait = 1000): void {
   test(name, async () => {
     let latestError;
@@ -47,6 +48,7 @@ export function flakyIt(name: string, fn: any, retries = 3, wait = 1000): void {
     throw latestError;
   });
 }
+/* eslint-enable jest/no-export */
 
 flakyIt.only = it.only;
 flakyIt.skip = it.skip;