lava-oushudb-dt-sql-parser/test/parser/mysql/syntax.test.ts
Hayden bb0fad1dbe
refactor: standard naming (#278)
* refactor: rename flinksql to flink

* refactor: rename pgsql to postgresql

* refactor: rename trinosql to trino

* refactor: replace all default exports with named export

* refactor: rename basicParser to basicSQL

* refactor: rename basic-parser-types to types

* refactor: replace arrow func with plain func
2024-03-27 10:33:25 +08:00

37 lines
1.0 KiB
TypeScript

import { MySQL } from 'src/parser/mysql';
describe('MySQL Syntax Tests', () => {
const mysql = new MySQL();
test('Select Statement', () => {
const sql = 'select id,name from user1;';
const result = mysql.validate(sql);
expect(result.length).toBe(0);
});
test('Select 1+1', () => {
const sql = 'SELECT 1+1;';
const result = mysql.validate(sql);
expect(result.length).toBe(0);
});
test('Test invalid Double Line Comment statement', () => {
let sql = `-test comment\n`;
let result = mysql.validate(sql);
expect(result.length).toBe(1);
});
test('Test valid Double Line Comment statement', () => {
const sql = `----test comment\n`;
const result = mysql.validate(sql);
expect(result.length).toBe(0);
});
test('Test valid Hash Sign Line Comment statement', () => {
const sql = `#test comment\n`;
const result = mysql.validate(sql);
expect(result.length).toBe(0);
});
});