cache.test.ts 813 B

12345678910111213141516171819202122232425262728293031323334
  1. import { describe, expect, test } from 'bun:test';
  2. import { buildCacheKey } from './cache';
  3. describe('smartfetch/cache', () => {
  4. test('includes save_binary but not format in the cache key', () => {
  5. const markdownKey = buildCacheKey(
  6. 'https://example.com/docs',
  7. true,
  8. 'auto',
  9. false,
  10. );
  11. const htmlKey = buildCacheKey(
  12. 'https://example.com/docs',
  13. true,
  14. 'auto',
  15. false,
  16. );
  17. const binaryKey = buildCacheKey(
  18. 'https://example.com/docs',
  19. true,
  20. 'auto',
  21. true,
  22. );
  23. expect(markdownKey).toBe(htmlKey);
  24. expect(markdownKey).not.toBe(binaryKey);
  25. expect(JSON.parse(markdownKey)).toMatchObject({
  26. saveBinary: false,
  27. });
  28. expect(JSON.parse(binaryKey)).toMatchObject({
  29. saveBinary: true,
  30. });
  31. });
  32. });