mirror of
https://github.com/Ujwal223/FocusGram.git
synced 2026-08-20 12:57:13 +02:00
Feature Pack with bug fixes for V2
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:focusgram/services/level_service.dart';
|
||||
|
||||
@@ -9,7 +8,6 @@ void main() {
|
||||
|
||||
setUp(() async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
// Ensure Hive is available for LevelService
|
||||
if (!Hive.isAdapterRegistered(0)) {
|
||||
await Hive.initFlutter();
|
||||
}
|
||||
@@ -17,13 +15,9 @@ void main() {
|
||||
|
||||
group('AppFeature — Your Journey unlock table', () {
|
||||
test('fullDmGhost is NOT in the all list', () async {
|
||||
// fullDmGhost should still be defined as a constant
|
||||
expect(AppFeature.fullDmGhost, isNotNull);
|
||||
|
||||
// But should NOT appear in the unlock table shown to users
|
||||
final contains = AppFeature.all.any(
|
||||
(f) => f.id == 'full_dm_ghost',
|
||||
);
|
||||
final contains = AppFeature.all.any((f) => f.id == 'full_dm_ghost');
|
||||
expect(contains, isFalse);
|
||||
});
|
||||
|
||||
@@ -47,20 +41,12 @@ void main() {
|
||||
|
||||
group('LevelService — No Firestore dependency', () {
|
||||
test('init succeeds without Firestore (uses Hive only)', () async {
|
||||
// This would crash if init tried to reach Firestore
|
||||
// Since we removed Firebase, it should work with just Hive cache
|
||||
final levelService = LevelService();
|
||||
|
||||
// Should not throw — even if no Firestore is available
|
||||
await expectLater(
|
||||
() => levelService.init(),
|
||||
returnsNormally,
|
||||
);
|
||||
await expectLater(() => levelService.init(), returnsNormally);
|
||||
|
||||
// Default state
|
||||
expect(levelService.level, equals(1));
|
||||
expect(levelService.xp, equals(0));
|
||||
expect(levelService.synced, isFalse);
|
||||
});
|
||||
|
||||
test('addXpForAd awards XP without Firestore', () async {
|
||||
@@ -73,14 +59,13 @@ void main() {
|
||||
expect(levelService.adsWatchedTotal, equals(1));
|
||||
});
|
||||
|
||||
test('debugSetLevel works with Hive-only storage', () async {
|
||||
test('level progresses from XP', () async {
|
||||
final levelService = LevelService();
|
||||
await levelService.init();
|
||||
|
||||
await levelService.debugSetLevel(3, 300);
|
||||
|
||||
expect(levelService.level, equals(3));
|
||||
expect(levelService.xp, equals(300));
|
||||
expect(levelService.level, equals(1));
|
||||
expect(levelService.xp, equals(0));
|
||||
expect(levelService.levelProgress, equals(0.0));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user