import { describe, it } from 'node:test' import assert from '../assert.js' import { returnClause } from '../../src/query/return.js' import { Alias, Identifier, Literal, ReturnValues } from '../../src/query/types.js' describe('RETURN keyword', () => { it('should collect a single value for a query to return', () => { assert.parseOk(returnClause, 'RETURN folklore AS f', ([actual]) => { assert.deepEqual(actual, new ReturnValues(new Alias(new Identifier('folklore'), new Identifier('f')))) }) }) it('should collect multiple values for a query to return', () => { assert.parseOk(returnClause, 'RETURN sybil, mercury, rowan', ([actual]) => { assert.deepStrictEqual(actual, new ReturnValues(...['sybil', 'mercury', 'rowan'].map(x => new Identifier(x)))) }) }) it('should accept mixed values and aliases', () => { assert.parseOk(returnClause, 'RETURN 19589 AS sybil, mercury AS vex, rowan', ([actual]) => { const sybil = new Alias(new Literal(19589), new Identifier('sybil')) const mercury = new Alias(new Identifier('mercury'), new Identifier('vex')) const rowan = new Identifier('rowan') assert.deepStrictEqual(actual, new ReturnValues(...[sybil, mercury, rowan])) }) }) })