unit.spec.ts 503 B

1234567891011121314151617181920
  1. import {createHash} from 'crypto';
  2. import {expect, test} from 'vitest';
  3. import {versions, sha256sum} from '../src';
  4. test('versions', async () => {
  5. expect(versions).toBe(process.versions);
  6. });
  7. test('nodeCrypto', async () => {
  8. /**
  9. * Random string to test hashing
  10. */
  11. const testString = Math.random().toString(36).slice(2, 7);
  12. const expectedHash = createHash('sha256')
  13. .update(testString)
  14. .digest('hex');
  15. expect(sha256sum(testString)).toBe(expectedHash);
  16. });