<commit_before><commit_msg>a few specs for exercise chooser<commit_after>{Testing, sinon, expect, _, React} = require '../../helpers/component-testing'
_ = require 'underscore'
moment = require 'moment-timezone'

{TocActions, TocStore} = require '../../../../src/flux/toc'
{TaskPlanActions, TaskPlanStore} = require '../../../../src/flux/task-plan'
{ExtendBasePlan, PlanRenderHelper} = require '../../helpers/task-plan'
{CourseActions, CourseStore} = require '../../../../src/flux/course'

ECOSYSTEM_ID = '1'
COURSE_ID    = '1'
PLAN_ID      = '1'

COURSE = require '../../../../api/user/courses/1.json'
READINGS  = require '../../../../api/ecosystems/1/readings.json'
NEW_PLAN = ExtendBasePlan({id: PLAN_ID})

ChooseExercises = require '../../../../src/components/task-plan/homework/choose-exercises'

describe 'choose exercises component', ->

  beforeEach ->
    TocActions.loaded(READINGS, ECOSYSTEM_ID)
    TaskPlanActions.loaded(NEW_PLAN, PLAN_ID)
    CourseActions.loaded(COURSE, COURSE_ID)
    @props =
      ecosystemId: ECOSYSTEM_ID
      courseId: COURSE_ID
      canEdit: false
      planId: PLAN_ID
      cancel: sinon.spy()
      hide: sinon.spy()

  it 'renders selections', ->
    Testing.renderComponent( ChooseExercises, props: @props ).then ({dom}) ->
      expect(dom.querySelector('[data-chapter-section="1.1"]')).to.exist

  it 'hides exercises onSectionChange', ->
    Testing.renderComponent( ChooseExercises, props: @props, unmountAfter: 10 ).then ({dom, element}) ->
      Testing.actions.click( dom.querySelector('.section') )
      expect(element.state.showProblems).to.be.false
{'fraction_non_alphanumeric': 0.17757009345794392, 'fraction_numerical': 0.005607476635514018, 'mean_word_length': 3.4, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5324792', 'n_tokens_mistral': 535, 'n_tokens_neox': 529, 'n_words': 100}