All files index.js

81.82% Statements 9/11
50% Branches 4/8
80% Functions 4/5
81.82% Lines 9/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                  1x 1x 1x     1x     1x       1x       1x             1x 1x                  
import React from 'react';
import cowsay from 'cowsay-browser';
 
class Cowsay extends React.Component {
  componentDidMount(){
	// some logic here - we only test if the method is called
  }
  
  getText(){
	const content = this.props.children || this.props.text;
	let text      = null;
	Iif(content === undefined) {
	  return 'Cowsay needs some text! Please add some to the text prop or as children.';
	}
	else Iif(typeof content !== 'string') {
	  return 'Cowsay can only accept a string x.x';
	}
	return content;
  }
  
  getAction(){
	return this.props.think !== undefined ? 'think' : 'say';
  }
  
  getOptions(){
	return Object.assign( {
	  text: this.getText()
	}, { W: 40 }, this.props );
  }
  
  render(){
	
	const cow = cowsay[ this.getAction() ]( this.getOptions() );
	return (
		<pre style={{ textAlign: 'left' }}>
		  {cow}
            </pre>
	)
  }
}
;
 
export default Cowsay;