mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 02:10:12 -06:00
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>
52 lines
1.3 KiB
TypeScript
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);
|
|
});
|
|
});
|