浏览代码

test(common): Fix failing test

Michael Bromley 4 年之前
父节点
当前提交
29d898947f
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16 0
      packages/common/src/omit.spec.ts

+ 16 - 0
packages/common/src/omit.spec.ts

@@ -3,6 +3,22 @@ import { omit } from './omit';
 declare const File: any;
 
 describe('omit()', () => {
+    let patchedFileClass = false;
+    beforeAll(() => {
+        // In Node.js there is no File constructor, so we need to patch
+        // a mock version.
+        if (typeof File === 'undefined') {
+            (global as any).File = class MockFile {};
+            patchedFileClass = true;
+        }
+    });
+
+    afterAll(() => {
+        if (patchedFileClass) {
+            delete (global as any).File;
+        }
+    });
+
     it('returns a new object', () => {
         const obj = { foo: 1, bar: 2 };
         expect(omit(obj, ['bar'])).not.toBe(obj);