-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show test/expect information about an example or description
Summary: Changelog: [Internal] - Allow for examples to define test steps and expectation Reviewed By: charlesbdudley Differential Revision: D29674189 fbshipit-source-id: ac62a634d0139d179408104479f88009237503e3
- Loading branch information
1 parent
9825a62
commit 08ba866
Showing
4 changed files
with
141 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
import * as React from 'react'; | ||
import {View, Text, StyleSheet, Button} from 'react-native'; | ||
import {type RNTesterTheme} from './RNTesterTheme'; | ||
|
||
function RNTTestDetails({ | ||
test, | ||
description, | ||
expect, | ||
title, | ||
theme, | ||
}: { | ||
test?: string, | ||
description?: string, | ||
expect?: string, | ||
title: string, | ||
theme: RNTesterTheme, | ||
}): React.Node { | ||
const [collapsed, setCollapsed] = React.useState(false); | ||
|
||
const content = | ||
test != null ? ( | ||
<> | ||
<View style={styles.section}> | ||
<Text style={styles.heading}>How to Test</Text> | ||
<Text style={styles.paragraph}>{test}</Text> | ||
</View> | ||
{expect != null && ( | ||
<View style={styles.section}> | ||
<Text style={styles.heading}>Expectation</Text> | ||
<Text style={styles.paragraph}>{expect}</Text> | ||
</View> | ||
)} | ||
</> | ||
) : description != null ? ( | ||
<View style={styles.section}> | ||
<Text style={styles.heading}>Description</Text> | ||
<Text style={styles.paragraph}>{description}</Text> | ||
</View> | ||
) : null; | ||
|
||
return ( | ||
<View | ||
style={StyleSheet.compose(styles.container, { | ||
borderColor: theme.SeparatorColor, | ||
})}> | ||
<View style={styles.titleRow}> | ||
<Text | ||
numberOfLines={1} | ||
style={StyleSheet.compose(styles.title, {color: theme.LabelColor})}> | ||
{title} | ||
</Text> | ||
{content != null && ( | ||
<Button | ||
title={collapsed ? 'Expand' : 'Collapse'} | ||
onPress={() => setCollapsed(!collapsed)} | ||
color={theme.LinkColor} | ||
/> | ||
)} | ||
</View> | ||
{!collapsed ? content : null} | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
paddingHorizontal: 10, | ||
paddingTop: 6, | ||
paddingBottom: 10, | ||
borderBottomWidth: 1, | ||
}, | ||
heading: { | ||
fontSize: 16, | ||
color: 'grey', | ||
fontWeight: '500', | ||
}, | ||
paragraph: { | ||
fontSize: 14, | ||
}, | ||
section: { | ||
marginVertical: 4, | ||
}, | ||
title: { | ||
fontSize: 18, | ||
}, | ||
titleRow: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
}, | ||
}); | ||
|
||
export default RNTTestDetails; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters