Browse Source

test(common): Fix failing test

Michael Bromley 4 years ago
parent
commit
29d898947f
1 changed files with 16 additions and 0 deletions
  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;
 declare const File: any;
 
 
 describe('omit()', () => {
 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', () => {
     it('returns a new object', () => {
         const obj = { foo: 1, bar: 2 };
         const obj = { foo: 1, bar: 2 };
         expect(omit(obj, ['bar'])).not.toBe(obj);
         expect(omit(obj, ['bar'])).not.toBe(obj);