forked from eatvio/eatvio_app
68 lines
2.0 KiB
Dart
68 lines
2.0 KiB
Dart
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('Toasts', () {
|
|
test('showInfoToast is callable', () {
|
|
// Note: This test verifies the function exists and can be called
|
|
// Actual toast display requires Flutter context and cannot be easily tested
|
|
expect(showInfoToast, isA<Function>());
|
|
});
|
|
|
|
test('showErrorToast is callable', () {
|
|
expect(showErrorToast, isA<Function>());
|
|
});
|
|
|
|
test('showSuccessToast is callable', () {
|
|
expect(showSuccessToast, isA<Function>());
|
|
});
|
|
|
|
test('showInternetConnectionToast is callable', () {
|
|
expect(showInternetConnectionToast, isA<Function>());
|
|
});
|
|
|
|
testWidgets('showInfoToast accepts string parameter', (tester) async {
|
|
// Verify function signature - MissingPluginException is expected in tests
|
|
// Fluttertoast.showToast is async, so we need to handle it properly
|
|
try {
|
|
showInfoToast('Test message');
|
|
// Wait a bit for async operations
|
|
await tester.pump();
|
|
} catch (e) {
|
|
// MissingPluginException is expected in test environment
|
|
expect(e, isA<MissingPluginException>());
|
|
}
|
|
});
|
|
|
|
testWidgets('showErrorToast accepts string parameter', (tester) async {
|
|
try {
|
|
showErrorToast('Test error');
|
|
await tester.pump();
|
|
} catch (e) {
|
|
expect(e, isA<MissingPluginException>());
|
|
}
|
|
});
|
|
|
|
testWidgets('showSuccessToast accepts string parameter', (tester) async {
|
|
try {
|
|
showSuccessToast('Test success');
|
|
await tester.pump();
|
|
} catch (e) {
|
|
expect(e, isA<MissingPluginException>());
|
|
}
|
|
});
|
|
|
|
testWidgets('showInternetConnectionToast has no parameters', (tester) async {
|
|
try {
|
|
showInternetConnectionToast();
|
|
await tester.pump();
|
|
} catch (e) {
|
|
expect(e, isA<MissingPluginException>());
|
|
}
|
|
});
|
|
});
|
|
}
|