import Legend from '../index'
import styles from '../styles.css'

describe('Legend', () => {
  const testbed = createTestbed(Legend, {
    series: [
      { className: 'redClass', label: 'Red' },
      { className: 'blueClass', label: 'Blue' }
    ]
  })

  it('renders each series', () => {
    testbed.render()
    const series = testbed.findChildrenByClass(styles.seriesContainer)
    expect(series).to.have.length(2)
    expect(testbed.getText(series[0])).to.include('Red')
    expect(testbed.findChildrenByClass('redClass')).to.have.length(1)
    expect(testbed.getText(series[1])).to.include('Blue')
    expect(testbed.findChildrenByClass('blueClass')).to.have.length(1)
  })

  it('applies containerRow class to row variant', () => {
    testbed.render({ variant: 'row' })
    const series = testbed.findChildrenBySelector(`.${styles.containerRow} .${styles.seriesContainer}`)
    expect(series).to.have.length(2)
  })
})
