Added tests for synchronous methods in native modules on iOS

Reviewed By: javache

Differential Revision: D4947631

fbshipit-source-id: d7e497c44602eb6e38896a00edb61639ab2b8cd4
This commit is contained in:
Alex Dvornikov
2017-04-27 11:49:50 -07:00
committed by Facebook Github Bot
parent db0c22192c
commit 971b083c6a
5 changed files with 155 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ var TESTS = [
require('./ImageCachePolicyTest'),
require('./ImageSnapshotTest'),
require('./PromiseTest'),
require('./SyncMethodTest'),
require('./WebSocketTest'),
];

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2015-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.
*
* @flow
* @providesModule SyncMethodTest
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var { View } = ReactNative;
const {
TestModule,
UIExplorerTestModule,
} = ReactNative.NativeModules;
class SyncMethodTest extends React.Component {
componentDidMount() {
if (UIExplorerTestModule.echoString('test string value') !== 'test string value') {
throw new Error('Something wrong with sync method export');
}
if (UIExplorerTestModule.methodThatReturnsNil() != null) {
throw new Error('Something wrong with sync method export');
}
TestModule.markTestCompleted();
}
render(): React.Element<any> {
return <View />;
}
}
SyncMethodTest.displayName = 'SyncMethodTest';
module.exports = SyncMethodTest;