Code coverage report for src/components/performance-forecast/practice-button.cjsx

Statements: 100% (24 / 24)      Branches: 83.33% (5 / 6)      Functions: 100% (2 / 2)      Lines: 100% (24 / 24)      Ignored: none     

All files » src/components/performance-forecast/ » practice-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 48 49 50 51 52 53 54 55 56 57 58 59 60                                               63× 63× 63× 63× 63× 63×   63×       63×         61×          
var BS, ChapterSectionType, PerformanceForecast, React, _;
 
React = require('react');
 
BS = require('react-bootstrap');
 
_ = require('underscore');
 
PerformanceForecast = require('../../flux/performance-forecast');
 
ChapterSectionType = require('./chapter-section-type');
 
module.exports = React.createClass({
  displayName: 'PracticeButton',
  propTypes: {
    courseId: React.PropTypes.string.isRequired,
    title: React.PropTypes.string.isRequired,
    sections: React.PropTypes.arrayOf(ChapterSectionType)
  },
  contextTypes: {
    router: React.PropTypes.func
  },
  onClick: function() {
    var courseId, page_ids, ref, sections;
    ref = this.props, courseId = ref.courseId, sections = ref.sections;
    page_ids = PerformanceForecast.Helpers.pagesForSections(sections);
    Eif (!_.isEmpty(page_ids)) {
      return this.context.router.transitionTo('viewPractice', {
        courseId: courseId
      }, {
        page_ids: page_ids
      });
    }
  },
  render: function() {
    var button, classNames, isDisabled, page_ids, sections, tooltip;
    sections = this.props.sections;
    page_ids = PerformanceForecast.Helpers.pagesForSections(sections);
    classNames = ['practice', this.props.practiceType];
    isDisabled = _.isEmpty(page_ids);
    if (isDisabled) {
      classNames.push('disabled');
    }
    button = React.createElement(BS.Button, {
      "className": classNames.join(' '),
      "onClick": this.onClick
    }, this.props.title, React.createElement("i", null));
    if (isDisabled) {
      tooltip = React.createElement(BS.Tooltip, null, "No problems are available for practicing");
      return React.createElement(BS.OverlayTrigger, {
        "placement": 'top',
        "overlay": tooltip
      }, button);
    } else {
      return button;
    }
  }
});