Files
photo-live/apps/mobile/test/ui/section_header_test.dart
T
2026-09-21 14:55:29 +08:00

38 lines
1.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/// SectionHeader widget 测试(UI-01 Task 3)。
///
/// 覆盖:分组标题渲染(titleMedium 字阶)、可选行尾动作渲染/缺省。
library;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:photo_live/app/theme.dart';
import 'package:photo_live/ui/components/section_header.dart';
void main() {
testWidgets('渲染标题与可选行尾动作', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: AppTheme.light,
home: const Scaffold(
body: SectionHeader(title: '活动信息', trailing: Text('查看全部')),
),
),
);
final title = tester.widget<Text>(find.text('活动信息'));
expect(title.style!.fontSize, 17, reason: '分组标题字阶 17(titleMedium)');
expect(find.text('查看全部'), findsOneWidget);
});
testWidgets('无行尾动作 → 仅标题', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: SectionHeader(title: '活动信息')),
),
);
expect(find.text('活动信息'), findsOneWidget);
expect(find.byType(TextButton), findsNothing);
});
}