import 'package:eatvio_app/core/utils/toasts.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('Toast Functions', () { setUpAll(() { // Mock Fluttertoast plugin TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler( const MethodChannel('PonnamKarthik/fluttertoast'), (MethodCall methodCall) async { return null; }, ); }); tearDownAll(() { // Clear mock handlers TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler( const MethodChannel('PonnamKarthik/fluttertoast'), null, ); }); test('showInfoToast can be called without errors', () { // This function shows a toast, which is hard to test directly // In tests, we mock the plugin to avoid MissingPluginException showInfoToast('Test info message'); // Test passes if no exception is thrown }); test('showErrorToast can be called without errors', () { showErrorToast('Test error message'); }); test('showSuccessToast can be called without errors', () { showSuccessToast('Test success message'); }); test('showInternetConnectionToast can be called without errors', () { showInternetConnectionToast(); }); test('showInfoToast accepts different messages', () { final messages = ['Message 1', 'Message 2', 'Long message with special chars: !@#\$%']; for (final message in messages) { showInfoToast(message); } }); test('showErrorToast accepts different messages', () { final messages = ['Error 1', 'Error 2', 'Critical error occurred']; for (final message in messages) { showErrorToast(message); } }); test('showSuccessToast accepts different messages', () { final messages = ['Success 1', 'Success 2', 'Operation completed successfully']; for (final message in messages) { showSuccessToast(message); } }); }); }