Include : and new lines where appropriate when auto-completing

This commit is contained in:
Christopher Schleiden
2023-01-05 17:26:08 -08:00
parent a2ee3041df
commit d16aa652f9
5 changed files with 371 additions and 12 deletions
@@ -373,4 +373,51 @@ jobs:
end: {line: 6, character: 17}
});
});
describe("completes with indentation", () => {
it("default indentation", async () => {
const input = `on: push
jobs:
build:
step|`;
const result = await complete(...getPositionFromCursor(input));
// Sequence
expect(result.filter(x => x.label === "steps").map(x => x.textEdit?.newText)).toEqual(["steps:\n - "]);
// Mapping
expect(result.filter(x => x.label === "env").map(x => x.textEdit?.newText)).toEqual(["env:\n "]);
// Value
expect(result.filter(x => x.label === "timeout-minutes").map(x => x.textEdit?.newText)).toEqual([
"timeout-minutes: "
]);
// One-of
expect(result.filter(x => x.label === "concurrency").map(x => x.textEdit?.newText)).toEqual(["concurrency"]);
});
it("custom indentation", async () => {
// Use 3 spaces to indent
const input = `on: push
jobs:
build:
step|`;
const result = await complete(...getPositionFromCursor(input));
// Sequence
expect(result.filter(x => x.label === "steps").map(x => x.textEdit?.newText)).toEqual(["steps:\n - "]);
// Mapping
expect(result.filter(x => x.label === "env").map(x => x.textEdit?.newText)).toEqual(["env:\n "]);
// Value
expect(result.filter(x => x.label === "timeout-minutes").map(x => x.textEdit?.newText)).toEqual([
"timeout-minutes: "
]);
// One-of
expect(result.filter(x => x.label === "concurrency").map(x => x.textEdit?.newText)).toEqual(["concurrency"]);
});
});
});