// This file is auto-generated by alef — DO NOT EDIT. // alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75 // To regenerate: alef generate // To verify freshness: alef verify --exit-code // Issues & docs: https://github.com/kreuzberg-dev/alef // ignore_for_file: unused_local_variable import 'package:test/test.dart'; import 'dart:io'; import 'package:kreuzberg/kreuzberg.dart'; import 'package:kreuzberg/src/kreuzberg_bridge_generated/frb_generated.dart' show RustLib; // E2e tests for category: async String _alefE2eText(Object? value) { if (value == null) return ''; // Check if it's an enum by examining its toString representation. final str = value.toString(); if (str.contains('.')) { // Enum.toString() returns 'EnumName.variantName'. Extract the variant name. final parts = str.split('.'); if (parts.length == 2) { final variantName = parts[1]; // Convert camelCase variant names to snake_case for serde compatibility. // E.g. 'toolCalls' -> 'tool_calls', 'stop' -> 'stop'. return _camelToSnake(variantName); } } return str; } String _camelToSnake(String camel) { final buffer = StringBuffer(); for (int i = 0; i < camel.length; i++) { final char = camel[i]; if (char.contains(RegExp(r'[A-Z]'))) { if (i > 0) buffer.write('_'); buffer.write(char.toLowerCase()); } else { buffer.write(char); } } return buffer.toString(); } void main() { setUpAll(() async { await RustLib.init(); final _testDocs = Platform.environment['FIXTURES_DIR'] ?? '../../test_documents'; final _dir = Directory(_testDocs); if (_dir.existsSync()) Directory.current = _dir; }); test('Async extract_bytes call on PDF document', () async { final result = await KreuzbergBridge.extractBytes(File('pdf/fake_memo.pdf').readAsBytesSync(), 'application/pdf'); expect(result.mimeType.toString().trim(), equals('application/pdf'.toString().trim())); expect(result.content.length, greaterThanOrEqualTo(50)); }); test('extract_bytes empty MIME async', () async { await expectLater(KreuzbergBridge.extractBytes(File('text/plain.txt').readAsBytesSync(), ''), throwsA(anything)); }); test('extract_bytes unsupported MIME async', () async { await expectLater(KreuzbergBridge.extractBytes(File('text/plain.txt').readAsBytesSync(), 'application/x-nonexistent'), throwsA(anything)); }); }