import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:water_management_system/services/auth_service.dart'; void main() { group('AuthService', () { late AuthService authService; setUp(() { SharedPreferences.setMockInitialValues({}); authService = AuthService(); }); test('initial state should not be authenticated', () { expect(authService.isAuthenticated, false); expect(authService.token, null); expect(authService.isLoading, false); }); test('login failure should keep not authenticated', () async { final result = await authService.login('invalid', 'wrong'); expect(result, false); expect(authService.isAuthenticated, false); }); test('logout should clear auth data', () async { await authService.logout(); expect(authService.isAuthenticated, false); expect(authService.token, null); }); test('isLoading should be false after operation', () async { await authService.login('test', 'test'); expect(authService.isLoading, false); }); }); }