url = require 'url'

HomePage = require './homepage.po'

beforeEach ->
  @homePage = new HomePage()
  @homePage.get()

describe 'The App', ->

  it 'should automatically redirect to / when location hash is empty', ->
    expect(browser.getLocationAbsUrl()).toMatch '/'

describe 'Home Page', ->

  it 'should greet the user', ->

    expect(
      @homePage.greeting.getText()
    ).toEqual 'Hello, world! - from DemoController.coffee'

  it 'should navigate to docs view when docs button is clicked', ->

    @homePage.docsBtn.click()

    browser.getCurrentUrl()
      .then (path) -> expect(url.parse(path).pathname).toEqual '/docs'
