import ReactDOM from 'react-dom'

import renderAlerts from '../renderAlerts'
import Alerts from '../../components/alerts'

describe('renderAlerts', () => {
  const alert = document.createElement('div')
  alert.setAttribute('role', 'alert')
  alert.setAttribute('aria-live', 'assertive')

  beforeEach(() => {
    document.body.appendChild(alert)
    sinon.stub(ReactDOM, 'render')
  })

  afterEach(() => {
    document.body.removeChild(alert)
    ReactDOM.render.restore()
  })

  it('renders Alerts into the dom', () => {
    const store = {}
    renderAlerts(store)
    expect(ReactDOM.render.calledWithMatch({
      props: { children: { type: Alerts } }
    }, alert)).to.be.true()
  })
})
