Vin*_*nay 7 jestjs react-native enzyme
有没有人为 react-native-tab-view 编写过单元测试?我需要模拟道具 onIndexChanged 和 TabBar 的 getLabelText。这是我们的模拟
import React from 'react';
import { View } from "react-native";
export class TabView extends View {
render = function () {
return <View>
{this.props.renderTabBar()}
{Object.values(this.props.renderScene)
.map((scene, i) => <View key={i}>{scene()}</View>)}
</View>;
};
};
export const TabBar = View;
export const SceneMap = map => map;
Here is the TabView we are using. Any help is really appreciated. Run Code Online (Sandbox Code Playgroud)
<TabView
navigationState={this.state}
renderScene={SceneMap({
current: () => <TorViewCurrent
torCurrentList={this.props.torCurrentList}
torCurrentListLoading={this.props.isLoading || this.props.torCurrentListLoading}
torCurrentListLoaded={this.torCurrentListLoaded}
torCurrentListError={this.props.torCurrentListError}
torStatusMap={this.props.torStatusMap}
torReasonMap={this.props.torReasonMap}
torTypeMap={this.props.torTypeMap}
refreshTorCurrentList={this.onRefreshTorCurrentList.bind(this)} />,
past: () => <TorViewPast
torPastList={this.props.torPastList}
torPastListLoading={this.props.isLoading || this.props.torPastListLoading}
torPastListLoaded={this.torPastListLoaded}
torPastListError={this.props.torPastListError}
torStatusMap={this.props.torStatusMap}
torReasonMap={this.props.torReasonMap}
torTypeMap={this.props.torTypeMap}
refreshTorPastList={this.onRefreshTorPastList.bind(this)} />,
})}
onIndexChange={index => this.setState({ index })}
initialLayout={styles.tabSize}
renderTabBar={props =>
<TabBar
{...props}
getLabelText={({ route }) => route.title}
activeColor={WalmartColorPalette.Primary.Black}
inactiveColor={WalmartColorPalette.Primary.IconGray}
indicatorStyle={styles.tabIndicator}
style={styles.tabs}
labelStyle={styles.labelStyle}
/>
}
/>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
910 次 |
| 最近记录: |