57 lines
2.1 KiB
Dart
57 lines
2.1 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:words999/services/day_numerology.dart';
|
|
import 'package:words999/services/words_repository.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
setUpAll(() async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
await WordsRepository().init(remoteDailyShuffle: false);
|
|
});
|
|
|
|
test('calendar reduction keeps master numbers', () {
|
|
expect(DayNumerology.reduce(11), 11);
|
|
expect(DayNumerology.reduce(22), 22);
|
|
expect(DayNumerology.reduce(33), 33);
|
|
expect(DayNumerology.reduce(29), 11);
|
|
expect(DayNumerology.reduce(2026), 1);
|
|
expect(DayNumerology.reduce(10), 1);
|
|
|
|
final ordinary = DayNumerology.ofDate(DateTime(2026, 10, 5));
|
|
expect(ordinary.value, 7);
|
|
expect(ordinary.word, 'семь');
|
|
expect(ordinary.formula, '5 + 1 + 1 = 7');
|
|
|
|
expect(DayNumerology.ofDate(DateTime(2016, 1, 1)).value, 11);
|
|
expect(DayNumerology.ofDate(DateTime(2016, 2, 11)).value, 22);
|
|
expect(DayNumerology.ofDate(DateTime(2009, 11, 29)).value, 33);
|
|
});
|
|
|
|
test('code words and twelve stations live inside the thousand', () {
|
|
final repo = WordsRepository();
|
|
for (final name in DayNumerology.words.values) {
|
|
expect(repo.getWordByName(name), isNotNull, reason: name);
|
|
}
|
|
|
|
final file = File('assets/data/traditions_canon.json');
|
|
final canon = json.decode(file.readAsStringSync()) as Map<String, dynamic>;
|
|
final numerology = canon['numerology'] as Map<String, dynamic>;
|
|
final stations = numerology['stations'] as List;
|
|
expect(stations, hasLength(12));
|
|
for (final raw in stations) {
|
|
final station = raw as Map<String, dynamic>;
|
|
final primary = station['primary'] as Map<String, dynamic>;
|
|
final word = primary['word'] as String;
|
|
final item = repo.getWordByName(word);
|
|
expect(item, isNotNull, reason: word);
|
|
expect(item!.id, primary['id']);
|
|
expect((station['name'] as String).isNotEmpty, isTrue);
|
|
}
|
|
});
|
|
}
|