balancer.test.ts 863 B

1234567891011121314151617181920212223242526272829
  1. /// <reference types="vite/client" />
  2. import { describe, expect, it } from 'vitest';
  3. import { BalancerObjectSchema } from '@/schemas/routing';
  4. const fixtures = import.meta.glob<unknown>('./golden/fixtures/balancer/*.json', {
  5. eager: true,
  6. import: 'default',
  7. });
  8. function fixtureName(path: string): string {
  9. const file = path.split('/').pop() ?? path;
  10. return file.replace(/\.json$/, '');
  11. }
  12. describe('BalancerObjectSchema fixtures', () => {
  13. const entries = Object.entries(fixtures).sort(([a], [b]) => a.localeCompare(b));
  14. expect(
  15. entries.length,
  16. 'expected at least one fixture under golden/fixtures/balancer',
  17. ).toBeGreaterThan(0);
  18. for (const [path, raw] of entries) {
  19. it(`parses ${fixtureName(path)} byte-stably`, () => {
  20. const parsed = BalancerObjectSchema.parse(raw);
  21. expect(parsed).toMatchSnapshot();
  22. });
  23. }
  24. });