Code coverage report for src/components/buttons/back-button.cjsx

Statements: 100% (16 / 16)      Branches: 50% (2 / 4)      Functions: 100% (2 / 2)      Lines: 100% (16 / 16)      Ignored: none     

All files » src/components/buttons/ » back-button.cjsx
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                                                              
var BS, BackButton, History, Link, React, TransitionActions, TransitionStore, _, ref, ref1;
 
React = require('react');
 
BS = require('react-bootstrap');
 
_ = require('underscore');
 
ref = require('react-router'), History = ref.History, Link = ref.Link;
 
ref1 = require('../../flux/transition'), TransitionActions = ref1.TransitionActions, TransitionStore = ref1.TransitionStore;
 
BackButton = React.createClass({
  displayName: 'BackButton',
  propTypes: {
    bsStyle: React.PropTypes.string,
    fallbackLink: React.PropTypes.shape({
      to: React.PropTypes.string,
      params: React.PropTypes.object,
      text: React.PropTypes.string
    }).isRequired
  },
  getDefaultProps: function() {
    return {
      bsStyle: 'default'
    };
  },
  contextTypes: {
    router: React.PropTypes.func
  },
  render: function() {
    var backText, className, fallbackLink, historyInfo, href, ref2, text;
    historyInfo = TransitionStore.getPrevious(this.context.router);
    ref2 = this.props, fallbackLink = ref2.fallbackLink, className = ref2.className;
    text = fallbackLink.text;
    backText = historyInfo.name ? "Back to " + historyInfo.name : fallbackLink.text;
    href = historyInfo.path || this.context.router.makeHref(this.props.fallbackLink.to, this.props.fallbackLink.params);
    return React.createElement(Link, {
      "className": "btn btn-" + this.props.bsStyle,
      "to": href
    }, backText);
  }
});
 
module.exports = BackButton;