jomarko commented on code in PR #2684:
URL:
https://github.com/apache/incubator-kie-tools/pull/2684#discussion_r1808425331
##########
packages/feel-input-component/tests/semanticTokensProvider.test.ts:
##########
@@ -22,6 +22,10 @@ import { BuiltInTypes, DmnDefinitions, FeelVariables } from
"@kie-tools/dmn-feel
import * as Monaco from "@kie-tools-core/monaco-editor";
import { Element } from "@kie-tools/feel-input-component/dist/themes/Element";
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+//import {getMarshaller} from "@kie-tools/dmn-marshaller/d"
Review Comment:
leftover probably?
##########
packages/feel-input-component/tests/semanticTokensProvider.test.ts:
##########
@@ -286,6 +290,149 @@ ThatShouldFailWhenBreakLine`,
}
});
});
+
+ describe("variables inside Decision Tables", () => {
+ const dmnModelWithInclude =
"../tests-data/variables-inside-decision-tables/modelWithInclude.dmn";
+ const includedDmnModel =
"../tests-data/variables-inside-decision-tables/included.dmn";
+ test("should recognize local nodes", async () => {
+ const expression = "LocalInput + LocalDecision";
+ const id = "_AEC3EEB0-8436-4767-A214-20FF5E5CB7BE";
+ const modelMock = createModelMockForExpression(expression);
+
+ const localModel = getDmnModelFromFilePath(dmnModelWithInclude);
+ const includedModel = getDmnModelFromFilePath(includedDmnModel);
+
+ const feelVariables = new FeelVariables(
+ localModel.definitions,
+ new Map([[includedModel.definitions["@_namespace"] ?? "",
includedModel]])
+ );
+
+ const semanticTokensProvider = new SemanticTokensProvider(feelVariables,
id, () => {});
+
+ const semanticMonacoTokens = await
semanticTokensProvider.provideDocumentSemanticTokens(
+ modelMock as unknown as Monaco.editor.ITextModel,
+ null,
+ cancellationTokenMock
+ );
+
+ const expected = [
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: 0,
+ tokenLength: "LocalInput".length,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: "LocalInput".length + 3, //
+3 because of the " + "
+ tokenLength: "LocalDecision".length,
+ }),
+ ];
+
+ for (let i = 0; i < expected.length; i++) {
+ expect(semanticMonacoTokens?.data[i]).toEqual(expected[i]);
+ }
+ });
+
+ test("should recognize included nodes", async () => {
+ const expression = "MyIncludedModel.MyDS(LocalInput) +
MyIncludedModel.RemoteInput";
+ const id = "_206131ED-0B81-4013-980A-4BB2539A53D0";
+ const modelMock = createModelMockForExpression(expression);
+
+ const localModel = getDmnModelFromFilePath(dmnModelWithInclude);
+ const includedModel = getDmnModelFromFilePath(includedDmnModel);
+
+ const feelVariables = new FeelVariables(
+ localModel.definitions,
+ new Map([[includedModel.definitions["@_namespace"] ?? "",
includedModel]])
+ );
+
+ const semanticTokensProvider = new SemanticTokensProvider(feelVariables,
id, () => {});
+
+ const semanticMonacoTokens = await
semanticTokensProvider.provideDocumentSemanticTokens(
+ modelMock as unknown as Monaco.editor.ITextModel,
+ null,
+ cancellationTokenMock
+ );
+
+ const expected = [
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: 0,
+ tokenLength: "MyIncludedModel.MyDS".length,
+ tokenType: Element.FunctionCall,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex:
"MyIncludedModel.MyDS".length + 1, // +1 because of the "("
+ tokenLength: "LocalInput".length,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: "LocalInput".length + ") +
".length,
+ tokenLength: "MyIncludedModel.RemoteInput".length,
+ }),
+ ];
+
+ for (let i = 0; i < expected.length; i++) {
+ expect(semanticMonacoTokens?.data[i]).toEqual(expected[i]);
+ }
Review Comment:
can't we simplify?:
```
expect(semanticMonacoTokens?.data).toEqual(expected)
```
see: https://jestjs.io/docs/expect#toequalvalue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]