Skip to content

Commit

Permalink
Adding tests to cover regressions when upgrading to babel 7
Browse files Browse the repository at this point in the history
Reviewed By: mjesun

Differential Revision: D7123659

fbshipit-source-id: f344786dfe5e4c6c0d81992504ba93688edeb5db
  • Loading branch information
Peter van der Zee authored and facebook-github-bot committed Mar 6, 2018
1 parent e839c91 commit 6eef7de
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Libraries/Blob/__tests__/File-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 6eef7de

Please sign in to comment.