diff --git a/editors/vscode/test/completion-scope.test.js b/editors/vscode/test/completion-scope.test.js index b8033608..db143c19 100644 --- a/editors/vscode/test/completion-scope.test.js +++ b/editors/vscode/test/completion-scope.test.js @@ -7,10 +7,48 @@ const Module = require("node:module"); // Mock the vscode module for unit tests const originalLoad = Module._load; Module._load = function load(request, parent, isMain) { - if (request === "vscode") return {}; + if (request === "vscode") { + return { + Position: class Position { + constructor(line, character) { + this.line = line; + this.character = character; + } + }, + Range: class Range { + constructor(start, end) { + this.start = start; + this.end = end; + } + }, + CompletionItem: class CompletionItem { + constructor(label, kind) { + this.label = label; + this.kind = kind; + } + }, + CompletionItemKind: { + Event: 23, + Property: 10, + Function: 12, + Keyword: 14, + Variable: 13, + }, + SnippetString: class SnippetString { + constructor(text) { + this.value = text; + } + }, + MarkdownString: class MarkdownString { + constructor(text) { + this.value = text; + } + }, + }; + } return originalLoad.call(this, request, parent, isMain); }; -const { isInsideViewBlock } = require("../src/completion.js"); +const { isInsideViewBlock, provideCompletionItems } = require("../src/completion.js"); Module._load = originalLoad; const PAGE = `page Home { @@ -30,3 +68,43 @@ test("a markup offset is inside a view block", () => { test("a functions-block offset is not inside a view block", () => { assert.equal(isInsideViewBlock(PAGE, PAGE.indexOf("function go")), false); }); + +test("provideCompletionItems returns empty array when inside view block", () => { + const document = { + getText() { + return PAGE; + }, + offsetAt(position) { + return PAGE.indexOf("