describe 'PvrInfoItem', ->
  React = require 'react'
  PvrInfoItem = React.createFactory require('../../src/components/pvr_info_item')
  TestUtils = require 'react-dom/test-utils'
  ReactDOM = require 'react-dom'
   
  #--------------------------------------------------------------------- Render
  it 'Should Render the appropriate CSS class if hasSubLabel property is true', ->

    pvrInfoItem = TestUtils.renderIntoDocument PvrInfoItem {
      hasSubLabel: yes
      itemHeight: 10
      item: {
        info: 'info'
        label: 'label'
      }
    }
  
    mainDiv = TestUtils.scryRenderedDOMComponentsWithClass pvrInfoItem, 'has-sublabel'

    expect(mainDiv.length).to.equal(1)

  it 'Should NOT Render the sub label CSS class if hasSubLabel property is false', ->

    pvrInfoItem = TestUtils.renderIntoDocument PvrInfoItem {
      item: {
        info: 'info'
        label: 'label'
      }
    }

    mainDiv = TestUtils.scryRenderedDOMComponentsWithClass pvrInfoItem, 'has-sublabel'

    expect(mainDiv.length).to.equal(0)


  it 'Should Render the item label and info', ->

    item = {
      info: 'info'
      label: 'label'
    }

    pvrInfoItem = TestUtils.renderIntoDocument PvrInfoItem {
      item: item
    }

    infoDiv = TestUtils.findRenderedDOMComponentWithClass pvrInfoItem, 'pvr-info'
    labelDiv = TestUtils.findRenderedDOMComponentWithClass pvrInfoItem, 'pvr-info-label'

    expect(infoDiv.innerText).to.equal(item.info)
    expect(labelDiv.innerText).to.equal(item.label)


  it 'Should have min-height of itemHeight property', ->

    itemHeight = 10
    item = {
      info: 'info'
      label: 'label'
    }

    pvrInfoItem = TestUtils.renderIntoDocument PvrInfoItem {
      item: item
      itemHeight: itemHeight
    }

    mainDiv = TestUtils.findRenderedDOMComponentWithClass pvrInfoItem, 'plain-pvr-content-item'
  
    expect(mainDiv.style['min-height']).to.equal("#{itemHeight}px")


  it 'Should have line-height of itemHeight property divided by 2', ->

    itemHeight = 10
    item = {
      info: 'info'
      label: 'label'
    }

    pvrInfoItem = TestUtils.renderIntoDocument PvrInfoItem {
      item: item
      itemHeight: itemHeight
    }

    mainDiv = TestUtils.findRenderedDOMComponentWithClass pvrInfoItem, 'plain-pvr-content-item'

    lineHeight = itemHeight/2
  
    expect(mainDiv.style['line-height']).to.equal("#{lineHeight}px")
 