import { noop } from 'lodash'
import * as React from 'react'
import renderWithTheme from '../../tests/helpers/renderWithTheme'
import TextInput from '../TextInput/TextInput'
import Modal from './Modal'
describe('component: Modal', () => {
test('Modal is open when isOpen=true', () => {
const { getByText } = renderWithTheme(
I am a modal
)
expect(getByText('I am a modal')).toBeVisible()
})
test('Modal is closed when isOpen=false', () => {
const { queryByText } = renderWithTheme(
I am a modal
)
expect(queryByText('I am a modal')).not.toBeInTheDocument()
})
test('Aria-labels applied correctly', () => {
const ref: React.RefObject = { current: null } as any
const { getByLabelText } = renderWithTheme(
)
expect(getByLabelText('Custom Label')).toBe(ref.current)
expect(ref.current).toHaveAttribute('aria-modal', 'true')
expect(getByLabelText('The Closer')).toHaveClass('modal-close-btn')
})
test('Can render content as children', () => {
const { getByTestId } = renderWithTheme(
)
const child = getByTestId('child')
expect(child).toBeInTheDocument()
})
test('should support flex item props', () => {
const { getByText } = renderWithTheme(
Flex Modal
)
const modal = getByText('Flex Modal')
expect(modal).toHaveStyle('flex: 1')
expect(modal).toHaveStyle('flex-grow: 1')
expect(modal).toHaveStyle('flex-shrink: 0')
expect(modal).toHaveStyle('flex-basis: 0')
})
test('should support flex shortcut prop (boolean)', () => {
const { getByText } = renderWithTheme(
Flex Modal
)
const modal = getByText('Flex Modal')
expect(modal).toHaveStyle({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
})
})
test('should support flex shortcut prop (flex-flow)', () => {
const { getByText } = renderWithTheme(
Flex Modal
)
const modal = getByText('Flex Modal')
expect(modal).toHaveStyle({
display: 'flex',
flexFlow: 'row wrap',
})
})
})