All files / components message.js

100% Statements 8/8
100% Branches 5/5
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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            13x   2x   1x   4x   1x   5x       13x               2x            
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Alert } from 'react-bootstrap';
 
class Message extends Component {
  icon() {
    switch (this.props.level) {
      case 'error':
        return <span className="icon icon-error" />;
      case 'info':
        return <span className="icon icon-info" />;
      case 'ok':
        return <span className="icon icon-ok" />;
      case 'warning':
        return <span className="icon icon-warning" />;
      default:
        return null;
    }
  }
  render() {
    return (
      <Alert onClick={this.props.onClick}>
        {this.icon()}
        {this.props.content}
      </Alert>
    );
  }
}
Message.propTypes = {
  level: PropTypes.string,
  content: PropTypes.string,
};
 
export default Message;