Files
formbricks-formbricks/apps/web/lib/hash-string.test.ts
Victor Hugo dos Santos ef973c8995 chore: merge rate limiter epic branch into main (#6236)
Co-authored-by: Harsh Bhat <90265455+harshsbhat@users.noreply.github.com>
Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Piyush Gupta <56182734+gupta-piyush19@users.noreply.github.com>
Co-authored-by: Aditya <162564995+Naidu-4444@users.noreply.github.com>
Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com>
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
Co-authored-by: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com>
Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
Co-authored-by: Jakob Schott <154420406+jakobsitory@users.noreply.github.com>
Co-authored-by: Suraj <surajsuthar0067@gmail.com>
Co-authored-by: Kshitij Sharma <63995641+kshitij-codes@users.noreply.github.com>
Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
2025-07-16 12:28:59 +00:00

52 lines
1.3 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { hashString } from "./hash-string";
describe("hashString", () => {
test("should return a string", () => {
const input = "test string";
const hash = hashString(input);
expect(typeof hash).toBe("string");
expect(hash.length).toBeGreaterThan(0);
});
test("should produce consistent hashes for the same input", () => {
const input = "test string";
const hash1 = hashString(input);
const hash2 = hashString(input);
expect(hash1).toBe(hash2);
});
test("should handle empty strings", () => {
const hash = hashString("");
expect(typeof hash).toBe("string");
expect(hash.length).toBeGreaterThan(0);
});
test("should handle special characters", () => {
const input = "!@#$%^&*()_+{}|:<>?";
const hash = hashString(input);
expect(typeof hash).toBe("string");
expect(hash.length).toBeGreaterThan(0);
});
test("should handle unicode characters", () => {
const input = "Hello, 世界!";
const hash = hashString(input);
expect(typeof hash).toBe("string");
expect(hash.length).toBeGreaterThan(0);
});
test("should handle long strings", () => {
const input = "a".repeat(1000);
const hash = hashString(input);
expect(typeof hash).toBe("string");
expect(hash.length).toBeGreaterThan(0);
});
});