2018-05-09 07:47:45 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-05-09 07:47:45 +00:00
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const mockNativeFunction = methodName => {
|
|
|
|
let warned = false;
|
|
|
|
return function() {
|
|
|
|
if (warned) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
warned = true;
|
|
|
|
console.warn(
|
|
|
|
'Calling .' +
|
|
|
|
methodName +
|
|
|
|
'() in the test renderer environment is not supported. Instead, mock ' +
|
|
|
|
'out your components that use findNodeHandle with replacements that ' +
|
|
|
|
"don't rely on the native environment.",
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const MockNativeMethods = {
|
|
|
|
measure: mockNativeFunction('measure'),
|
|
|
|
measureInWindow: mockNativeFunction('measureInWindow'),
|
|
|
|
measureLayout: mockNativeFunction('measureLayout'),
|
|
|
|
setNativeProps: mockNativeFunction('setNativeProps'),
|
|
|
|
focus: mockNativeFunction('focus'),
|
|
|
|
blur: mockNativeFunction('blur'),
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = MockNativeMethods;
|