Add kanjivg data
Build and test / build (push) Successful in 10m0s

This commit is contained in:
2026-03-03 13:47:59 +09:00
parent 8ba7c66e67
commit bbdb177fa4
20 changed files with 1195 additions and 1 deletions
+67
View File
@@ -0,0 +1,67 @@
import 'package:jadb/models/kanjivg/kanjivg_path_group.dart';
import 'package:jadb/search.dart';
import 'package:test/test.dart';
import 'setup_database_connection.dart';
Iterable<KanjiVGPathGroup> _flattenGroups(
Iterable<KanjiVGPathGroup> groups,
) sync* {
for (final group in groups) {
yield group;
yield* _flattenGroups(group.children);
}
}
void main() {
group('KanjiVG search', () {
test('returns null when the entry does not exist', () async {
final connection = await setupDatabaseConnection();
addTearDown(() async => connection.close());
final result = await connection.jadbSearchKanjiVGGraph('notfound');
expect(result, isNull);
});
test('returns entry paths without path groups by default', () async {
final connection = await setupDatabaseConnection();
addTearDown(() async => connection.close());
final result = await connection.jadbSearchKanjiVGGraph('');
expect(result, isNotNull);
expect(result!.character, equals(''));
expect(result.paths, isNotEmpty);
expect(result.pathGroups, isNull);
});
test('returns the path-group graph when requested', () async {
final connection = await setupDatabaseConnection();
addTearDown(() async => connection.close());
final result = await connection.jadbSearchKanjiVGGraph(
'',
includePathGroups: true,
);
expect(result, isNotNull);
expect(result!.pathGroups, isNotNull);
expect(result.pathGroups, isNotEmpty);
final allGroups = _flattenGroups(result.pathGroups!).toList();
final groupedPathIds =
allGroups
.expand((group) => group.paths)
.map((path) => path.pathId)
.toList()
..sort();
final entryPathIds = result.paths.map((path) => path.pathId).toList()
..sort();
expect(allGroups.any((group) => group.groupId == 0), isTrue);
expect(allGroups.any((group) => group.paths.isNotEmpty), isTrue);
expect(groupedPathIds, equals(entryPathIds));
});
});
}