mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-30 23:22:41 +08:00
Fixed XHR tests
Summary: The XMLHttpRequest jest tests were attempting to call a private method in XMLHttpRequestBase.js (denoted by an _ prefix). JS doesn't actually have any language-level support for private methods, the use of _ prefix is just a convention. But to prevent casually calling private methods externally, we have a transform that mangles the names of prefixed methods so that that attempting to call them will fail. Using a double _ bypasses this name-mangling mechanism, while still making it clear that the method is intended to be private. Reviewed By: javache Differential Revision: D3276261 fb-gh-sync-id: e0c17e1003d2df09d1a16f78ae9d95bef923d74e fbshipit-source-id: e0c17e1003d2df09d1a16f78ae9d95bef923d74e
This commit is contained in:
committed by
Facebook Github Bot 6
parent
e737891242
commit
963a53b1a7
@@ -214,7 +214,7 @@ class XMLHttpRequestBase extends EventTarget(...XHR_EVENTS) {
|
||||
this._requestId = requestId;
|
||||
this._subscriptions.push(RCTDeviceEventEmitter.addListener(
|
||||
'didSendNetworkData',
|
||||
(args) => this._didUploadProgress(...args)
|
||||
(args) => this.__didUploadProgress(...args)
|
||||
));
|
||||
this._subscriptions.push(RCTDeviceEventEmitter.addListener(
|
||||
'didReceiveNetworkResponse',
|
||||
@@ -226,11 +226,12 @@ class XMLHttpRequestBase extends EventTarget(...XHR_EVENTS) {
|
||||
));
|
||||
this._subscriptions.push(RCTDeviceEventEmitter.addListener(
|
||||
'didCompleteNetworkResponse',
|
||||
(args) => this._didCompleteResponse(...args)
|
||||
(args) => this.__didCompleteResponse(...args)
|
||||
));
|
||||
}
|
||||
|
||||
_didUploadProgress(requestId: number, progress: number, total: number): void {
|
||||
// exposed for testing
|
||||
__didUploadProgress(requestId: number, progress: number, total: number): void {
|
||||
if (requestId === this._requestId) {
|
||||
this.upload.dispatchEvent({
|
||||
type: 'progress',
|
||||
@@ -266,7 +267,8 @@ class XMLHttpRequestBase extends EventTarget(...XHR_EVENTS) {
|
||||
}
|
||||
}
|
||||
|
||||
_didCompleteResponse(requestId: number, error: string, timeOutError: boolean): void {
|
||||
// exposed for testing
|
||||
__didCompleteResponse(requestId: number, error: string, timeOutError: boolean): void {
|
||||
if (requestId === this._requestId) {
|
||||
if (error) {
|
||||
this.responseText = error;
|
||||
|
||||
Reference in New Issue
Block a user