feat(tests): add fixtures

This commit is contained in:
mso7nueh
2025-11-20 16:58:56 +03:00
parent 6fa944b3df
commit 4deda92c5e
24 changed files with 6852 additions and 4358 deletions

30
test/fixtures/fixture_reader.dart vendored Normal file
View File

@@ -0,0 +1,30 @@
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;
/// Utility that reads JSON fixtures from `test/fixtures`.
///
/// Using files instead of inline maps makes it explicit which payloads
/// are exchanged with the backend.
class FixtureReader {
const FixtureReader._();
static String readAsString(String relativePath) {
final file = File(_resolve(relativePath));
return file.readAsStringSync();
}
static Map<String, dynamic> readAsMap(String relativePath) {
return jsonDecode(readAsString(relativePath)) as Map<String, dynamic>;
}
static List<dynamic> readAsList(String relativePath) {
return jsonDecode(readAsString(relativePath)) as List<dynamic>;
}
static String _resolve(String relativePath) {
return p.normalize(p.join('test', 'fixtures', relativePath));
}
}