-{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'
 


    handleSelect = (period) =>
      @selectedPeriod = period

    componentStub
      .render(<CoursePeriodsNav
        courseId={COURSE_ID}
        handleSelect={handleSelect}
        periods={COURSE_PERIODS}/>)

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

    lastPeriodItemLink = div.querySelector('li:last-of-type > a')

    sortedPeriods = _.sortBy(COURSE_PERIODS, (period) ->
      parseInt(period.name)
    )

    commonActions.click(lastPeriodItemLink)
    expect(@transitionSpy).to.have.been.calledWith(
      '/test/test/test', {}, {tab: COURSE_PERIODS.length - 1}
    )
    expect(@selectedPeriod).to.deep.equal(_.last(sortedPeriods))

    done()
