-{expect} = require 'chai'
 _ = require 'underscore'
-
+expect = chai.expect
 {Promise} = require 'es6-promise'
 React = require 'react/addons'
+StubContext = require('react-stub-context')
 
 {componentStub, commonActions}   = require './helpers/utilities'
 

  it 'should pass in period info when selected', (done) ->
    {div} = @result

    firstPeriodItemLink = div.querySelector('li > a')
    sortedPeriods = _.sortBy(COURSE_PERIODS, (period) ->
      parseInt(period.name)
    )

    commonActions.click(firstPeriodItemLink)

    expect(@selectedPeriod).to.deep.equal(sortedPeriods[0])

    done()


    handleSelect = (period) =>
      @selectedPeriod = period
    @transitionSpy = sinon.spy()
    Component = StubContext(CoursePeriodsNav, {router: {
      transitionTo: @transitionSpy
      getCurrentQuery: -> {tab: 0}
      getCurrentPathname: -> '/test/test/test'
    }})
    componentStub
      .render(<Component
        courseId={COURSE_ID}
        handleSelect={handleSelect}
        periods={COURSE_PERIODS}/>)
