mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
feat(ipuaro): implement v0.1.0 foundation
- Project setup with tsup, vitest, ESM support - Domain entities: Session, Project - Value objects: FileData, FileAST, FileMeta, ChatMessage, ToolCall, ToolResult, UndoEntry - Service interfaces: IStorage, ILLMClient, ITool, IIndexer, IToolRegistry - Shared: Config (zod), IpuaroError, utils (hash, tokens), Result type - CLI with placeholder commands (start, init, index) - 91 unit tests with 100% coverage - Fix package scope @puaros -> @samiyev in CLAUDE.md
This commit is contained in:
56
packages/ipuaro/tests/unit/shared/utils/hash.test.ts
Normal file
56
packages/ipuaro/tests/unit/shared/utils/hash.test.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { describe, it, expect } from "vitest"
|
||||
import { md5, hashLines, shortHash } from "../../../../src/shared/utils/hash.js"
|
||||
|
||||
describe("hash utils", () => {
|
||||
describe("md5", () => {
|
||||
it("should return consistent hash for same input", () => {
|
||||
const hash1 = md5("hello")
|
||||
const hash2 = md5("hello")
|
||||
|
||||
expect(hash1).toBe(hash2)
|
||||
})
|
||||
|
||||
it("should return different hash for different input", () => {
|
||||
const hash1 = md5("hello")
|
||||
const hash2 = md5("world")
|
||||
|
||||
expect(hash1).not.toBe(hash2)
|
||||
})
|
||||
|
||||
it("should return 32 character hex string", () => {
|
||||
const hash = md5("test")
|
||||
|
||||
expect(hash).toHaveLength(32)
|
||||
expect(hash).toMatch(/^[a-f0-9]+$/)
|
||||
})
|
||||
})
|
||||
|
||||
describe("hashLines", () => {
|
||||
it("should hash joined lines", () => {
|
||||
const lines = ["line1", "line2", "line3"]
|
||||
const hash = hashLines(lines)
|
||||
|
||||
expect(hash).toBe(md5("line1\nline2\nline3"))
|
||||
})
|
||||
|
||||
it("should handle empty array", () => {
|
||||
const hash = hashLines([])
|
||||
|
||||
expect(hash).toBe(md5(""))
|
||||
})
|
||||
})
|
||||
|
||||
describe("shortHash", () => {
|
||||
it("should return truncated hash", () => {
|
||||
const hash = shortHash("test")
|
||||
|
||||
expect(hash).toHaveLength(8)
|
||||
})
|
||||
|
||||
it("should accept custom length", () => {
|
||||
const hash = shortHash("test", 12)
|
||||
|
||||
expect(hash).toHaveLength(12)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user