2023-11-27 15:25:40 +08:00
|
|
|
import MySQL from '../../../src/parser/mysql';
|
2020-09-11 17:39:10 +08:00
|
|
|
|
2023-11-27 15:25:40 +08:00
|
|
|
describe('MySQL Syntax Tests', () => {
|
|
|
|
const parser = new MySQL();
|
2020-09-11 17:39:10 +08:00
|
|
|
|
|
|
|
test('Select Statement', () => {
|
|
|
|
const sql = 'select id,name from user1;';
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Select 1+1', () => {
|
|
|
|
const sql = 'SELECT 1+1;';
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
2023-01-09 11:01:10 +08:00
|
|
|
|
|
|
|
test('Test invalid Double Line Comment statement', () => {
|
|
|
|
let sql = `-test comment\n`;
|
|
|
|
let result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Test valid Double Line Comment statement', () => {
|
|
|
|
const sql = `----test comment\n`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Test valid Hash Sign Line Comment statement', () => {
|
|
|
|
const sql = `#test comment\n`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
2020-09-11 17:39:10 +08:00
|
|
|
});
|