<commit_before>{React, Testing, _} = require '../helpers/component-testing'

{TimeActions, TimeStore} = require '../../../src/flux/time'

Cell = require '../../../src/components/scores/homework-cell'
PieProgress = require '../../../src/components/scores/pie-progress'

TH = require '../../../src/helpers/task'

describe 'Student Scores Homework Cell', ->

  beforeEach ->
    @props =
      courseId: '1'
      student:
        name: '<NAME>'
        role: 1
      task:
        id: 1
        status: 'in_progress'
        type: 'homework'
        exercise_count: 17
        correct_exercise_count: 9
        completed_step_count: 11
        correct_on_time_exercise_count: 3
        completed_exercise_count: 11
        completed_on_time_exercise_count: 11
        completed_accepted_late_exercise_count: 0
        correct_accepted_late_exercise_count: 0

  it 'renders score cell', ->
    @props.task.completed_exercise_count = @props.task.exercise_count - 1
    wrapper = mount(<Cell {...@props} />)
    expect(wrapper.find('.score a').text()).to.equal('---')
    expect(wrapper.find('.late-caret')).to.have.length(0)
    undefined

  it 'renders as completed', ->
    completedProps = _.extend({}, @props)
    completedProps.task.completed_on_time_exercise_count = @props.task.exercise_count
    completedProps.task.completed_exercise_count = @props.task.exercise_count
    wrapper = mount(<Cell {...@props} />)
    score = ((@props.task.correct_on_time_exercise_count / @props.task.exercise_count) * 100).toFixed(0) + '%'
    expect(wrapper.find('.score a').text()).to.equal(score)
    expect(wrapper.find('.late-caret')).to.have.length(0)
    undefined

  it 'renders progress cell', ->
    @props.size = 24
    @props.value = 33
    Testing.renderComponent( PieProgress, props: @props ).then ({dom}) ->
      expect(dom.querySelector('g')).to.exist

  it 'renders as not started', ->
    @props.task.completed_exercise_count = 0<commit_msg>make sure task isnt due<commit_after>{React, Testing, _} = require '../helpers/component-testing'

{TimeActions, TimeStore} = require '../../../src/flux/time'
moment = require 'moment'
Cell = require '../../../src/components/scores/homework-cell'
PieProgress = require '../../../src/components/scores/pie-progress'

TH = require '../../../src/helpers/task'

describe 'Student Scores Homework Cell', ->

  beforeEach ->
    @props =
      courseId: '1'
      student:
        name: '<NAME>'
        role: 1
      task:
        id: 1
        status: 'in_progress'
        type: 'homework'
        exercise_count: 17
        correct_exercise_count: 9
        completed_step_count: 11
        correct_on_time_exercise_count: 3
        completed_exercise_count: 11
        completed_on_time_exercise_count: 11
        completed_accepted_late_exercise_count: 0
        correct_accepted_late_exercise_count: 0

  it 'renders score cell', ->
    @props.task.completed_exercise_count = @props.task.exercise_count - 1
    @props.due_at = moment().add(1, 'day')
    wrapper = mount(<Cell {...@props} />)
    expect(wrapper.find('.score a').text()).to.equal('---')
    expect(wrapper.find('.late-caret')).to.have.length(0)
    undefined

  it 'renders as completed', ->
    completedProps = _.extend({}, @props)
    completedProps.task.completed_on_time_exercise_count = @props.task.exercise_count
    completedProps.task.completed_exercise_count = @props.task.exercise_count
    wrapper = mount(<Cell {...@props} />)
    score = ((@props.task.correct_on_time_exercise_count / @props.task.exercise_count) * 100).toFixed(0) + '%'
    expect(wrapper.find('.score a').text()).to.equal(score)
    expect(wrapper.find('.late-caret')).to.have.length(0)
    undefined

  it 'renders progress cell', ->
    @props.size = 24
    @props.value = 33
    Testing.renderComponent( PieProgress, props: @props ).then ({dom}) ->
      expect(dom.querySelector('g')).to.exist

  it 'renders as not started', ->
    @props.task.completed_exercise_count = 0
{'fraction_non_alphanumeric': 0.15458207452165157, 'fraction_numerical': 0.013846928499496475, 'mean_word_length': 3.03760162601626, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4622767', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1231, 'n_words': 233}