Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions __tests__/editor/messageHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,18 @@ describe("handleEditorMessage", () => {
});

describe("progress", () => {
it("clears busy indicators and skips reportProgress when progress is empty", () => {
it("clears busy indicators and reports 'File verified' when progress is empty", () => {
const editor = createEditorMock();
const numberOfLines = 12;
const msg: Message = {
type: MessageType.progress,
body: { numberOfLines: 12, progress: [] },
body: { numberOfLines, progress: [] },
};

handleEditorMessage(editor, msg);

expect(editor.removeBusyIndicators).toHaveBeenCalledTimes(1);
expect(editor.reportProgress).not.toHaveBeenCalled();
});

it("reports 'File verified' when progress has reached the last line", () => {
const editor = createEditorMock();
const numberOfLines = 50;
const msg: Message = {
type: MessageType.progress,
body: {
numberOfLines,
progress: [{ range: { start: { line: numberOfLines - 1, character: 0 }, end: { line: numberOfLines - 1, character: 0 } } }],
},
};

handleEditorMessage(editor, msg);

expect(editor.reportProgress).toHaveBeenCalledWith(numberOfLines, numberOfLines, "File verified");
expect(editor.removeBusyIndicators).not.toHaveBeenCalled();
});

it("reports partial progress message when not yet on the last line", () => {
Expand Down
8 changes: 2 additions & 6 deletions editor/src/messageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,9 @@ export function handleEditorMessage(editor: MessageHandlerEditor, msg: Message):
const { numberOfLines, progress } = msg.body;
if (progress.length === 0) {
editor.removeBusyIndicators();
break;
}

const at = progress[0].range.start.line + 1;
if (at === numberOfLines) {
editor.reportProgress(at, numberOfLines, "File verified");
editor.reportProgress(numberOfLines, numberOfLines, "File verified");
} else {
const at = progress[0].range.start.line + 1;
editor.reportProgress(at, numberOfLines, `Verified file up to line: ${at}`);
}
break;
Expand Down