build: optimize cli and add eslint
This commit is contained in:
16
test/parsers/mysql/lexer.test.ts
Normal file
16
test/parsers/mysql/lexer.test.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import MySQLParser from '../../../src/core/mysql';
|
||||
|
||||
describe('MySQL Lexer tests', () => {
|
||||
const mysqlParser = new MySQLParser();
|
||||
|
||||
const sql = 'select id,name,sex from user1;';
|
||||
const tokens = mysqlParser.getAllTokens(sql);
|
||||
|
||||
test('token counts', () => {
|
||||
expect(tokens.length).toBe(12);
|
||||
});
|
||||
|
||||
test('token counts', () => {
|
||||
expect(tokens.length).toBe(12);
|
||||
});
|
||||
});
|
24
test/parsers/mysql/parser.test.ts
Normal file
24
test/parsers/mysql/parser.test.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import MySQLParser from '../../../src/core/mysql';
|
||||
|
||||
describe('MySQL Parser tests', () => {
|
||||
const mysql = new MySQLParser();
|
||||
|
||||
test('Select * FROM Statement', () => {
|
||||
const sql = 'SELECT * FROM tb;';
|
||||
const result = mysql.parserTreeToString(sql);
|
||||
expect(result).toEqual(`
|
||||
(statement (sqlStatements (
|
||||
sqlStatement (
|
||||
dmlStatement (
|
||||
selectStatement (
|
||||
querySpecification SELECT (selectElements *) (
|
||||
fromClause FROM (
|
||||
tableSources (tableSource (
|
||||
tableSourceItem (tableName (
|
||||
fullId (uid (
|
||||
simpleId TB
|
||||
)
|
||||
))))))))))) (emptyStatement ;)) <EOF>
|
||||
)`);
|
||||
});
|
||||
});
|
11
test/parsers/mysql/syntax.test.ts
Normal file
11
test/parsers/mysql/syntax.test.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import MySQLParser from '../../../src/core/mysql';
|
||||
|
||||
describe('MySQL Syntax tests', () => {
|
||||
const mysql = new MySQLParser();
|
||||
test('Select Statement', () => {
|
||||
const sql = 'select id,name from user1;';
|
||||
const result = mysql.validate(sql);
|
||||
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user