MCPcopy Create free account
hub / github.com/codemix/graph / setupMultiLabelGraph

Function setupMultiLabelGraph

packages/graph/src/test/queryExecution.test.ts:256–296  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

254
255// Tests for labels() function
256function setupMultiLabelGraph(): Graph<GraphSchema> {
257 const schema = {
258 vertices: {
259 User: {
260 properties: {
261 name: { type: makeType<string>("") },
262 },
263 },
264 Post: {
265 properties: {
266 title: { type: makeType<string>("") },
267 },
268 },
269 Comment: {
270 properties: {
271 text: { type: makeType<string>("") },
272 },
273 },
274 },
275 edges: {
276 wrote: {
277 properties: {},
278 },
279 },
280 } as const satisfies GraphSchema;
281
282 const graph = new Graph({ schema, storage: new InMemoryGraphStorage() });
283
284 // Add vertices with different labels
285 const alice = graph.addVertex("User", { name: "Alice" });
286 const bob = graph.addVertex("User", { name: "Bob" });
287 const post1 = graph.addVertex("Post", { title: "Hello World" });
288 const post2 = graph.addVertex("Post", { title: "Second Post" });
289 const comment1 = graph.addVertex("Comment", { text: "Nice post!" });
290
291 graph.addEdge(alice.id, "wrote", post1.id, {});
292 graph.addEdge(bob.id, "wrote", post2.id, {});
293 graph.addEdge(alice.id, "wrote", comment1.id, {});
294
295 return graph;
296}
297
298test("Query Execution End-to-End - labels() function - should return labels for a single vertex", () => {
299 const graph = setupMultiLabelGraph();

Callers 1

Calls 3

addVertexMethod · 0.95
addEdgeMethod · 0.95
makeTypeFunction · 0.70

Tested by

no test coverage detected