Skip to content

Commit

Permalink
feat: Add TextEditor.getBreakpoint(line: number): Promise<Breakpoint>
Browse files Browse the repository at this point in the history
  • Loading branch information
pospisilf committed Sep 3, 2024
1 parent 977eb7a commit 96a5e07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/page-objects/src/components/editor/TextEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,21 @@ export class TextEditor extends Editor {
return new Breakpoint(breakpoints[0], lineElement);
}

/**
* Get paused breakpoint on line if available. Otherwise, return undefined.
* @param line number of the line to retrieve
* @returns promise which resolves to either Breakpoint page object or undefined
*/
async getBreakpoint(line: number): Promise<Breakpoint | undefined> {
const breakpoints = await this.getBreakpoints();
for (const breakpoint of breakpoints){
if (await breakpoint.getLineNumber() === line){
return breakpoint;
}
}
return undefined;
}

/**
* Get all breakpoints.
* @returns List of Breakpoints.
Expand Down
5 changes: 5 additions & 0 deletions tests/test-project/src/test/debug/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ describe('Debugging', function () {
)) as Breakpoint;
});

it('TextEditor: getBreakpoint works', async function () {
const breakpoint = await editor.getBreakpoint(7);
expect(breakpoint).not.undefined;
});

it('TextEditor: getBreakpoints works', async function () {
const breakpoints = editor.getBreakpoints();
expect((await breakpoints).length).equals(2);
Expand Down

0 comments on commit 96a5e07

Please sign in to comment.