mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Update some JS in preparation for some Jest updates.
Summary: * Next version of Jest doesn't allow non test files in __tests__ folders. * I'm trying to switch all tests off of jsdom on react-native. This should save 500ms of time when running a single test because jsdom is slow to load and react-native is also not supposed to run in a DOM environment, so let's not pretend we are providing the DOM in tests. * Make the bridge config configurable so that when we disable automocking and we reset the registry we can redefine the value. Oh also, stop using lodash in Server.js. First off, lodash 3 doesn't work in Jest's node env because it does some crazy stuff, second because we don't need to load all of lodash for debounce. Reviewed By: davidaurelio Differential Revision: D3502886 fbshipit-source-id: 1da1cfba9ed12264d81945b702e7a429d5f84424
This commit is contained in:
committed by
Facebook Github Bot 6
parent
4a15dc814e
commit
89a9ca6688
78
Libraries/Utilities/__mocks__/MessageQueueTestConfig.js
Normal file
78
Libraries/Utilities/__mocks__/MessageQueueTestConfig.js
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* These don't actually exist anywhere in the code.
|
||||
*/
|
||||
'use strict';
|
||||
var remoteModulesConfig = {
|
||||
"RemoteModule1": {
|
||||
"moduleID":0,
|
||||
"methods":{
|
||||
"remoteMethod1":{
|
||||
"type":"remote",
|
||||
"methodID":0
|
||||
},
|
||||
"remoteMethod2":{
|
||||
"type":"remote",
|
||||
"methodID":1
|
||||
}
|
||||
}
|
||||
},
|
||||
"RemoteModule2":{
|
||||
"moduleID":1,
|
||||
"methods":{
|
||||
"remoteMethod1":{
|
||||
"type":"remote",
|
||||
"methodID":0
|
||||
},
|
||||
"remoteMethod2":{
|
||||
"type":"remote",
|
||||
"methodID":1
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* These actually exist in the __tests__ folder.
|
||||
*/
|
||||
var localModulesConfig = {
|
||||
"MessageQueueTestModule1": {
|
||||
"moduleID":"MessageQueueTestModule1",
|
||||
"methods":{
|
||||
"testHook1":{
|
||||
"type":"local",
|
||||
"methodID":"testHook1"
|
||||
},
|
||||
"testHook2":{
|
||||
"type":"local",
|
||||
"methodID":"testHook2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"MessageQueueTestModule2": {
|
||||
"moduleID":"MessageQueueTestModule2",
|
||||
"methods": {
|
||||
"runLocalCode":{
|
||||
"type":"local",
|
||||
"methodID":"runLocalCode"
|
||||
},
|
||||
"runLocalCode2":{
|
||||
"type":"local",
|
||||
"methodID":"runLocalCode2"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var MessageQueueTestConfig = {
|
||||
localModuleConfig: localModulesConfig,
|
||||
remoteModuleConfig: remoteModulesConfig,
|
||||
};
|
||||
|
||||
module.exports = MessageQueueTestConfig;
|
||||
26
Libraries/Utilities/__mocks__/MessageQueueTestModule1.js
Normal file
26
Libraries/Utilities/__mocks__/MessageQueueTestModule1.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule MessageQueueTestModule1
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Dummy module that only exists for the sake of proving that the message queue
|
||||
* correctly dispatches to commonJS modules. The `testHook` is overriden by test
|
||||
* cases.
|
||||
*/
|
||||
var MessageQueueTestModule1 = {
|
||||
testHook1: function() {
|
||||
},
|
||||
testHook2: function() {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = MessageQueueTestModule1;
|
||||
|
||||
20
Libraries/Utilities/__mocks__/MessageQueueTestModule2.js
Normal file
20
Libraries/Utilities/__mocks__/MessageQueueTestModule2.js
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule MessageQueueTestModule2
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var MessageQueueTestModule2 = {
|
||||
runLocalCode: function() {
|
||||
},
|
||||
runLocalCode2: function() {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = MessageQueueTestModule2;
|
||||
Reference in New Issue
Block a user