This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
viscord/packages/preload/tests/unit.spec.ts

21 lines
483 B
TypeScript

import {createHash} from 'crypto';
import {expect, test} from 'vitest';
import {versions, sha256sum} from '../src';
test('versions', async () => {
expect(versions).toBe(process.versions);
});
test('nodeCrypto', async () => {
/**
* Random string to test hashing
*/
const testString = Math.random().toString(36).slice(2, 7);
const expectedHash = createHash('sha256')
.update(testString)
.digest('hex');
expect(sha256sum(testString)).toBe(expectedHash);
});