marquee_text_test.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import 'package:cardash_launcher/features/home/widgets/marquee_text.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_test/flutter_test.dart';
  4. void main() {
  5. testWidgets('long text duplicates for a seamless loop', (tester) async {
  6. const title = 'A very long song title that cannot possibly fit';
  7. await tester.pumpWidget(
  8. const MaterialApp(
  9. home: Scaffold(
  10. body: SizedBox(
  11. width: 140,
  12. child: MarqueeText(text: title, animate: true),
  13. ),
  14. ),
  15. ),
  16. );
  17. await tester.pump(const Duration(milliseconds: 100));
  18. expect(tester.takeException(), isNull);
  19. expect(find.text(title), findsNWidgets(2));
  20. });
  21. testWidgets('paused marquee does not animate', (tester) async {
  22. const title = 'A very long song title that cannot possibly fit';
  23. await tester.pumpWidget(
  24. const MaterialApp(
  25. home: Scaffold(
  26. body: SizedBox(
  27. width: 140,
  28. child: MarqueeText(text: title, animate: false),
  29. ),
  30. ),
  31. ),
  32. );
  33. await tester.pump();
  34. expect(tester.binding.transientCallbackCount, 0);
  35. });
  36. }