From 523a64869a76bf0a1294684cbd5f08bd9f89a706 Mon Sep 17 00:00:00 2001 From: kitsunecafe Date: Wed, 13 Nov 2024 19:21:51 -0600 Subject: [PATCH] add test for polycule --- tests/query/match.test.js | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/query/match.test.js b/tests/query/match.test.js index 59366fb..aad9ddf 100644 --- a/tests/query/match.test.js +++ b/tests/query/match.test.js @@ -67,12 +67,24 @@ describe('edge', () => { }) describe('MATCH keyword', () => { - it('should match nodes with a relationship to another another node', () => { + it('should match a single node with no relationships', () => { + assert.parseOk(statement, 'MATCH (:Label)', ([actual]) => { + const expected = makeNode(undefined, 'Label') + assert.deepEqual(actual, expected) + }) + assert.parseOk(statement, 'MATCH (node:Label)', ([actual]) => { const expected = makeNode('node', 'Label') assert.deepEqual(actual, expected) }) + assert.parseOk(statement, 'MATCH (node:Label { prop: true, value: "test" })', ([actual]) => { + const expected = makeNode('node', 'Label', [['prop', true], ['value', 'test']]) + assert.deepEqual(actual, expected) + }) + }) + + it('should match nodes with a relationship to another another node', () => { assert.parseOk(statement, 'MATCH (:Node)-[:Edge]->(:Node)', actual => { const expected = [ makeNode(undefined, 'Node'), @@ -102,6 +114,30 @@ describe('MATCH keyword', () => { assert.deepEqual(actual, expected) }) + + assert.parseOk(statement, 'MATCH (:Node { db: 0.7 })-[:Edge]->(:Node { db: 0.95 })', actual => { + const expected = [ + makeNode(undefined, 'Node', [['db', 0.7]]), + makeEdge(undefined, 'Edge'), + makeNode(undefined, 'Node', [['db', 0.95]]), + ] + + assert.deepEqual(actual, expected) + }) + }) + + it('should handle multiple relationships', () => { + assert.parseOk(statement, 'MATCH (player:Player)-[:Knows]->(a:NPC)-[:Knows]->(b:NPC)', actual => { + const expected = [ + makeNode('player', 'Player'), + makeEdge(undefined, 'Knows'), + makeNode('a', 'NPC'), + makeEdge(undefined, 'Knows'), + makeNode('b', 'NPC'), + ] + + assert.deepEqual(actual, expected) + }) }) })