import React from 'react'
import { shallow } from 'enzyme'

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

import ModerateTray from '../presenter'

describe('ModerateTray presenter', () => {
  const props = {
    closeTray: () => {},
    isOpen: true,
    onTrayClosed: () => {}
  }

  function tray (extraProps) {
    return shallow(<ModerateTray {...extraProps} {...props}>---</ModerateTray>).find(Tray)
  }

  it('passes isOpen to the Tray component', () => {
    expect(tray().prop('open')).equal(props.isOpen)
  })

  it('passes closeTray to the Tray component', () => {
    expect(tray().prop('onDismiss')).equal(props.closeTray)
  })

  it('passes label to the Tray component', () => {
    expect(tray().prop('label')).to.equal('Moderate')
  })

  it("includes the participant name in the Tray's label if given", () => {
    expect(tray({ participantName: 'ohai' }).prop('label')).to.equal('ohai')
  })
})
