|
1 | 1 | import { FunctionCategory } from '../../models';
|
| 2 | +import type { FunctionData } from '../../models'; |
2 | 3 | import type { ConnectionDictionary, ConnectionUnit } from '../../models/Connection';
|
3 | 4 | import {
|
4 | 5 | ReservedToken,
|
5 | 6 | Separators,
|
6 | 7 | addAncestorNodesToCanvas,
|
7 | 8 | addParentConnectionForRepeatingElementsNested,
|
| 9 | + getDestinationNode, |
8 | 10 | getSourceValueFromLoop,
|
9 | 11 | getTargetValueWithoutLoops,
|
10 | 12 | lexThisThing as separateIntoTokens,
|
@@ -980,6 +982,59 @@ describe('utils/DataMap', () => {
|
980 | 982 | ]);
|
981 | 983 | });
|
982 | 984 | });
|
| 985 | + |
| 986 | + describe('getDestinationNode', () => { |
| 987 | + const mockSchemaNodeExtended: SchemaNodeExtended = { |
| 988 | + key: '/root', |
| 989 | + name: 'root', |
| 990 | + qName: 'root', |
| 991 | + type: NormalizedDataType.String, |
| 992 | + properties: SchemaNodeProperty.None, |
| 993 | + nodeProperties: [SchemaNodeProperty.None], |
| 994 | + children: [ |
| 995 | + { |
| 996 | + key: '/root/Some-String-Property-With-A-Dash-And-Longer-Than-A-Guid', |
| 997 | + name: 'Some-String-Property-With-A-Dash-And-Longer-Than-A-Guid', |
| 998 | + qName: 'Some-String-Property-With-A-Dash-And-Longer-Than-A-Guid', |
| 999 | + type: NormalizedDataType.String, |
| 1000 | + properties: SchemaNodeProperty.None, |
| 1001 | + nodeProperties: [SchemaNodeProperty.None], |
| 1002 | + children: [], |
| 1003 | + pathToRoot: [], |
| 1004 | + arrayItemIndex: undefined, |
| 1005 | + parentKey: '/root', |
| 1006 | + }, |
| 1007 | + ], |
| 1008 | + pathToRoot: [], |
| 1009 | + arrayItemIndex: undefined, |
| 1010 | + parentKey: undefined, |
| 1011 | + }; |
| 1012 | + |
| 1013 | + const mockFunctionData: FunctionData = { |
| 1014 | + key: 'some-function', |
| 1015 | + functionName: 'Some', |
| 1016 | + displayName: 'Some', |
| 1017 | + category: FunctionCategory.Custom, |
| 1018 | + description: 'Some', |
| 1019 | + inputs: [], |
| 1020 | + maxNumberOfInputs: 0, |
| 1021 | + outputValueType: NormalizedDataType.String, |
| 1022 | + }; |
| 1023 | + |
| 1024 | + it('returns function data for function target key', () => { |
| 1025 | + const result = getDestinationNode('some-function-4C117648-E570-4CDA-BA8E-DAFC66ECD402', [mockFunctionData], mockSchemaNodeExtended); |
| 1026 | + expect(result).toBe(mockFunctionData); |
| 1027 | + }); |
| 1028 | + |
| 1029 | + it('returns schema node for node target key', () => { |
| 1030 | + const result = getDestinationNode( |
| 1031 | + '/root/Some-String-Property-With-A-Dash-And-Longer-Than-A-Guid', |
| 1032 | + [mockFunctionData], |
| 1033 | + mockSchemaNodeExtended |
| 1034 | + ); |
| 1035 | + expect(result).toBe(mockSchemaNodeExtended.children[0]); |
| 1036 | + }); |
| 1037 | + }); |
983 | 1038 | });
|
984 | 1039 |
|
985 | 1040 | const indexed: ConnectionDictionary = {
|
|
0 commit comments