lava-oushudb-dt-sql-parser/test/parser/plsql/visitor.test.ts
Hayden 7de192d486
chroe: devops (#180)
* ci: add dependencies about lint tool

* ci: replace eslint with prettier

* ci: add husky, cz and commitlint

* style: lint fix via prettier

* ci: add prettier and check-types to github workflow

'
2023-10-13 11:16:36 +08:00

28 lines
949 B
TypeScript

import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { PlSqlParserVisitor } from '../../../src/lib/plsql/PlSqlParserVisitor';
import PLSQL from '../../../src/parser/plsql';
describe('PLSQL Visitor Tests', () => {
const expectTableName = 'user1';
const sql = `select id,name,sex from ${expectTableName};`;
const parser = new PLSQL();
const parserTree = parser.parse(sql);
test('Visitor visitTable_ref_list', () => {
let result = '';
class MyVisitor extends AbstractParseTreeVisitor<any> implements PlSqlParserVisitor<any> {
protected defaultResult() {
return result;
}
visitTable_ref_list = (ctx): void => {
result = ctx.text.toLowerCase();
};
}
const visitor: any = new MyVisitor();
visitor.visit(parserTree);
expect(result).toBe(expectTableName);
});
});