Prettier React Native Libraries

Reviewed By: sahrens

Differential Revision: D7961488

fbshipit-source-id: 05f9b8b0b91ae77f9040a5321ccc18f7c3c1ce9a
This commit is contained in:
Eli White
2018-05-10 19:06:46 -07:00
committed by Facebook Github Bot
parent 1e2de71290
commit d01ab66b47
301 changed files with 6259 additions and 3781 deletions

View File

@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @emails oncall+react_native
*/
@@ -28,9 +29,9 @@ describe('FormData', function() {
const expectedPart = {
string: 'null',
headers: {
'content-disposition': 'form-data; name="null"'
'content-disposition': 'form-data; name="null"',
},
fieldName: 'null'
fieldName: 'null',
};
expect(formData.getParts()[0]).toMatchObject(expectedPart);
});
@@ -39,7 +40,7 @@ describe('FormData', function() {
formData.append('photo', {
uri: 'arbitrary/path',
type: 'image/jpeg',
name: 'photo.jpg'
name: 'photo.jpg',
});
const expectedPart = {
@@ -48,9 +49,9 @@ describe('FormData', function() {
name: 'photo.jpg',
headers: {
'content-disposition': 'form-data; name="photo"; filename="photo.jpg"',
'content-type': 'image/jpeg'
'content-type': 'image/jpeg',
},
fieldName: 'photo'
fieldName: 'photo',
};
expect(formData.getParts()[0]).toMatchObject(expectedPart);
});

View File

@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @emails oncall+react_native
*/
@@ -12,27 +13,26 @@ jest.unmock('Platform');
const Platform = require('Platform');
let requestId = 1;
function setRequestId(id){
function setRequestId(id) {
if (Platform.OS === 'ios') {
return;
}
requestId = id;
}
jest
.dontMock('event-target-shim')
.setMock('NativeModules', {
Networking: {
addListener: function() {},
removeListeners: function() {},
sendRequest(options, callback) {
if (typeof callback === 'function') { // android does not pass a callback
callback(requestId);
}
},
abortRequest: function() {},
jest.dontMock('event-target-shim').setMock('NativeModules', {
Networking: {
addListener: function() {},
removeListeners: function() {},
sendRequest(options, callback) {
if (typeof callback === 'function') {
// android does not pass a callback
callback(requestId);
}
},
});
abortRequest: function() {},
},
});
const XMLHttpRequest = require('XMLHttpRequest');
@@ -98,7 +98,9 @@ describe('XMLHttpRequest', function() {
// Can't change responseType after first data has been received.
xhr.open('GET', 'blabla');
xhr.send();
expect(() => { xhr.responseType = 'text'; }).toThrow();
expect(() => {
xhr.responseType = 'text';
}).toThrow();
});
it('should expose responseText correctly', function() {
@@ -115,7 +117,9 @@ describe('XMLHttpRequest', function() {
expect(xhr.response).toBe('');
// responseText is read-only.
expect(() => { xhr.responseText = 'hi'; }).toThrow();
expect(() => {
xhr.responseText = 'hi';
}).toThrow();
expect(xhr.responseText).toBe('');
expect(xhr.response).toBe('');
@@ -217,8 +221,7 @@ describe('XMLHttpRequest', function() {
});
expect(xhr.getAllResponseHeaders()).toBe(
'Content-Type: text/plain; charset=utf-8\r\n' +
'Content-Length: 32');
'Content-Type: text/plain; charset=utf-8\r\n' + 'Content-Length: 32',
);
});
});