mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
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:
committed by
Facebook Github Bot
parent
db0c22192c
commit
971b083c6a
@@ -33,6 +33,7 @@ var TESTS = [
|
||||
require('./ImageCachePolicyTest'),
|
||||
require('./ImageSnapshotTest'),
|
||||
require('./PromiseTest'),
|
||||
require('./SyncMethodTest'),
|
||||
require('./WebSocketTest'),
|
||||
];
|
||||
|
||||
|
||||
42
IntegrationTests/SyncMethodTest.js
Normal file
42
IntegrationTests/SyncMethodTest.js
Normal 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;
|
||||
Reference in New Issue
Block a user