import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; import 'package:smoke_cess_app/providers/audio_provider.dart'; import 'package:smoke_cess_app/providers/timer_provider.dart'; import 'package:smoke_cess_app/providers/workout_provider.dart'; import 'package:smoke_cess_app/globals.dart' as globals; import '../mock/audio_provider_mock.dart'; import '../mock/db_mock.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); globals.databaseService = DatabaseMock(); group('WorkoutProvider', () { late WorkoutProvider workoutProvider; late TimerProvider timerProvider; late AudioProvider audioProvider; setUp(() { timerProvider = TimerProvider(); audioProvider = AudioProviderMock(); workoutProvider = WorkoutProvider(timerProvider, audioProvider); }); test('initial values', () { expect(workoutProvider.isWorkoutStarted, false); expect(workoutProvider.isWorkoutComplete, false); expect(workoutProvider.motivationBefore, 50); expect(workoutProvider.motivationAfter, 50); expect(workoutProvider.currentPhase, WorkoutPhases.warmUp); expect(workoutProvider.currentPhaseDuration, const Duration(minutes: 5)); expect(workoutProvider.isPhaseComplete, false); expect(workoutProvider.currentPhaseColor, Colors.green); expect(workoutProvider.currentPhaseTitle, 'Warm Up'); }); test('next phase', () { workoutProvider.nextPhase(); expect(workoutProvider.currentPhase, WorkoutPhases.highIntensity); expect(workoutProvider.currentPhaseDuration, const Duration(minutes: 4)); expect(workoutProvider.isPhaseComplete, false); expect(workoutProvider.currentPhaseColor, Colors.red); expect(workoutProvider.currentPhaseTitle, 'High Intensity'); }); test('start workout', () { workoutProvider.startWorkout(); expect(workoutProvider.isWorkoutStarted, true); expect(workoutProvider.isWorkoutComplete, false); expect(workoutProvider.currentPhase, WorkoutPhases.warmUp); expect(workoutProvider.currentPhaseDuration, const Duration(minutes: 5)); expect(workoutProvider.isPhaseComplete, false); }); test('stop workout', () { workoutProvider.startWorkout(); workoutProvider.stopWorkout(); expect(workoutProvider.isWorkoutStarted, false); expect(workoutProvider.isWorkoutComplete, true); }); test('interrupt workout', () { workoutProvider.startWorkout(); workoutProvider.interruptWorkout(); expect(workoutProvider.isWorkoutStarted, false); expect(workoutProvider.isWorkoutComplete, false); }); test('save workout', () async { workoutProvider.motivationBefore = 70; workoutProvider.motivationAfter = 80; workoutProvider.saveWorkout(); final result = await globals.databaseService.getWorkoutRecords(); expect(result.length, 1); }); }); }