apiClient.spec.ts 705 B

1234567891011121314151617181920
  1. import { describe, expect, it } from 'vitest';
  2. import { sha256Hex } from '../../src/api/hmac';
  3. describe('hmac helpers', () => {
  4. it('hashes body as lowercase hex sha256', async () => {
  5. await expect(sha256Hex('{"a":1}')).resolves.toBe('015abd7f5cc57a2dd94b7590f04ad8084273905ee33ec5cebeae62276a97f862');
  6. });
  7. it('produces consistent hash for same input', async () => {
  8. const hash1 = await sha256Hex('hello');
  9. const hash2 = await sha256Hex('hello');
  10. expect(hash1).toBe(hash2);
  11. });
  12. it('produces different hashes for different input', async () => {
  13. const hash1 = await sha256Hex('hello');
  14. const hash2 = await sha256Hex('world');
  15. expect(hash1).not.toBe(hash2);
  16. });
  17. });