import Spinner from '../Spinner'

describe('Spinner', () => {
  const testbed = createTestbed(Spinner, {})
  shouldRenderComponent(testbed, {}, Spinner)

  it('should render "Loading..." by default', () => {
    testbed.render()
    const text = testbed.getText()
    expect(text).to.include('Loading...')
  })

  it('should use mainText as screenreader text', () => {
    const mainText = 'Loading something important'
    const wrapper = testbed.renderShallowly({mainText})
    const spinner = wrapper.find('Spinner')
    expect(spinner.prop('title')).to.equal(mainText)
  })

  it('should render mainText if prop given', () => {
    const textProp = 'This is main text'
    testbed.render({mainText: textProp})
    const text = testbed.getText()
    expect(text).to.include(textProp)
  })

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