diff --git a/components/blocks/home/HeroSlider.test.tsx b/components/blocks/home/HeroSlider.test.tsx index d43f263..45a2391 100644 --- a/components/blocks/home/HeroSlider.test.tsx +++ b/components/blocks/home/HeroSlider.test.tsx @@ -98,4 +98,26 @@ describe('HeroSlider Component', () => { }).not.toThrow() }) }) + + describe('Slider Layout', () => { + it('should have fixed width for slide container to enable horizontal scrolling', () => { + const { StyleSheet } = require('react-native') + const { HeroSlider } = require('./HeroSlider') + + // 读取组件文件内容来验证样式定义 + const fs = require('fs') + const path = require('path') + const componentPath = path.join(__dirname, 'HeroSlider.tsx') + const componentContent = fs.readFileSync(componentPath, 'utf-8') + + // 验证 heroMainSlide 样式包含固定宽度265 + expect(componentContent).toContain('heroMainSlide: {') + expect(componentContent).toContain('width: 265') + + // 验证不包含 width: '100%' + const heroMainSlideMatch = componentContent.match(/heroMainSlide:\s*{[^}]*}/s) + expect(heroMainSlideMatch).toBeTruthy() + expect(heroMainSlideMatch![0]).not.toContain("width: '100%'") + }) + }) }) diff --git a/components/blocks/home/HeroSlider.tsx b/components/blocks/home/HeroSlider.tsx index c9769a8..927d757 100644 --- a/components/blocks/home/HeroSlider.tsx +++ b/components/blocks/home/HeroSlider.tsx @@ -69,7 +69,7 @@ const styles = StyleSheet.create({ gap: 12, }, heroMainSlide: { - width: '100%', + width: 265, }, heroMainImage: { width: 265,