Spaces:
Paused
Paused
Download packages/graph/src/queries/builder.test.ts from ccheney/engram-benchmark: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/ccheney/engram-benchmark/resolve/main/packages/graph/src/queries/builder.test.ts
- Command line
-
hf download hf://spaces/ccheney/engram-benchmark/packages/graph/src/queries/builder.test.ts
-
curl -L -o builder.test.ts https://huggingface.co/spaces/ccheney/engram-benchmark/resolve/main/packages/graph/src/queries/builder.test.ts
1.33 kB
| import { describe, expect, it } from "vitest"; | |
| import { MAX_DATE } from "../utils/time"; | |
| import { QueryBuilder } from "./builder"; | |
| describe("QueryBuilder", () => { | |
| it("should build simple match query", () => { | |
| const qb = new QueryBuilder(); | |
| const { cypher, params } = qb.match("(n)").return("n").build(); | |
| expect(cypher).toBe("MATCH (n) RETURN n"); | |
| expect(params).toEqual({}); | |
| }); | |
| it("should build query with where clause", () => { | |
| const qb = new QueryBuilder(); | |
| const { cypher } = qb.match("(n)").where("n.id = 1").return("n").build(); | |
| expect(cypher).toBe("MATCH (n) WHERE n.id = 1 RETURN n"); | |
| }); | |
| it("should add bitemporal constraints (current)", () => { | |
| const qb = new QueryBuilder(); | |
| const { cypher, params } = qb.match("(n)").at(["n"], { tt: "current" }).return("n").build(); | |
| expect(cypher).toContain(`MATCH (n) WHERE n.tt_end = ${MAX_DATE} RETURN n`); | |
| }); | |
| it("should add bitemporal constraints (valid time and transaction time)", () => { | |
| const qb = new QueryBuilder(); | |
| const { cypher, params } = qb | |
| .match("(n)") | |
| .at(["n"], { vt: 1000, tt: 2000 }) | |
| .return("n") | |
| .build(); | |
| expect(cypher).toContain("(n.vt_start <= $vt AND n.vt_end > $vt)"); | |
| expect(cypher).toContain("(n.tt_start <= $tt AND n.tt_end > $tt)"); | |
| expect(params).toEqual({ vt: 1000, tt: 2000 }); | |
| }); | |
| }); | |