From 6eef7de46ee5c5004854c1cdd5cd83f2a608f622 Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Tue, 6 Mar 2018 02:12:04 -0800 Subject: [PATCH] Adding tests to cover regressions when upgrading to babel 7 Reviewed By: mjesun Differential Revision: D7123659 fbshipit-source-id: f344786dfe5e4c6c0d81992504ba93688edeb5db --- Libraries/Blob/__tests__/File-test.js | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Libraries/Blob/__tests__/File-test.js b/Libraries/Blob/__tests__/File-test.js index d466d61b8..c10f90c18 100644 --- a/Libraries/Blob/__tests__/File-test.js +++ b/Libraries/Blob/__tests__/File-test.js @@ -13,8 +13,39 @@ jest.setMock('NativeModules', { BlobModule: require('../__mocks__/BlobModule'), }); +const Blob = require('Blob'); const File = require('File'); +describe('babel 7 smoke test', function() { + it('should be able to extend a class with native name', function() { + let called = false; + class Array { + constructor() { + called = true; + return {foo: 'PASS'}; + } + } + class A extends Array { + constructor() { + super(); + } + } + + // there is/was a regression in Babel where this would break and super() + // would not actually invoke the constructor of the parent class if the + // parent class had a name matching a built-in class (like Blob) + expect(new A().foo).toBe('PASS'); + expect(called).toBe(true); + }); +}); + +describe('Blob', function() { + it('regression caused by circular dep && babel 7', function() { + const blob = new Blob([], {type: 'image/jpeg'}); + expect(blob).toBeInstanceOf(Blob); + }); +}); + describe('File', function() { it('should create empty file', () => { const file = new File([], 'test.jpg');