import React from 'react'
import { mount } from '../../test/utils'

import { Card } from '../Card'

describe('<Card />', () => {
  it('has a header tag when the title is a string', () => {
    const title = 'Palenca'
    const card = mount(<Card title={title} />)
    expect(card.find('h2')).toContainReactText(title)
  })

  it('has a description when the description is a string', () => {
    const title = 'Palenca'
    const description = 'Lorem ipsum'
    const card = mount(<Card title={title} description={description} />)
    expect(card.find('p')).toContainReactText(description)
  })

  it('does not show description if title is not defined', () => {
    const description = 'Lorem ipsum'
    const card = mount(<Card description={description} />)
    expect(card.find('p')).toBeNull()
  })

  it('renders its children', () => {
    const mockChildren = 'mock_children'
    const app = mount(<Card>{mockChildren}</Card>)
    expect(app).toContainReactText(mockChildren)
  })
})
