expo-popcore-app/components/RefreshControl.test.tsx

67 lines
1.7 KiB
TypeScript

import React from 'react'
import { render } from '@testing-library/react-native'
import { ScrollView } from 'react-native'
import RefreshControl from './RefreshControl'
describe('RefreshControl Component', () => {
describe('Basic Rendering', () => {
it('should render with refreshing false', () => {
const mockOnRefresh = jest.fn()
const { UNSAFE_root } = render(
<ScrollView
refreshControl={
<RefreshControl refreshing={false} onRefresh={mockOnRefresh} />
}
>
<></>
</ScrollView>
)
expect(UNSAFE_root).toBeTruthy()
})
it('should render with refreshing true', () => {
const mockOnRefresh = jest.fn()
const { UNSAFE_root } = render(
<ScrollView
refreshControl={
<RefreshControl refreshing={true} onRefresh={mockOnRefresh} />
}
>
<></>
</ScrollView>
)
expect(UNSAFE_root).toBeTruthy()
})
})
describe('Props', () => {
it('should accept refreshing prop', () => {
const mockOnRefresh = jest.fn()
const { UNSAFE_root } = render(
<ScrollView
refreshControl={
<RefreshControl refreshing={true} onRefresh={mockOnRefresh} />
}
>
<></>
</ScrollView>
)
expect(UNSAFE_root).toBeTruthy()
})
it('should accept onRefresh callback prop', () => {
const mockOnRefresh = jest.fn()
const { UNSAFE_root } = render(
<ScrollView
refreshControl={
<RefreshControl refreshing={false} onRefresh={mockOnRefresh} />
}
>
<></>
</ScrollView>
)
expect(UNSAFE_root).toBeTruthy()
})
})
})