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

import { Labelled } from '../Labelled'
import { InlineError } from '../../InlineError/InlineError'

describe('<Labelled />', () => {
  describe('children', () => {
    it('renders its children', () => {
      const mockChildren = 'mock_children'
      const label = mount(<Labelled label="Label">{mockChildren}</Labelled>)
      expect(label).toContainReactText(mockChildren)
    })
  })

  describe('error', () => {
    it('renders error markup when provided with a value', () => {
      const label = mount(<Labelled label="Label" error="Error message" />)

      expect(label).toContainReactComponentTimes(InlineError, 1)
      expect(label).toContainReactText('Error message')
    })
  })
})
