Added Tests

main
Kai Mannweiler 2023-03-06 22:15:29 +01:00
parent 2ff821447f
commit 05f293d1b4
4 changed files with 18 additions and 9 deletions

View File

@ -1,12 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:smoke_cess_app/mock/settings_mock.dart';
import 'package:smoke_cess_app/services/date_service.dart';
import 'package:smoke_cess_app/services/pages_service.dart';
import 'package:smoke_cess_app/services/settings_service.dart';
import 'package:timezone/data/latest.dart' as tz;
import 'package:timezone/timezone.dart';
import '../mock/settings_mock.dart';
void main() async {
tz.initializeTimeZones();

View File

@ -1,8 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:smoke_cess_app/providers/input_provider.dart';
import 'package:smoke_cess_app/globals.dart' as globals;
import '../mock/db_mock.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
globals.databaseService = DatabaseMock();
group('InputProvider', () {
test('Initial values are correct', () {
late final inputProvider = InputProvider();

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:smoke_cess_app/mock/settings_mock.dart';
import 'package:smoke_cess_app/providers/settings_provider.dart';
import '../mock/settings_mock.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();

View File

@ -3,9 +3,12 @@ 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/db_mock.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
globals.databaseService = DatabaseMock();
group('WorkoutProvider', () {
late WorkoutProvider workoutProvider;
late TimerProvider timerProvider;
@ -65,12 +68,14 @@ void main() {
expect(workoutProvider.isWorkoutComplete, false);
});
// test('save workout', () {
// workoutProvider.motivationBefore = 70;
// workoutProvider.motivationAfter = 80;
// workoutProvider.saveWorkout();
test('save workout', () async {
workoutProvider.motivationBefore = 70;
workoutProvider.motivationAfter = 80;
workoutProvider.saveWorkout();
// // -> hier in datenbank nachschauen obs geklappt hat
// });
final result = await globals.databaseService.getWorkoutRecords();
expect(result.length, 1);
});
});
}