forked from florajs/sql-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect.js
More file actions
32 lines (26 loc) · 1.01 KB
/
select.js
File metadata and controls
32 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const { expect } = require('chai');
const { Parser } = require('../../index');
describe('select', () => {
const parser = new Parser();
it('should be null if empty', () => {
const ast = parser.parse('SELECT a');
expect(ast.options).to.be.null;
expect(ast.distinct).to.be.null;
expect(ast.from).to.be.null;
expect(ast.where).to.be.null;
expect(ast.groupby).to.be.null;
expect(ast.orderby).to.be.null;
expect(ast.limit).to.be.null;
});
it('should have appropriate types', () => {
const ast = parser.parse('SELECT SQL_NO_CACHE DISTINCT a FROM b WHERE c = 0 GROUP BY d ORDER BY e limit 3');
expect(ast.options).to.be.an('array');
expect(ast.distinct).to.equal('DISTINCT');
expect(ast.from).to.be.an('array');
expect(ast.where).to.be.an('object');
expect(ast.groupby).to.be.an('array');
expect(ast.orderby).to.be.an('array');
expect(ast.limit).to.be.an('array');
});
});