cpd_2022_zi/test/unit_tests/settings_provider_test.dart

35 lines
1.1 KiB
Dart
Raw Permalink Normal View History

2023-03-06 21:54:32 +01:00
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
2023-03-06 21:54:32 +01:00
import 'package:shared_preferences/shared_preferences.dart';
import 'package:smoke_cess_app/providers/settings_provider.dart';
2023-03-06 22:15:29 +01:00
import '../mock/settings_mock.dart';
void main() {
2023-03-06 21:54:32 +01:00
WidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues(mockSettings);
group('SettingsProvider', () {
test('initial state', () {
final provider = SettingsProvider();
expect(provider.settings, isNull);
expect(provider.initialized, isFalse);
expect(provider.scanning, isFalse);
});
2023-03-06 21:54:32 +01:00
test('initialize mocksettings', () async {
final provider = SettingsProvider();
2023-03-06 21:54:32 +01:00
await provider.initSettings();
expect(provider.settings, isNotNull);
expect(provider.initialized, isTrue);
2023-03-06 21:54:32 +01:00
expect(provider.settings?.group, 3);
});
test('set scanning', () {
final provider = SettingsProvider();
provider.scanning = true;
expect(provider.scanning, isTrue);
provider.scanning = false;
expect(provider.scanning, isFalse);
});
});
}