|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_test/flutter_test.dart'; |
| 3 | +import 'package:mockito/mockito.dart'; |
| 4 | +import 'package:taskwarrior/app/tour/task_swipe_tour.dart'; |
| 5 | +import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; |
| 6 | + |
| 7 | +class MockTutorialCoachMarkController extends Mock |
| 8 | + implements TutorialCoachMarkController {} |
| 9 | + |
| 10 | +void main() { |
| 11 | + group('Task Swipe Tour', () { |
| 12 | + late GlobalKey taskItemKey; |
| 13 | + final controller = MockTutorialCoachMarkController(); |
| 14 | + |
| 15 | + setUp(() { |
| 16 | + taskItemKey = GlobalKey(); |
| 17 | + }); |
| 18 | + |
| 19 | + test('should return a list of TargetFocus with correct properties', () { |
| 20 | + final targets = addTaskSwipeTutorialTargets( |
| 21 | + taskItemKey: taskItemKey, |
| 22 | + ); |
| 23 | + |
| 24 | + expect(targets.length, 1); |
| 25 | + |
| 26 | + expect(targets[0].keyTarget, taskItemKey); |
| 27 | + expect(targets[0].identify, "taskSwipeTutorial"); |
| 28 | + expect(targets[0].alignSkip, Alignment.bottomRight); |
| 29 | + expect(targets[0].shape, ShapeLightFocus.RRect); |
| 30 | + expect(targets[0].radius, 10); |
| 31 | + }); |
| 32 | + |
| 33 | + testWidgets('should render correct text for task swipe TargetContent', |
| 34 | + (WidgetTester tester) async { |
| 35 | + final targets = addTaskSwipeTutorialTargets( |
| 36 | + taskItemKey: taskItemKey, |
| 37 | + ); |
| 38 | + |
| 39 | + final content = targets[0].contents!.first; |
| 40 | + |
| 41 | + await tester.pumpWidget(MaterialApp( |
| 42 | + home: Builder( |
| 43 | + builder: (context) => content.builder!(context, controller), |
| 44 | + ), |
| 45 | + )); |
| 46 | + |
| 47 | + expect(find.text("Task Swipe Actions"), findsOneWidget); |
| 48 | + expect(find.text("This is how you manage your tasks quickly : "), |
| 49 | + findsOneWidget); |
| 50 | + expect(find.text("Swipe RIGHT to COMPLETE"), findsOneWidget); |
| 51 | + expect(find.text("Swipe LEFT to DELETE"), findsOneWidget); |
| 52 | + }); |
| 53 | + }); |
| 54 | +} |
0 commit comments