import React from 'react'
import { shallow } from 'enzyme'

import Card from '../index'
import CardContent from '../CardContent'
import CardWrapper from '../CardWrapper'

describe('Card', () => {
  it('renders CardContent', () => {
    const wrapper = shallow(<Card>Cool Content</Card>)
    const content = wrapper.find(CardContent)
    expect(content.prop('children')).to.equal('Cool Content')
  })

  it('passes props to CardContent', () => {
    const wrapper = shallow(
      <Card className="myClass" data-automation="card-for-testing">Cool Content</Card>
    )
    const content = wrapper.find(CardContent)
    expect(content.prop('className')).to.equal('myClass')
    expect(content.prop('data-automation')).to.equal('card-for-testing')
  })

  it('renders CardWrapper if wrapped', () => {
    const wrapper = shallow(<Card wrapped>Cool Content</Card>)
    const content = wrapper.find(CardWrapper).find(CardContent)
    expect(content.prop('children')).to.equal('Cool Content')
  })

  it('passes wrapperClassName to CardWrapper', () => {
    const wrapper = shallow(<Card wrapped wrapperClassName="myWrapperClass">Cool Content</Card>)
    expect(wrapper.find(CardWrapper).prop('className')).to.equal('myWrapperClass')
  })
})
