

anon = ->


  IT '/ OK', ->
    PAGE '/', { authenticated: false }, (html) ->
      EXPECT.contains(html,'Signin')
      DONE()

  IT '/calendar 302 to /?returnTo=/calendar', ->
    PAGE '/calendar', { authenticated: false, status: 302 }, (text) ->
      EXPECT.contains(text,'Redirecting to /?returnTo=/calendar')
      DONE()


authd = ->


  SKIP '/ 302 to /calendar', ->
    LOGIN {key:'jkg',oaEmails:''}, (session) ->
      expect(session._id).to.exist
      expect(session.name).to.equal('Jonathon Kresner')
      PAGE '/', { status: 302 }, (text) ->
        EXPECT.contains(text,'Redirecting to /calendar')
        DONE()


  IT '/calendar OK', ->
    LOGIN {key:'jkg'}, (session) ->
      expect(session._id).to.exist
      PAGE '/calendar', { status: 200 }, (text) ->
        EXPECT.contains(text,'Logout')
        DONE()


module.exports = ->

  DESCRIBE("ANONYMOUS", anon)
  DESCRIBE("AUTHENTICATED", authd)
