2024-11-10 10:15:43 +01:00
|
|
|
import { describe, it } from 'node:test'
|
|
|
|
import assert from 'node:assert'
|
|
|
|
import { parse } from '../../src/parser.js'
|
|
|
|
import { statement } from '../../src/query/return.js'
|
2024-11-10 22:25:26 +01:00
|
|
|
import { Alias } from '../../src/query/types.js'
|
2024-11-10 10:15:43 +01:00
|
|
|
|
|
|
|
describe('return parser', () => {
|
|
|
|
it('should collect a single value for a query to return', () => {
|
|
|
|
const result = parse(statement, 'RETURN folklore AS f')
|
|
|
|
assert(result.isOk())
|
|
|
|
const [[selected]] = result.value
|
2024-11-10 22:25:26 +01:00
|
|
|
assert.deepStrictEqual(selected, new Alias('folklore', 'f'))
|
2024-11-10 10:15:43 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
//it('should collect multiple values for a query to return', () => {
|
|
|
|
// const result = parse(statement, 'RETURN sybil, mercury, rowan')
|
|
|
|
// console.log(result.error.state[0])
|
|
|
|
// assert(result.isOk())
|
|
|
|
// const [[selected]] = result.value
|
|
|
|
// assert.deepStrictEqual(selected, ['sybil', 'mercury', 'rowan'])
|
|
|
|
//})
|
|
|
|
})
|
|
|
|
|