diff --git a/tests/query-parser/common.test.js b/tests/query-parser/common.test.js index 9abcf21..fdc14d7 100644 --- a/tests/query-parser/common.test.js +++ b/tests/query-parser/common.test.js @@ -1,6 +1,6 @@ import { describe, it } from 'node:test' import assert from '../assert.js' -import { Alias, Identifier, Literal, ObjectPath } from '../../src/query-parser/types.js' +import { Alias, Identifier, Literal, ObjectPath, Property } from '../../src/query-parser/types.js' import { baseValue, literal, value } from '../../src/query-parser/common.js' describe('common parser library', () => { @@ -38,7 +38,7 @@ describe('common parser library', () => { }) assert.parseOk(baseValue, 'ginger.snaps', ([actual]) => { - assert.deepEqual(actual, new ObjectPath(new Identifier('ginger'), new Identifier('snaps'))) + assert.deepEqual(actual, new ObjectPath(new Identifier('ginger'), new Property(new Identifier('snaps')))) }) }) @@ -56,7 +56,7 @@ describe('common parser library', () => { }) assert.parseOk(baseValue, 'monster.girl', ([actual]) => { - assert.deepEqual(actual, new ObjectPath(new Identifier('monster'), new Identifier('girl'))) + assert.deepEqual(actual, new ObjectPath(new Identifier('monster'), new Property(new Identifier('girl')))) }) }) @@ -74,7 +74,7 @@ describe('common parser library', () => { }) assert.parseOk(value, 'rowan.containment.isBreached AS rawrnEscaped', ([actual]) => { - const obj = new ObjectPath(new Identifier('rowan'), new Identifier('containment'), new Identifier('isBreached')) + const obj = new ObjectPath(new Identifier('rowan'), new Property(new Identifier('containment')), new Property(new Identifier('isBreached'))) const alias = new Alias(obj, new Identifier('rawrnEscaped')) assert.deepEqual(actual, alias) }) diff --git a/tests/query-parser/query.test.js b/tests/query-parser/query.test.js index 3a583d2..453faf3 100644 --- a/tests/query-parser/query.test.js +++ b/tests/query-parser/query.test.js @@ -1,11 +1,13 @@ +import util from 'node:util' import { describe, it } from 'node:test' import assert from '../assert.js' import { query } from '../../src/query-parser/index.js' -import { Alias, Identifier, Match, ObjectPath, Query, ReturnValues, SelectedGraph } from '../../src/query-parser/types.js' +import { Alias, Identifier, Match, ObjectPath, Property, Query, ReturnValues, SelectedGraph } from '../../src/query-parser/types.js' import { makeNode, makeRelationship, makeRightEdge } from '../utils.js' import { map } from '../../src/fn.js' -const path = (...x) => new ObjectPath(...x) +const path = (...args) => new ObjectPath(identifier(args[0]), ...args.slice(1).map(prop)) +const prop = x => new Property(identifier(x)) const alias = (...x) => new Alias(...x) const identifier = n => new Identifier(n) const graph = n => new SelectedGraph(identifier(n)) @@ -68,11 +70,13 @@ describe('query', () => { )), [], returnVals( - alias(path(identifier('kbity'), identifier('name')), identifier('name')), + alias(path('kbity', 'name'), identifier('name')), alias(identifier('snacc'), identifier('food')) ) ) + console.log(util.inspect(actual, { depth: null })) + console.log(util.inspect(expected, { depth: null })) assert.deepEqual(actual, expected) }) }) diff --git a/tests/query-parser/where.test.js b/tests/query-parser/where.test.js index d1b2b25..6b86f65 100644 --- a/tests/query-parser/where.test.js +++ b/tests/query-parser/where.test.js @@ -83,24 +83,23 @@ describe('where operators', () => { describe('WHERE keyword', () => { it('handles complex filters', () => { - parse(whereClause, 'WHERE h.max > 500 AND (h.current < 250 OR a.value = 10) OR a.value <= 2') assert.parseOk(whereClause, 'WHERE h.max > 500 AND (h.current < 250 OR a.value = 10) OR a.value <= 2', ([actual]) => { const expected = [ - new ObjectPath(new Identifier('h'), new Property('max')), + new ObjectPath(new Identifier('h'), new Property(new Identifier('max'))), new Literal(500), GreaterThan, - new ObjectPath(new Identifier('h'), new Property('current')), + new ObjectPath(new Identifier('h'), new Property(new Identifier('current'))), new Literal(250), LesserThan, - new ObjectPath(new Identifier('a'), new Property('value')), - Or, + new ObjectPath(new Identifier('a'), new Property(new Identifier('value'))), new Literal(10), Equal, - And, - new ObjectPath(new Identifier('a'), new Property('value')), Or, + And, + new ObjectPath(new Identifier('a'), new Property(new Identifier('value'))), new Literal(2), - LesserThanEqual + LesserThanEqual, + Or, ] assert.deepEqual(actual.values, expected) })