2023-03-06 21:54:32 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2023-03-06 20:38:53 +01:00
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
2023-03-06 21:54:32 +01:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2023-03-06 20:38:53 +01:00
|
|
|
import 'package:smoke_cess_app/providers/settings_provider.dart';
|
2023-03-06 22:15:29 +01:00
|
|
|
import '../mock/settings_mock.dart';
|
2023-03-06 20:38:53 +01:00
|
|
|
|
|
|
|
void main() {
|
2023-03-06 21:54:32 +01:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
SharedPreferences.setMockInitialValues(mockSettings);
|
2023-03-06 20:38:53 +01:00
|
|
|
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 {
|
2023-03-06 20:38:53 +01:00
|
|
|
final provider = SettingsProvider();
|
2023-03-06 21:54:32 +01:00
|
|
|
await provider.initSettings();
|
2023-03-06 20:38:53 +01:00
|
|
|
expect(provider.settings, isNotNull);
|
|
|
|
expect(provider.initialized, isTrue);
|
2023-03-06 21:54:32 +01:00
|
|
|
expect(provider.settings?.group, 3);
|
2023-03-06 20:38:53 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('set scanning', () {
|
|
|
|
final provider = SettingsProvider();
|
|
|
|
provider.scanning = true;
|
|
|
|
expect(provider.scanning, isTrue);
|
|
|
|
provider.scanning = false;
|
|
|
|
expect(provider.scanning, isFalse);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|