dte-signer-sv
Version:
Sign Digital Tax Documents (DTE) for El Salvador's Ministry of Finance
39 lines • 1.62 kB
JavaScript
import { hash } from "../lib/crypto";
describe("Crypto", () => {
describe("hash", () => {
it("should create SHA-512 hash", () => {
const input = "test123";
const result = hash(input);
// SHA-512 produces 128 character hex string
expect(result).toHaveLength(128);
expect(result).toMatch(/^[a-f0-9]+$/);
});
it("should produce consistent hashes", () => {
const input = "testPassword123";
const hash1 = hash(input);
const hash2 = hash(input);
expect(hash1).toBe(hash2);
});
it("should produce different hashes for different inputs", () => {
const hash1 = hash("password1");
const hash2 = hash("password2");
expect(hash1).not.toBe(hash2);
});
it("should handle empty string", () => {
const result = hash("");
expect(result).toHaveLength(128);
});
it("should handle special characters", () => {
const input = "test!@#$%^&*()_+-=[]{}|;':\",./<>?";
const result = hash(input);
expect(result).toHaveLength(128);
});
it("should match expected hash for known input", () => {
const input = "newpassword123";
const expectedHash = "f1fa51e19d62308105f92952febe4273eb683c7c65540f67d9abecebcdba877e3bfa87f4f65f2b5121e878a7655d4cc7ab313c463d9c08875fe9e76473bbbbf4";
const result = hash(input);
expect(result).toBe(expectedHash);
});
});
});
//# sourceMappingURL=crypto.test.js.map