import { fireEvent, render } from '@testing-library/react-native'
import * as React from 'react'
import { View } from 'react-native'
import SimpleMessagingCard from 'src/components/SimpleMessagingCard'
describe(SimpleMessagingCard, () => {
it('renders correctly', () => {
const onPress = jest.fn()
const { getByText, getByTestId } = render(
}
callToActions={[{ text: 'it goes boom', onPress }]}
/>
)
expect(getByText('Header')).toBeDefined()
expect(getByText('Test')).toBeDefined()
expect(getByTestId('TestIcon')).toBeDefined()
expect(getByText('it goes boom')).toBeDefined()
fireEvent.press(getByText('it goes boom'))
expect(onPress).toHaveBeenCalled()
})
it('renders remote icons', () => {
const onPress = jest.fn()
const { getByTestId } = render(
)
const icon = getByTestId('Card/Icon')
expect(icon.props.source).toEqual({ uri: 'https://example.com/icon.png' })
})
it('hides the icon when not set', () => {
const onPress = jest.fn()
const { queryByTestId } = render(
)
expect(queryByTestId('Card/Icon')).toBeNull()
})
})