import React from 'react'

import { useGridEditor } from './hook'
import { render, renderHook } from '../../utils/test-utils'
import { GridEditorContext } from './context'

const Component = () => {
    const { editable } = useGridEditor()
    return <div>{`${editable}`}</div>
}

describe('GridEditorContext', () => {
    it('should render editable true', () => {
        const { getByText } = render(
            <GridEditorContext.Provider value={{ editable: true }}>
                <Component />
            </GridEditorContext.Provider>
        )
        expect(getByText('true')).toBeInTheDocument()
    })
    it('should render editable false', () => {
        const { getByText } = render(
            <GridEditorContext.Provider value={{ editable: false }}>
                <Component />
            </GridEditorContext.Provider>
        )
        expect(getByText('false')).toBeInTheDocument()
    })
    it('hook should default to true', () => {
        const { result } = renderHook(() => useGridEditor())
        expect(result.current).toEqual({ editable: true })
    })
})
