63 lines
2.2 KiB
Dart
63 lines
2.2 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|||
|
|
import 'package:flutter_test/flutter_test.dart';
|
|||
|
|
import 'package:meeyao_qianwen/app/app_theme.dart';
|
|||
|
|
import 'package:meeyao_qianwen/features/divination/data/models/divination_params.dart';
|
|||
|
|
import 'package:meeyao_qianwen/features/divination/presentation/screens/auto_divination_screen.dart';
|
|||
|
|
import 'package:meeyao_qianwen/features/divination/presentation/screens/divination_screen.dart';
|
|||
|
|
import 'package:meeyao_qianwen/features/divination/presentation/screens/manual_divination_screen.dart';
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
testWidgets('divination screen navigates to auto screen', (tester) async {
|
|||
|
|
await tester.pumpWidget(
|
|||
|
|
MaterialApp(theme: AppTheme.light(), home: const DivinationScreen()),
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
await tester.tap(find.text('自动起卦'));
|
|||
|
|
await tester.enterText(find.byType(TextField), '最近事业发展是否顺利');
|
|||
|
|
await tester.tap(find.text('开始起卦'));
|
|||
|
|
await tester.pumpAndSettle();
|
|||
|
|
|
|||
|
|
expect(find.byType(AutoDivinationScreen), findsOneWidget);
|
|||
|
|
expect(find.text('○ 老阳(变)'), findsOneWidget);
|
|||
|
|
expect(find.text('× 老阴(变)'), findsOneWidget);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
testWidgets('auto screen keeps resolve button disabled initially', (
|
|||
|
|
tester,
|
|||
|
|
) async {
|
|||
|
|
final params = DivinationMockData.initial().copyWith(
|
|||
|
|
method: DivinationMethod.auto,
|
|||
|
|
question: '测试问题',
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
await tester.pumpWidget(
|
|||
|
|
MaterialApp(
|
|||
|
|
theme: AppTheme.light(),
|
|||
|
|
home: AutoDivinationScreen(params: params),
|
|||
|
|
),
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
final resolveButton = tester.widget<FilledButton>(
|
|||
|
|
find.widgetWithText(FilledButton, '开始解卦'),
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
expect(resolveButton.onPressed, isNull);
|
|||
|
|
expect(find.text('您还需摇 6 次'), findsOneWidget);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
testWidgets('divination screen navigates to manual screen by default', (
|
|||
|
|
tester,
|
|||
|
|
) async {
|
|||
|
|
await tester.pumpWidget(
|
|||
|
|
MaterialApp(theme: AppTheme.light(), home: const DivinationScreen()),
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
await tester.enterText(find.byType(TextField), '近期感情是否稳定');
|
|||
|
|
await tester.tap(find.text('开始起卦'));
|
|||
|
|
await tester.pump();
|
|||
|
|
await tester.pump(const Duration(milliseconds: 300));
|
|||
|
|
|
|||
|
|
expect(find.byType(ManualDivinationScreen), findsOneWidget);
|
|||
|
|
});
|
|||
|
|
}
|