-
-
Save prashantagarwal/384dbe937b5716bd16e91bf90ccb336d to your computer and use it in GitHub Desktop.
Revisions
-
MicheleBertoli created this gist
Sep 17, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import React, { PropTypes } from 'react' const Describe = ({ title, children }) => ( <div> <h1>{title}</h1> <ul>{children}</ul> </div> ) Describe.propTypes = { title: PropTypes.string, children: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.element), PropTypes.element, ]), } export default Describe This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ import React, { Component, PropTypes } from 'react' class It extends Component { constructor(props) { super(props) this.assert = this.assert.bind(this) } assert(condition) { return ( <div style={{ color: condition ? 'green' : 'red' }}> {this.props.title} {condition ? '😻' : '😿'} </div> ) } render() { return ( <li> {this.props.children(this.assert)} </li> ) } } It.propTypes = { title: PropTypes.string, children: PropTypes.func, } export default It This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import React from 'react' import Describe from './describe' import It from './it' const add = (a, b) => a + b const Test = () => ( <Describe title="add()"> <It title="adds two numbers"> {assert => assert(add(2, 3) === 5)} </It> <It title="doesn't add the third number"> {assert => assert(add(2, 3, 5) === add(2, 3))} </It> </Describe> ) export default Test