Testing · mastra-ai/mastra
Test image conversion and classification helpers for AI prompts
Adds a Vitest suite for eight pure image-handling utilities used to construct AI prompts. The tests cover data URIs, URLs, base64 strings, and binary inputs without changing production behavior.
The problem
The image utilities lacked unit coverage for their input conversion and classification behavior. Their contracts include MIME type defaults and precedence, URL passthrough, binary encoding, and handling of malformed or incomplete data URIs.
The approach
Adds a dedicated image-utils.test.ts file using Vitest assertions against the pure helpers. Tests exercise parsing and construction, round-trip conversion, binary-to-base64 paths, cache key generation, and file classification. Edge cases include missing media types, absent base64 flags, and data URIs without a comma.
What changed
Introduces additive test coverage in one new file, with no production code changes or new dependencies. The assertions record existing behavior, including preservation of content and MIME type fallback rules.
- vitest
- typescript
- unit-tests
- image-processing
- data-uri
- base64