
import {List} from 'immutable'

import styles from '../styles.css'
import Errors from '../Errors'

describe('Errors', () => {
  const testbed = createTestbed(Errors, {
    errorList: List(['something is wrong', 'something else is wrong'])
  })

  shouldRenderComponent(
    testbed, {}, Errors
  )

  describe('rendering', () => {
    it('should render a list of errors', () => {
      testbed.render({})

      const individualErrors = testbed.findChildrenByClass(styles.error)
      expect(individualErrors.length).to.be.equal(2)
    })

    it('should not render if no errors are given', () => {
      testbed.render({errorList: List()})

      const errorWrapper = testbed.findChildrenByClass(styles.errors)[0]
      expect(errorWrapper).to.be.undefined()

      const individualErrors = testbed.findChildrenByClass(styles.error)
      expect(individualErrors.length).to.be.equal(0)
    })
  })

  describe('a11y tests', () => {
    it('should meet a11y standards', (done) => {
      testbed.render({})
      testbed.checkA11yStandards(done)
    })
  })
})
