No Description

assert.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // @flow
  2. import React, {Component} from 'react';
  3. import {
  4. AppRegistry,
  5. StyleSheet,
  6. Text,
  7. View,
  8. Platform,
  9. ScrollView,
  10. Image,
  11. } from 'react-native';
  12. export default class Assert extends Component {
  13. props : {
  14. expect : any,
  15. actual : any
  16. };
  17. constructor(props) {
  18. super(props)
  19. }
  20. render() {
  21. return (
  22. <View style={{
  23. padding : 16,
  24. borderLeftWidth : 5,
  25. marginTop : 4,
  26. backgroundColor : 'white',
  27. borderColor : this.getAssertion() ? '#00a825' : '#ff0d0d'
  28. }}>
  29. <Text style={{
  30. color : this.getAssertion() ? '#00a825' : '#ff0d0d',
  31. margin : 8,
  32. marginLeft : 0
  33. }}>{ this.getAssertion() ? '✅' : '×' } Assertion description</Text>
  34. <Text style={{flex : 1, flexDirection : 'row'}}>
  35. <Text style={{ color : '#AAA'}}>expect </Text>
  36. <Text style={{flex : 1}}>{this.props.expect}</Text>
  37. </Text>
  38. <Text style={{flex : 1, flexDirection : 'row'}}>
  39. <Text style={{color : '#AAA'}}>actual </Text>
  40. <Text style={{flex : 1}}>{this.props.actual}</Text>
  41. </Text>
  42. </View>
  43. )
  44. }
  45. getAssertion() {
  46. return this.props.expect === this.props.actual
  47. }
  48. }