|
| 1 | +import 'package:flutter/material.dart' as material; |
| 2 | +import 'package:flutter_test/flutter_test.dart'; |
| 3 | +import 'package:querya_desktop/core/widgets/virtual_selectable_text_view.dart'; |
| 4 | + |
| 5 | +void main() { |
| 6 | + group('VirtualSelectableTextView', () { |
| 7 | + testWidgets('renders SingleChildScrollView + SelectableText below threshold', (tester) async { |
| 8 | + const text = 'line 1\nline 2\nline 3'; |
| 9 | + await tester.pumpWidget( |
| 10 | + const material.MaterialApp( |
| 11 | + home: material.Scaffold( |
| 12 | + body: VirtualSelectableTextView( |
| 13 | + text: text, |
| 14 | + threshold: 10, |
| 15 | + ), |
| 16 | + ), |
| 17 | + ), |
| 18 | + ); |
| 19 | + |
| 20 | + expect(find.byType(material.SingleChildScrollView), findsOneWidget); |
| 21 | + expect(find.byType(material.ListView), findsNothing); |
| 22 | + expect(find.text(text), findsOneWidget); |
| 23 | + }); |
| 24 | + |
| 25 | + testWidgets('renders ListView.builder above threshold', (tester) async { |
| 26 | + final text = List.generate(50, (i) => 'Virtual Line $i').join('\n'); |
| 27 | + await tester.pumpWidget( |
| 28 | + material.MaterialApp( |
| 29 | + home: material.Scaffold( |
| 30 | + body: VirtualSelectableTextView( |
| 31 | + text: text, |
| 32 | + threshold: 10, |
| 33 | + ), |
| 34 | + ), |
| 35 | + ), |
| 36 | + ); |
| 37 | + |
| 38 | + expect(find.byType(material.SingleChildScrollView), findsNothing); |
| 39 | + expect(find.byType(material.ListView), findsOneWidget); |
| 40 | + expect(find.text('Virtual Line 0'), findsOneWidget); |
| 41 | + expect(find.text('Virtual Line 1'), findsOneWidget); |
| 42 | + }); |
| 43 | + }); |
| 44 | +} |
0 commit comments