import React from 'react'
import { snapshot } from '../utils/test-utils'
import { GridCellButton } from './cell-button'
import { Calendar } from '@planview/pv-icons'
import { render } from '@testing-library/react'
import userEvent from '@testing-library/user-event'

describe('GridCellButton', () => {
    snapshot('Minimal props', <GridCellButton tabIndex={0} />)
    snapshot('Label', <GridCellButton tabIndex={0} label="Hello world" />)
    snapshot('Icon', <GridCellButton tabIndex={0} icon={<Calendar />} />)
    describe('Interaction', () => {
        it('should call onClick callback', async () => {
            const callBack = jest.fn()
            const { getByRole } = render(
                <GridCellButton label="Hello" tabIndex={0} onClick={callBack} />
            )
            await userEvent.click(getByRole('button'))
            expect(callBack).toHaveBeenCalled()
        })
    })
})
