archive-nested-context.spec.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { describe, expect, it, vi } from 'vitest';
  2. import { buildArchiveNestedRenderContext } from '../packages/renderers/archive/src/archiveShared';
  3. import type { FileRenderContext } from '../packages/core/src';
  4. describe('archive nested render context', () => {
  5. it('renders extracted children from bytes instead of inheriting the parent archive stream URL', () => {
  6. const renderNestedBuffer = vi.fn();
  7. const registerExportAdapter = vi.fn();
  8. const parentContext: FileRenderContext = {
  9. filename: 'documents.zip',
  10. url: '/example/documents.zip',
  11. streamUrl: '/example/documents.zip',
  12. options: {
  13. theme: 'light',
  14. pdf: {
  15. streaming: true,
  16. },
  17. archive: {
  18. cache: true,
  19. },
  20. },
  21. registerExportAdapter,
  22. renderNestedBuffer,
  23. };
  24. const nestedContext = buildArchiveNestedRenderContext(
  25. parentContext,
  26. { name: 'contract.pdf' },
  27. parentContext.options?.archive
  28. );
  29. expect(nestedContext.filename).toBe('contract.pdf');
  30. expect(nestedContext.url).toBeUndefined();
  31. expect(nestedContext.streamUrl).toBeUndefined();
  32. expect(nestedContext.renderNestedBuffer).toBe(renderNestedBuffer);
  33. expect(nestedContext.registerExportAdapter).toBe(registerExportAdapter);
  34. expect(nestedContext.options?.theme).toBe('light');
  35. expect(nestedContext.options?.pdf?.streaming).toBe(true);
  36. expect(nestedContext.options?.archive?.cache).toBe(true);
  37. });
  38. });