28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
import { describe, it } from 'node:test'
|
|
import assert from '../assert.js'
|
|
import { statement } from '../../src/query/return.js'
|
|
import { Alias, Identifier, Literal } from '../../src/query/types.js'
|
|
|
|
describe('return parser', () => {
|
|
it('should collect a single value for a query to return', () => {
|
|
assert.parseOk(statement, 'RETURN folklore AS f', actual => {
|
|
assert.deepEqual(actual, new Alias(new Identifier('folklore'), new Identifier('f')))
|
|
})
|
|
})
|
|
|
|
it('should collect multiple values for a query to return', () => {
|
|
assert.parseOk(statement, 'RETURN sybil, mercury, rowan', actual => {
|
|
assert.deepStrictEqual(actual, ['sybil', 'mercury', 'rowan'].map(x => new Identifier(x)))
|
|
})
|
|
})
|
|
|
|
it('should accept mixed values and aliases', () => {
|
|
assert.parseOk(statement, '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, [sybil, mercury, rowan])
|
|
})
|
|
})
|
|
})
|
|
|