
import Tooltip from '@instructure/ui-overlays/lib/components/Tooltip'

import Title from '../index'

describe('Common Stimulus Sidebar Title Presenter', () => {
  const props = {
    sidebarOpen: true,
    title: 'This is a title'
  }

  const testbed = createTestbed(Title, props)

  describe('#renderTitle', () => {
    it('should render html content as html', () => {
      const title = '<div>Hello</div>'
      testbed.render({title})
      expect(testbed.getText()).include(title)
    })

    it('renders a tooltip component if title is longer than 80 chars', () => {
      testbed.render(
        {title: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula and more'}
      )
      expect(testbed.findChildrenByType(Tooltip).length).to.eq(1)
    })

    it('does not render a tooltip component if title is shorter than 80 chars', () => {
      testbed.render({title: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit'})
      expect(testbed.findChildrenByType(Tooltip).length).to.eq(0)
    })
  })

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