   beforeEach ->
     ReferenceBookActions.loaded(TOC, COURSE_ID)
     ReferenceBookPageActions.loaded(PAGE, FIRST_PAGE_ID)
-    renderBook(FIRST_PAGE_ID).then (state) =>
+    renderBook(FIRST_PAGE).then (state) =>
       @state = state
 
   it 'renders the section title on the navbar',  ->

    expect(@state.div.querySelector('.page').textContent)
      .to.equal('A bunch of html')

  it 'toggles menu when navbar control is clicked', ->
    toggle = @state.div.querySelector('.menu-toggle')

    expect(_.toArray(@state.div.querySelector('.reference-book').classList))
      .to.not.contain('menu-open')



COURSE_ID = '1'
TOC  = require '../../api/courses/1/readings.json'
FIRST_PAGE_ID = '0e58aa87-2e09-40a7-8bf3-269b2fa16509'
FIRST_PAGE  = '1.1'
SECOND_PAGE = '1.2'
SECOND_PAGE_ID = '0e58aa87-2e09-40a7-8bf3-269b2fa16510'
THIRD_PAGE  = '1.3'

PAGE = require '../../api/pages/0e58aa87-2e09-40a7-8bf3-269b2fa16509.json'


renderBook = (section) ->
  new Promise (resolve, reject) ->
    url = "/books/#{COURSE_ID}"
    url += "/section/#{section}" if section
    routerStub.goTo(url).then( (result) ->
      resolve(_.extend({
        book: ReactTestUtils.findRenderedComponentWithType(result.component, ReferenceBook)
