StarRailCopilot/webapp/packages/preload/tests/unit.spec.ts
2023-09-10 00:22:01 +08:00

16 lines
460 B
TypeScript

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