Code coverage report for src/components/course-calendar/plan-label.cjsx

Statements: 92.86% (13 / 14)      Branches: 50% (1 / 2)      Functions: 100% (2 / 2)      Lines: 92.86% (13 / 14)      Ignored: none     

All files » src/components/course-calendar/ » plan-label.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                                 54×     27× 27× 27× 27× 27×       27×     27×                    
var CoursePlanLabel, React, twix;
 
React = require('react');
 
twix = require('twix');
 
CoursePlanLabel = React.createClass({
  displayName: 'CoursePlanLabel',
  propTypes: {
    rangeDuration: React.PropTypes.instanceOf(twix).isRequired,
    plan: React.PropTypes.shape({
      title: React.PropTypes.string.isRequired,
      durationLength: React.PropTypes.number.isRequired,
      opensAt: React.PropTypes.string
    }).isRequired,
    offsetFromPlanStart: React.PropTypes.number.isRequired,
    index: React.PropTypes.number.isRequired,
    offset: React.PropTypes.number.isRequired
  },
  calcPercentOfPlanLength: function(partLength) {
    return partLength / this.props.plan.durationLength * 100 + '%';
  },
  render: function() {
    var index, label, labelClass, offset, offsetFromPlanStart, opensAt, plan, planLabelStyle, planRangeLength, rangeDuration, ref, title;
    ref = this.props, rangeDuration = ref.rangeDuration, plan = ref.plan, index = ref.index, offset = ref.offset, offsetFromPlanStart = ref.offsetFromPlanStart;
    opensAt = plan.opensAt, title = plan.title;
    planRangeLength = rangeDuration.length('days');
    planLabelStyle = {
      width: this.calcPercentOfPlanLength(planRangeLength),
      marginLeft: this.calcPercentOfPlanLength(offsetFromPlanStart)
    };
    Iif (index !== 0) {
      labelClass = 'continued';
    }
    return label = React.createElement("label", {
      "data-opens-at": opensAt,
      "data-title": title,
      "style": planLabelStyle,
      "className": labelClass
    }, title);
  }
});
 
module.exports = CoursePlanLabel;