* fix: passing next edit requests will render things * chore: remove comment * feat: skip whitespace only deletions * feat: add a utility function for checking if a diff is a whitespace only deletion * feat: add test for next edit utils * feat: move filtering to NextEditProvider * fix: escape newline properly * feat: make jump decoration more visible * feat: remove redundant escapes * fix: undo the escapeSVG * fix: update tests * fix: use proper line heights * fix: place the SVG at the end of the line * fix: handle cases where the completion is a single line * feat: improve next edit UI (#7167) * fix: use proper line heights * fix: place the SVG at the end of the line * fix: handle cases where the completion is a single line * fix: allocate more memory for the GUI build step * fix: set flag as node options * fix: jump scrolls only after accepting * fix: update jump manager vitest
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { describe, expect, test, vi } from "vitest";
|
|
import { DiffLine } from "..";
|
|
import { isNextEditTest, isWhitespaceOnlyDeletion } from "./utils";
|
|
|
|
describe("isNextEditTest", () => {
|
|
test("returns true when NEXT_EDIT_TEST_ENABLED is 'true'", () => {
|
|
vi.stubEnv("NEXT_EDIT_TEST_ENABLED", "true");
|
|
expect(isNextEditTest()).toBe(true);
|
|
});
|
|
|
|
test("returns false when NEXT_EDIT_TEST_ENABLED is 'false'", () => {
|
|
vi.stubEnv("NEXT_EDIT_TEST_ENABLED", "false");
|
|
expect(isNextEditTest()).toBe(false);
|
|
});
|
|
|
|
test("returns false when NEXT_EDIT_TEST_ENABLED is undefined", () => {
|
|
vi.stubEnv("NEXT_EDIT_TEST_ENABLED", undefined);
|
|
expect(isNextEditTest()).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("isWhitespaceOnlyDeletion", () => {
|
|
test("returns true for whitespace-only deletions", () => {
|
|
const diffLines: DiffLine[] = [
|
|
{ type: "old", line: " " },
|
|
{ type: "old", line: "\t" },
|
|
];
|
|
expect(isWhitespaceOnlyDeletion(diffLines)).toBe(true);
|
|
});
|
|
|
|
test("returns false for non-whitespace deletions", () => {
|
|
const diffLines: DiffLine[] = [
|
|
{ type: "old", line: "code" },
|
|
{ type: "old", line: " " },
|
|
];
|
|
expect(isWhitespaceOnlyDeletion(diffLines)).toBe(false);
|
|
});
|
|
|
|
test("returns false for mixed content", () => {
|
|
const diffLines: DiffLine[] = [
|
|
{ type: "old", line: " " },
|
|
{ type: "old", line: "code" },
|
|
];
|
|
expect(isWhitespaceOnlyDeletion(diffLines)).toBe(false);
|
|
});
|
|
|
|
test("returns false for mixed type", () => {
|
|
const diffLines: DiffLine[] = [
|
|
{ type: "old", line: " " },
|
|
{ type: "new", line: "" },
|
|
];
|
|
expect(isWhitespaceOnlyDeletion(diffLines)).toBe(false);
|
|
});
|
|
|
|
test("returns true for empty array", () => {
|
|
const diffLines: DiffLine[] = [];
|
|
expect(isWhitespaceOnlyDeletion(diffLines)).toBe(true);
|
|
});
|
|
});
|