main
dart 51 lines 1.64 KB
Raw
1 import 'package:flutter/material.dart';
2 import 'package:flutter_test/flutter_test.dart';
3 import 'package:localmind/features/chat/views/components/heartbeat_dot.dart';
4
5 void main() {
6 group('HeartbeatDot', () {
7 testWidgets('renders with default size and primary color', (tester) async {
8 await tester.pumpWidget(
9 const MaterialApp(
10 home: Scaffold(body: Center(child: HeartbeatDot())),
11 ),
12 );
13
14 expect(find.byType(HeartbeatDot), findsOneWidget);
15 // Ensure initial frame renders
16 await tester.pump();
17 expect(tester.takeException(), isNull);
18 });
19
20 testWidgets('renders with custom size and custom color', (tester) async {
21 const customColor = Colors.teal;
22 await tester.pumpWidget(
23 const MaterialApp(
24 home: Scaffold(
25 body: Center(child: HeartbeatDot(size: 10, color: customColor)),
26 ),
27 ),
28 );
29
30 expect(find.byType(HeartbeatDot), findsOneWidget);
31 await tester.pump();
32 expect(tester.takeException(), isNull);
33 });
34
35 testWidgets('animates heartbeat cycle smoothly over time', (tester) async {
36 await tester.pumpWidget(
37 const MaterialApp(
38 home: Scaffold(body: Center(child: HeartbeatDot(size: 7))),
39 ),
40 );
41
42 // Advance through heartbeat phases (first beat, recoil, second beat, rest)
43 await tester.pump(const Duration(milliseconds: 200));
44 await tester.pump(const Duration(milliseconds: 300));
45 await tester.pump(const Duration(milliseconds: 400));
46 await tester.pump(const Duration(milliseconds: 500));
47
48 expect(tester.takeException(), isNull);
49 });
50 });
51 }