all files / components/ Banner.js

88.89% Statements 32/36
57.58% Branches 19/33
100% Functions 11/11
100% Lines 8/8
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63                                                                                                              
import React from 'react';IEE
import PropTypes from 'prop-types';EIII
 
class Banner extends React.Component {
  componentDidMount() {
    // some logic here - we only test if the method is called
  }
  render() {
    const style = {
      banner: {
        marginTop: '-20px',
        width: '100vw',
        backgroundColor: this.props.backgroundColour,
        color: '#fff',
        boxSizing: 'border-box',
        display: 'block',
        height: '40px',
      },
      bannerTag: {
        paddingTop: '2px',
        paddingRight: '7px',
        paddingBottom: '3px',
        paddingLeft: '7px',
        marginLeft: '10px',
        color: '#FFFFFF',
        fontWeight: '700',
        backgroundColor: '#323132',
        boxSizing: 'border-box',
      },
      p: {
        paddingTop: '10px',
      },
    };
    return (
      <div id="banner" style={style.banner}>
        <div id="innerBanner" style={style.banner}>
          <div className="container">
            <p style={style.p}>
              <strong style={style.bannerTag}>
                {this.props.text}
              </strong>&nbsp;
              {this.props.message}
            </p>
          </div>
        </div>
      </div>
    );
  }
}
 
Banner.defaultProps = {
  message: '',
  backgroundColour: '#3B7A9E',
};
 
Banner.propTypes = {
  text: PropTypes.string.isRequired,
  message: PropTypes.string,
  backgroundColour: PropTypes.string,
};
 
export default Banner;