Skip to content

Instantly share code, notes, and snippets.

@caponetto
Created August 2, 2022 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caponetto/a1dc3abe3c674f7afd92254ccb26a487 to your computer and use it in GitHub Desktop.
Save caponetto/a1dc3abe3c674f7afd92254ccb26a487 to your computer and use it in GitHub Desktop.
diff --git a/packages/serverless-workflow-language-service/tests/SwfJsonLanguageService.test.ts b/packages/serverless-workflow-language-service/tests/SwfJsonLanguageService.test.ts
index 6e22af7910..bf521f9caa 100644
--- a/packages/serverless-workflow-language-service/tests/SwfJsonLanguageService.test.ts
+++ b/packages/serverless-workflow-language-service/tests/SwfJsonLanguageService.test.ts
@@ -21,6 +21,7 @@ import {
} from "@kie-tools/serverless-workflow-language-service/dist/channel";
import {
SwfServiceCatalogFunction,
+ SwfServiceCatalogFunctionArgumentType,
SwfServiceCatalogFunctionSourceType,
SwfServiceCatalogFunctionType,
SwfServiceCatalogService,
@@ -38,7 +39,11 @@ const testRelativeFunction1: SwfServiceCatalogFunction = {
type: SwfServiceCatalogFunctionSourceType.LOCAL_FS,
serviceFileAbsolutePath: "/Users/tiago/Desktop/testRelativeService1.yml",
},
- arguments: {},
+ arguments: {
+ argString: SwfServiceCatalogFunctionArgumentType.string,
+ argNumber: SwfServiceCatalogFunctionArgumentType.number,
+ argBoolean: SwfServiceCatalogFunctionArgumentType.boolean,
+ },
};
const testRelativeService1: SwfServiceCatalogService = {
@@ -516,4 +521,62 @@ describe("SWF LS JSON", () => {
insertTextFormat: InsertTextFormat.Snippet,
} as CompletionItem);
});
+
+ test("functionRef arguments completion", async () => {
+ const ls = new SwfJsonLanguageService({
+ fs: {},
+ serviceCatalog: {
+ ...defaultServiceCatalogConfig,
+ relative: { getServices: async () => [testRelativeService1] },
+ },
+ config: defaultConfig,
+ });
+
+ const { content, cursorPosition } = treat(`
+{
+ "functions": [
+ {
+ "name": "testRelativeFunction1",
+ "operation": "specs/testRelativeService1.yml#testRelativeFunction1",
+ "type": "rest"
+ }
+ ],
+ "states": [
+ {
+ "name": "testState",
+ "type": "operation",
+ "transition": "end",
+ "actions": [
+ {
+ "name": "testStateAction",
+ "functionRef": {
+ "refName":"testRelativeFunction1",
+ "arguments":🎯
+ }
+ }
+ ]
+ },
+ ]
+}`);
+
+ const completionItems = await ls.getCompletionItems({
+ uri: "test.sw.json",
+ content,
+ cursorPosition,
+ cursorWordRange: { start: cursorPosition, end: cursorPosition },
+ });
+
+ expect(completionItems).toHaveLength(1);
+ expect(completionItems[0]).toStrictEqual({
+ kind: CompletionItemKind.Module,
+ label: `'testRelativeFunction1' arguments`,
+ detail: "specs/testRelativeService1.yml#testRelativeFunction1",
+ sortText: "testRelativeFunction1 arguments",
+ textEdit: {
+ newText: `{\n "argString": "\${1:}",\n "argNumber": "\${2:}",\n "argBoolean": "\${3:}"\n}`,
+ range: { start: cursorPosition, end: cursorPosition },
+ },
+ insertTextFormat: InsertTextFormat.Snippet,
+ } as CompletionItem);
+ });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment