Skip to content

Commit b6ddf4f

Browse files
feat: parser unit tests
1 parent 4b6d636 commit b6ddf4f

File tree

3 files changed

+8
-54
lines changed

3 files changed

+8
-54
lines changed

src/utils/apex/parser/apexparser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ParseTreeWalker } from 'antlr4ts/tree/ParseTreeWalker';
1919

2020
export class ApexASTParser {
2121
private apexFilePath: string;
22-
private implementsInterface: Map<string, Token>;
22+
private implementsInterface: Map<string, Token> = new Map();
2323
// private callsMethods: Map<string, Token[]>;
2424
private interfaceName: string;
2525
private methodName: string;
@@ -50,7 +50,7 @@ export class ApexASTParser {
5050

5151
private createASTListener(): ApexParserListener {
5252
class ApexMigrationListener implements ApexParserListener {
53-
public constructor(private parser: ApexASTParser) {}
53+
public constructor(private parser: ApexASTParser) { }
5454
public enterClassDeclaration(ctx: ClassDeclarationContext): void {
5555
const interfaceToBeSearched = this.parser.interfaceName;
5656
if (!interfaceToBeSearched) return;

test/FormulaParserService.cls

Lines changed: 0 additions & 49 deletions
This file was deleted.

test/utils/apex/parser/apexparser.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ import { ApexASTParser } from '../../../../src/utils/apex/parser/apexparser';
33

44
describe('ApexASTParser', () => {
55
it('should parse the Apex file and collect interface implementations, method calls, and class names', () => {
6-
const apexFilePath = '../../../FormulaParserService.cls';
7-
const interfaceName = 'YourInterface';
6+
const apexFilePath = 'test/utils/apex/parser/resource/FormulaParserService.cls';
7+
const interfaceName = 'Callable';
88
const methodName = 'yourMethod';
99

1010
const apexParser = new ApexASTParser(apexFilePath, interfaceName, methodName);
11+
apexParser.parse();
1112
const implementsInterface = apexParser.implemementsInterface;
1213
// const callsMethods = apexParser.getCallsMethods();
1314
// const className = apexParser.getClassName();
1415

1516
// Add your assertions here based on the expected results
16-
expect(implementsInterface).to.not.be.empty;
17+
// implementsInterface.get(interfaceName);
18+
expect(implementsInterface.get(interfaceName).charPositionInLine).to.be.equal(58);
19+
expect(implementsInterface.get(interfaceName).line).to.be.equal(6);
1720
// expect(callsMethods).to.not.be.empty;
1821
// expect(className).to.equal('YourClass');
1922
});

0 commit comments

Comments
 (0)