import React from 'react'
import { render } from '@testing-library/react-native'
import { LikeButton } from './LikeButton'
describe('LikeButton Component', () => {
describe('Component Export', () => {
it('should be defined', () => {
expect(LikeButton).toBeDefined()
})
it('should be wrapped with React.memo', () => {
expect(typeof LikeButton).toBe('object')
})
})
describe('Props Interface', () => {
it('should accept liked prop', () => {
const props = { liked: true }
expect(props.liked).toBe(true)
})
it('should accept loading prop', () => {
const props = { loading: true }
expect(props.loading).toBe(true)
})
it('should accept count prop', () => {
const props = { count: 100 }
expect(props.count).toBe(100)
})
it('should accept size prop', () => {
const props = { size: 24 }
expect(props.size).toBe(24)
})
it('should accept onPress callback', () => {
const onPress = jest.fn()
expect(typeof onPress).toBe('function')
})
it('should accept testID prop', () => {
const props = { testID: 'like-button' }
expect(props.testID).toBe('like-button')
})
})
describe('Default Values', () => {
it('should have default liked value of false', () => {
const defaultLiked = false
expect(defaultLiked).toBe(false)
})
it('should have default loading value of false', () => {
const defaultLoading = false
expect(defaultLoading).toBe(false)
})
it('should have default size value of 24', () => {
const defaultSize = 24
expect(defaultSize).toBe(24)
})
})
describe('Rendering', () => {
it('should render successfully', () => {
const { getByTestId } = render()
expect(getByTestId('like-button')).toBeTruthy()
})
it('should render with default props', () => {
const { getByTestId } = render()
expect(getByTestId('like-button-default')).toBeTruthy()
})
})
describe('Liked State', () => {
it('should render outline heart when liked is false', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-unliked')
expect(button).toBeTruthy()
})
it('should render filled heart when liked is true', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-liked')
expect(button).toBeTruthy()
})
})
describe('Loading State', () => {
it('should render loading state when loading is true', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-loading')
expect(button).toBeTruthy()
})
it('should disable button when loading', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-disabled')
expect(button).toBeTruthy()
})
})
describe('Count Display', () => {
it('should render count when provided', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-count')
expect(button).toBeTruthy()
})
it('should not render count when not provided', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-no-count')
expect(button).toBeTruthy()
})
it('should display zero count', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-zero')
expect(button).toBeTruthy()
})
})
describe('Custom Size', () => {
it('should render with custom size', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-size')
expect(button).toBeTruthy()
})
it('should render with small size', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-small')
expect(button).toBeTruthy()
})
it('should render with large size', () => {
const { getByTestId } = render()
const button = getByTestId('like-button-large')
expect(button).toBeTruthy()
})
})
describe('Press Handler', () => {
it('should accept onPress callback', () => {
const onPress = jest.fn()
const { getByTestId } = render()
const button = getByTestId('like-button-press')
expect(button).toBeTruthy()
})
})
})