only-bible-app v3.7.2+24
git clone https://git.pyrossh.dev/only-bible-app
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
test/actions_backup_test.dart
import "dart:convert";
import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
import "package:only_bible_app/store/actions_backup.dart";
import "package:only_bible_app/store/app_state.dart";
import "app_logic_test.dart" show buildTestBible;
void main() {
group("buildBackupFileName", () {
test("formats a zero-padded date", () {
expect(
buildBackupFileName(DateTime.utc(2026, 3, 5)),
"only_bible_app_backup_2026-03-05.json",
);
});
});
group("buildBackupJson / parseBackupState", () {
test("round-trips highlights and settings through export and import", () async {
final bible = buildTestBible();
final state = AppState(
bible: bible,
themeMode: ThemeMode.dark,
fontSize: 22,
highlights: {"0:0:0": 2},
highlightHistory: [
HighlightHistoryEntry(book: 0, chapter: 0, verseIndex: 0, colorIndex: 2, timestamp: DateTime.utc(2026, 1, 1)),
],
);
final jsonString = buildBackupJson(state);
final restored = await parseBackupState(jsonString, loadBibleFn: (_) async => bible);
expect(restored.themeMode, ThemeMode.dark);
expect(restored.fontSize, 22);
expect(restored.highlights["0:0:0"], 2);
expect(restored.highlightHistory.single.colorIndex, 2);
});
test("rejects malformed JSON", () async {
expect(
() => parseBackupState("not json", loadBibleFn: (_) async => buildTestBible()),
throwsA(isA<BackupParseException>()),
);
});
test("rejects valid JSON that isn't an object", () async {
expect(
() => parseBackupState(jsonEncode([1, 2, 3]), loadBibleFn: (_) async => buildTestBible()),
throwsA(isA<BackupParseException>()),
);
});
test("rejects a bibleName the app can't load", () async {
expect(
() => parseBackupState(
jsonEncode({"bibleName": "does_not_exist"}),
loadBibleFn: (_) async => throw Exception("no such asset"),
),
throwsA(isA<BackupParseException>()),
);
});
});
}