testing library

Test helpers for apps and services that use fayda_decoder.

Build realistic, fully synthetic card payloads and QR images, signed with a published test key, so tests never touch a real person's card:

import 'package:fayda_decoder/fayda_decoder.dart';
import 'package:fayda_decoder/testing.dart';

final payload = buildTestPayload(fullName: 'Hana Girma Wolde');
final result = decodePayload(payload) as FaydaSuccess;
expect(result.verify(publicKeyPem: faydaTestPublicKeyPem).verified, isTrue);

final png = buildTestQrPng(payload);
expect(await decodeImage(png), isA<FaydaSuccess>());

Import this only from tests and fixtures.

Constants

faydaTestPublicKeyPem → const String
PEM public key that verifies payloads from buildTestPayload.

Properties

faydaTestFace → Uint8List
A tiny (8x8) synthetic WebP used as the default test face.
final

Functions

buildTestPayload({String fullName = 'Abebe Kebede Alemu', FaydaGender? gender = FaydaGender.male, String? fan = '6140123412341234', DateTime? dateOfBirth, List<int>? face, String version = '4', bool signed = true, Map<String, String?> overrides = const {}}) → String
Builds a synthetic Fayda V4 QR payload for tests, so you never need a real person's card.
buildTestQrImage(String payload, {int moduleSize = 4, int quietZone = 4}) → RgbaImage
Renders payload as raw pixels, for testing decodeImageData and camera-frame code paths. See buildTestQrPng.
buildTestQrPng(String payload, {int moduleSize = 4, int quietZone = 4}) → Uint8List
Renders payload as a QR code PNG (EC level L, like real cards), for feeding decodeImage or a mocked image picker in tests.