import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
import { Plan } from '../../../../../type'
import List from '../index'

describe('CloudPlanItem/List', () => {
  it('should show sandbox specific quotas', () => {
    render(<List plan={Plan.sandbox} />)

    expect(screen.getByText('billing.plansCommon.messageRequest.title:{"count":200}')).toBeInTheDocument()
    expect(screen.getByText('billing.plansCommon.triggerEvents.sandbox:{"count":3000}')).toBeInTheDocument()
    expect(screen.getByText('billing.plansCommon.startNodes.limited:{"count":2}')).toBeInTheDocument()
  })

  it('should show professional monthly quotas and tooltips', async () => {
    const user = userEvent.setup()
    render(<List plan={Plan.professional} />)

    expect(screen.getByText('billing.plansCommon.messageRequest.titlePerMonth:{"count":5000}')).toBeInTheDocument()
    await user.hover(screen.getByRole('button', { name: 'billing.plansCommon.vectorSpaceTooltip' }))
    expect(await screen.findByText('billing.plansCommon.vectorSpaceTooltip')).toBeInTheDocument()
    expect(screen.getByText('billing.plansCommon.workflowExecution.faster')).toBeInTheDocument()
  })

  it('should show unlimited messaging details for team plan', () => {
    render(<List plan={Plan.team} />)

    expect(screen.getByText('billing.plansCommon.triggerEvents.unlimited')).toBeInTheDocument()
    expect(screen.getByText('billing.plansCommon.workflowExecution.priority')).toBeInTheDocument()
    expect(screen.getByText('billing.plansCommon.unlimitedApiRate')).toBeInTheDocument()
  })
})
