forked from eatvio/eatvio_app
chore(dependencies): add webview_flutter_platform_interface package to pubspec.yaml and clean up test files by removing unnecessary whitespace
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/user_details/presentation/widgets/expandable_bouble.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('ExpandableBouble', () {
|
||||
testWidgets('displays title correctly', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: ExpandableBouble(
|
||||
title: 'Test Title',
|
||||
children: [Text('Child 1'), Text('Child 2')],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Test Title'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays children when expanded', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: ExpandableBouble(
|
||||
title: 'Test Title',
|
||||
initiallyExpanded: true,
|
||||
children: [Text('Child 1'), Text('Child 2')],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Child 1'), findsOneWidget);
|
||||
expect(find.text('Child 2'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('hides children when collapsed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: ExpandableBouble(
|
||||
title: 'Test Title',
|
||||
initiallyExpanded: false,
|
||||
children: [Text('Child 1'), Text('Child 2')],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Children should not be visible when collapsed
|
||||
expect(find.text('Child 1'), findsNothing);
|
||||
expect(find.text('Child 2'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('expands and collapses on tap', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: ExpandableBouble(
|
||||
title: 'Test Title',
|
||||
initiallyExpanded: false,
|
||||
children: [Text('Child 1')],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Initially collapsed
|
||||
expect(find.text('Child 1'), findsNothing);
|
||||
|
||||
// Tap to expand
|
||||
await tester.tap(find.text('Test Title'));
|
||||
await tester.pumpAndSettle(const Duration(seconds: 2));
|
||||
|
||||
// Should be expanded now
|
||||
expect(find.text('Child 1'), findsOneWidget);
|
||||
|
||||
// Tap to collapse
|
||||
await tester.tap(find.text('Test Title'));
|
||||
await tester.pumpAndSettle(const Duration(seconds: 2));
|
||||
|
||||
// Should be collapsed again
|
||||
expect(find.text('Child 1'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('works with empty children list', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: ExpandableBouble(
|
||||
title: 'Empty Title',
|
||||
children: [],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Empty Title'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('works with multiple children', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: ExpandableBouble(
|
||||
title: 'Multiple Children',
|
||||
initiallyExpanded: true,
|
||||
children: [
|
||||
Text('Child 1'),
|
||||
Text('Child 2'),
|
||||
Text('Child 3'),
|
||||
Text('Child 4'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Child 1'), findsOneWidget);
|
||||
expect(find.text('Child 2'), findsOneWidget);
|
||||
expect(find.text('Child 3'), findsOneWidget);
|
||||
expect(find.text('Child 4'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user