Files
expo-popcore-app/components/blocks/home/TabNavigation.test.tsx
imeepos 2757b68756 feat: add TemplateGrid and TitleBar components with tests
- Implemented TemplateGrid component for displaying templates in a grid layout.
- Added calculateCardWidth helper function for dynamic card sizing.
- Created TitleBar component for displaying the title and points with interaction.
- Added unit tests for TemplateGrid and TitleBar components to ensure proper functionality.
- Introduced useStickyTabs and useTabNavigation hooks with tests for managing sticky tab behavior and navigation logic.
- Implemented useTemplateFilter hook for filtering templates based on video content.
- Added comprehensive tests for all new hooks and components to validate behavior and edge cases.
2026-01-26 12:43:20 +08:00

69 lines
1.9 KiB
TypeScript

import { TabNavigation } from './TabNavigation'
describe('TabNavigation Component', () => {
describe('Component Export', () => {
it('should be defined', () => {
expect(TabNavigation).toBeDefined()
})
it('should be a function component', () => {
expect(typeof TabNavigation).toBe('function')
})
})
describe('Props Interface', () => {
it('should accept tabs prop as string array', () => {
const props = { tabs: ['Tab1', 'Tab2', 'Tab3'] }
expect(Array.isArray(props.tabs)).toBe(true)
expect(props.tabs.length).toBe(3)
})
it('should accept activeIndex prop', () => {
const props = { activeIndex: 1 }
expect(props.activeIndex).toBe(1)
})
it('should accept onTabPress callback', () => {
const onTabPress = jest.fn()
expect(typeof onTabPress).toBe('function')
})
it('should accept showArrow optional prop', () => {
const props = { showArrow: true }
expect(props.showArrow).toBe(true)
})
it('should accept onArrowPress callback', () => {
const onArrowPress = jest.fn()
expect(typeof onArrowPress).toBe('function')
})
it('should accept isSticky optional prop', () => {
const props = { isSticky: true }
expect(props.isSticky).toBe(true)
})
it('should accept wrapperStyle optional prop', () => {
const props = { wrapperStyle: { marginTop: 10 } }
expect(props.wrapperStyle).toEqual({ marginTop: 10 })
})
it('should accept onLayout callback', () => {
const onLayout = jest.fn()
expect(typeof onLayout).toBe('function')
})
})
describe('Default Values', () => {
it('should have default showArrow value of false', () => {
const defaultShowArrow = false
expect(defaultShowArrow).toBe(false)
})
it('should have default isSticky value of false', () => {
const defaultIsSticky = false
expect(defaultIsSticky).toBe(false)
})
})
})