Files
puaros/packages/ipuaro/tests/unit/domain/value-objects/FileData.test.ts
imfozilbek 130a8c4f24 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
2025-11-29 23:08:38 +05:00

40 lines
1.2 KiB
TypeScript

import { describe, it, expect } from "vitest"
import {
createFileData,
isFileDataEqual,
} from "../../../../src/domain/value-objects/FileData.js"
describe("FileData", () => {
describe("createFileData", () => {
it("should create FileData with all fields", () => {
const lines = ["line1", "line2"]
const hash = "abc123"
const size = 100
const lastModified = Date.now()
const result = createFileData(lines, hash, size, lastModified)
expect(result.lines).toEqual(lines)
expect(result.hash).toBe(hash)
expect(result.size).toBe(size)
expect(result.lastModified).toBe(lastModified)
})
})
describe("isFileDataEqual", () => {
it("should return true for equal hashes", () => {
const a = createFileData(["a"], "hash1", 1, 1)
const b = createFileData(["b"], "hash1", 2, 2)
expect(isFileDataEqual(a, b)).toBe(true)
})
it("should return false for different hashes", () => {
const a = createFileData(["a"], "hash1", 1, 1)
const b = createFileData(["a"], "hash2", 1, 1)
expect(isFileDataEqual(a, b)).toBe(false)
})
})
})