@wix/motion-edm-autogen-transformations-core 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/__tests__/corvid-entity.spec.js +68 -0
- package/dist/cjs/__tests__/corvid-entity.spec.js.map +1 -0
- package/dist/cjs/__tests__/getArgumentCardinality.spec.js +58 -0
- package/dist/cjs/__tests__/getArgumentCardinality.spec.js.map +1 -0
- package/dist/cjs/__tests__/helpers.spec.js +90 -0
- package/dist/cjs/__tests__/helpers.spec.js.map +1 -0
- package/dist/cjs/__tests__/reduceTransformation.spec.js +478 -0
- package/dist/cjs/__tests__/reduceTransformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/custom-functions.spec.js +111 -0
- package/dist/cjs/__tests__/transformations/custom-functions.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/create-transformation.spec.js +47 -0
- package/dist/cjs/__tests__/transformations/preset/create-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/delete-transformation.spec.js +75 -0
- package/dist/cjs/__tests__/transformations/preset/delete-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/get-transformation.spec.js +46 -0
- package/dist/cjs/__tests__/transformations/preset/get-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/list-transformation.spec.js +28 -0
- package/dist/cjs/__tests__/transformations/preset/list-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/query-transformation.spec.js +66 -0
- package/dist/cjs/__tests__/transformations/preset/query-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/update-transformation.spec.js +90 -0
- package/dist/cjs/__tests__/transformations/preset/update-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/validations/validateRequestTransformation.spec.js +291 -0
- package/dist/cjs/__tests__/validations/validateRequestTransformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/validations/validateResponseTransformation.spec.js +370 -0
- package/dist/cjs/__tests__/validations/validateResponseTransformation.spec.js.map +1 -0
- package/dist/cjs/index.js +102 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/corvid-entity/index.js +32 -0
- package/dist/cjs/lib/corvid-entity/index.js.map +1 -0
- package/dist/cjs/lib/getArgumentCardinality.js +34 -0
- package/dist/cjs/lib/getArgumentCardinality.js.map +1 -0
- package/dist/cjs/lib/helpers.js +111 -0
- package/dist/cjs/lib/helpers.js.map +1 -0
- package/dist/cjs/lib/transformations/common.js +24 -0
- package/dist/cjs/lib/transformations/common.js.map +1 -0
- package/dist/cjs/lib/transformations/constants.js +23 -0
- package/dist/cjs/lib/transformations/constants.js.map +1 -0
- package/dist/cjs/lib/transformations/custom-functions.js +46 -0
- package/dist/cjs/lib/transformations/custom-functions.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/create.js +17 -0
- package/dist/cjs/lib/transformations/preset/create.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/delete.js +42 -0
- package/dist/cjs/lib/transformations/preset/delete.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/get.js +17 -0
- package/dist/cjs/lib/transformations/preset/get.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/list.js +13 -0
- package/dist/cjs/lib/transformations/preset/list.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/query.js +40 -0
- package/dist/cjs/lib/transformations/preset/query.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/update.js +37 -0
- package/dist/cjs/lib/transformations/preset/update.js.map +1 -0
- package/dist/cjs/lib/transformations/reduceTransformation.js +180 -0
- package/dist/cjs/lib/transformations/reduceTransformation.js.map +1 -0
- package/dist/cjs/lib/transformations/validations/common.js +50 -0
- package/dist/cjs/lib/transformations/validations/common.js.map +1 -0
- package/dist/cjs/lib/transformations/validations/validateRequestTransformation.js +118 -0
- package/dist/cjs/lib/transformations/validations/validateRequestTransformation.js.map +1 -0
- package/dist/cjs/lib/transformations/validations/validateResponseTransformation.js +161 -0
- package/dist/cjs/lib/transformations/validations/validateResponseTransformation.js.map +1 -0
- package/dist/esm/__tests__/corvid-entity.spec.js +58 -0
- package/dist/esm/__tests__/corvid-entity.spec.js.map +1 -0
- package/dist/esm/__tests__/getArgumentCardinality.spec.js +42 -0
- package/dist/esm/__tests__/getArgumentCardinality.spec.js.map +1 -0
- package/dist/esm/__tests__/helpers.spec.js +61 -0
- package/dist/esm/__tests__/helpers.spec.js.map +1 -0
- package/dist/esm/__tests__/reduceTransformation.spec.js +416 -0
- package/dist/esm/__tests__/reduceTransformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/custom-functions.spec.js +87 -0
- package/dist/esm/__tests__/transformations/custom-functions.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/create-transformation.spec.js +40 -0
- package/dist/esm/__tests__/transformations/preset/create-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/delete-transformation.spec.js +65 -0
- package/dist/esm/__tests__/transformations/preset/delete-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/get-transformation.spec.js +39 -0
- package/dist/esm/__tests__/transformations/preset/get-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/list-transformation.spec.js +22 -0
- package/dist/esm/__tests__/transformations/preset/list-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/query-transformation.spec.js +57 -0
- package/dist/esm/__tests__/transformations/preset/query-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/update-transformation.spec.js +85 -0
- package/dist/esm/__tests__/transformations/preset/update-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/validations/validateRequestTransformation.spec.js +200 -0
- package/dist/esm/__tests__/validations/validateRequestTransformation.spec.js.map +1 -0
- package/dist/esm/__tests__/validations/validateResponseTransformation.spec.js +246 -0
- package/dist/esm/__tests__/validations/validateResponseTransformation.spec.js.map +1 -0
- package/dist/esm/index.js +47 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/corvid-entity/index.js +17 -0
- package/dist/esm/lib/corvid-entity/index.js.map +1 -0
- package/dist/esm/lib/getArgumentCardinality.js +30 -0
- package/dist/esm/lib/getArgumentCardinality.js.map +1 -0
- package/dist/esm/lib/helpers.js +56 -0
- package/dist/esm/lib/helpers.js.map +1 -0
- package/dist/esm/lib/transformations/common.js +17 -0
- package/dist/esm/lib/transformations/common.js.map +1 -0
- package/dist/esm/lib/transformations/constants.js +18 -0
- package/dist/esm/lib/transformations/constants.js.map +1 -0
- package/dist/esm/lib/transformations/custom-functions.js +34 -0
- package/dist/esm/lib/transformations/custom-functions.js.map +1 -0
- package/dist/esm/lib/transformations/preset/create.js +8 -0
- package/dist/esm/lib/transformations/preset/create.js.map +1 -0
- package/dist/esm/lib/transformations/preset/delete.js +25 -0
- package/dist/esm/lib/transformations/preset/delete.js.map +1 -0
- package/dist/esm/lib/transformations/preset/get.js +8 -0
- package/dist/esm/lib/transformations/preset/get.js.map +1 -0
- package/dist/esm/lib/transformations/preset/list.js +6 -0
- package/dist/esm/lib/transformations/preset/list.js.map +1 -0
- package/dist/esm/lib/transformations/preset/query.js +28 -0
- package/dist/esm/lib/transformations/preset/query.js.map +1 -0
- package/dist/esm/lib/transformations/preset/update.js +18 -0
- package/dist/esm/lib/transformations/preset/update.js.map +1 -0
- package/dist/esm/lib/transformations/reduceTransformation.js +122 -0
- package/dist/esm/lib/transformations/reduceTransformation.js.map +1 -0
- package/dist/esm/lib/transformations/validations/common.js +35 -0
- package/dist/esm/lib/transformations/validations/common.js.map +1 -0
- package/dist/esm/lib/transformations/validations/validateRequestTransformation.js +107 -0
- package/dist/esm/lib/transformations/validations/validateRequestTransformation.js.map +1 -0
- package/dist/esm/lib/transformations/validations/validateResponseTransformation.js +142 -0
- package/dist/esm/lib/transformations/validations/validateResponseTransformation.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/__tests__/corvid-entity.spec.d.ts +2 -0
- package/dist/types/__tests__/corvid-entity.spec.d.ts.map +1 -0
- package/dist/types/__tests__/getArgumentCardinality.spec.d.ts +2 -0
- package/dist/types/__tests__/getArgumentCardinality.spec.d.ts.map +1 -0
- package/dist/types/__tests__/helpers.spec.d.ts +2 -0
- package/dist/types/__tests__/helpers.spec.d.ts.map +1 -0
- package/dist/types/__tests__/reduceTransformation.spec.d.ts +2 -0
- package/dist/types/__tests__/reduceTransformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/custom-functions.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/custom-functions.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/create-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/create-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/delete-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/delete-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/get-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/get-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/list-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/list-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/query-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/query-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/update-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/update-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/validations/validateRequestTransformation.spec.d.ts +2 -0
- package/dist/types/__tests__/validations/validateRequestTransformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/validations/validateResponseTransformation.spec.d.ts +2 -0
- package/dist/types/__tests__/validations/validateResponseTransformation.spec.d.ts.map +1 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/corvid-entity/index.d.ts +13 -0
- package/dist/types/lib/corvid-entity/index.d.ts.map +1 -0
- package/dist/types/lib/getArgumentCardinality.d.ts +3 -0
- package/dist/types/lib/getArgumentCardinality.d.ts.map +1 -0
- package/dist/types/lib/helpers.d.ts +28 -0
- package/dist/types/lib/helpers.d.ts.map +1 -0
- package/dist/types/lib/transformations/common.d.ts +15 -0
- package/dist/types/lib/transformations/common.d.ts.map +1 -0
- package/dist/types/lib/transformations/constants.d.ts +18 -0
- package/dist/types/lib/transformations/constants.d.ts.map +1 -0
- package/dist/types/lib/transformations/custom-functions.d.ts +13 -0
- package/dist/types/lib/transformations/custom-functions.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/create.d.ts +6 -0
- package/dist/types/lib/transformations/preset/create.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/delete.d.ts +7 -0
- package/dist/types/lib/transformations/preset/delete.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/get.d.ts +6 -0
- package/dist/types/lib/transformations/preset/get.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/list.d.ts +4 -0
- package/dist/types/lib/transformations/preset/list.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/query.d.ts +20 -0
- package/dist/types/lib/transformations/preset/query.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/update.d.ts +8 -0
- package/dist/types/lib/transformations/preset/update.d.ts.map +1 -0
- package/dist/types/lib/transformations/reduceTransformation.d.ts +6 -0
- package/dist/types/lib/transformations/reduceTransformation.d.ts.map +1 -0
- package/dist/types/lib/transformations/validations/common.d.ts +13 -0
- package/dist/types/lib/transformations/validations/common.d.ts.map +1 -0
- package/dist/types/lib/transformations/validations/validateRequestTransformation.d.ts +6 -0
- package/dist/types/lib/transformations/validations/validateRequestTransformation.d.ts.map +1 -0
- package/dist/types/lib/transformations/validations/validateResponseTransformation.d.ts +6 -0
- package/dist/types/lib/transformations/validations/validateResponseTransformation.d.ts.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
|
|
4
|
+
|
|
5
|
+
var _lodash = require("lodash");
|
|
6
|
+
|
|
7
|
+
var _reduceTransformation = require("../lib/transformations/reduceTransformation");
|
|
8
|
+
|
|
9
|
+
describe('reduceTransformation', () => {
|
|
10
|
+
describe('simple transformations', () => {
|
|
11
|
+
const visitorCallbackResult = (0, _motionRuntimeTestContext.aString)();
|
|
12
|
+
test('traverses a simple transformation', () => {
|
|
13
|
+
const visitorCallback = jest.fn().mockReturnValueOnce(visitorCallbackResult);
|
|
14
|
+
const transformation = '$.a.b.c';
|
|
15
|
+
const result = (0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
16
|
+
visitors: {
|
|
17
|
+
TopLevelSimpleTransformationExpression: visitorCallback
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
21
|
+
expect(visitorCallback).toHaveBeenCalledWith('$.a.b.c');
|
|
22
|
+
expect(result).toStrictEqual(visitorCallbackResult);
|
|
23
|
+
});
|
|
24
|
+
describe('custom-functions', () => {
|
|
25
|
+
test('traverses a valid custom-function expression', () => {
|
|
26
|
+
const visitorCallback = jest.fn().mockReturnValueOnce(visitorCallbackResult);
|
|
27
|
+
const transformation = '#someCustomFunction($.a.b.c,someOtherArg)';
|
|
28
|
+
const result = (0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
29
|
+
visitors: {
|
|
30
|
+
TopLevelCustomFunctionExpression: visitorCallback
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
34
|
+
expect(visitorCallback).toHaveBeenCalledWith('someCustomFunction', ['$.a.b.c', 'someOtherArg'], transformation);
|
|
35
|
+
expect(result).toStrictEqual(visitorCallbackResult);
|
|
36
|
+
});
|
|
37
|
+
test('does not fail for invalid custom-function expression', () => {
|
|
38
|
+
const visitorCallback = jest.fn().mockReturnValueOnce(visitorCallbackResult);
|
|
39
|
+
const transformationWithInvalidCustomFunctionExpression = '#($.a.b.c)';
|
|
40
|
+
const result = (0, _reduceTransformation.reduceTransformation)(transformationWithInvalidCustomFunctionExpression, {
|
|
41
|
+
visitors: {
|
|
42
|
+
TopLevelCustomFunctionExpression: visitorCallback
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
46
|
+
expect(visitorCallback).toHaveBeenCalledWith(null, null, transformationWithInvalidCustomFunctionExpression);
|
|
47
|
+
expect(result).toStrictEqual(visitorCallbackResult);
|
|
48
|
+
});
|
|
49
|
+
}); // TODO: replace with returning the invalid value, for constant-transformation
|
|
50
|
+
|
|
51
|
+
test('invokes the TopLevelUnsupportedTransformationExpression otherwise', () => {
|
|
52
|
+
const visitorCallback = jest.fn().mockReturnValueOnce(visitorCallbackResult);
|
|
53
|
+
const transformation = (0, _motionRuntimeTestContext.aString)();
|
|
54
|
+
const result = (0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
55
|
+
visitors: {
|
|
56
|
+
TopLevelUnsupportedTransformationExpression: visitorCallback
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
60
|
+
expect(visitorCallback).toHaveBeenCalledWith(transformation);
|
|
61
|
+
expect(result).toStrictEqual(visitorCallbackResult);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
describe('complex transformation', () => {
|
|
65
|
+
const accumulator = (0, _motionRuntimeTestContext.anObject)();
|
|
66
|
+
test('traverses all string nodes that are transformation expressions', () => {
|
|
67
|
+
const visitorCallback = jest.fn();
|
|
68
|
+
const transformation = {
|
|
69
|
+
a: {
|
|
70
|
+
b: {
|
|
71
|
+
c: '$[0].ddd.eee.ffff'
|
|
72
|
+
},
|
|
73
|
+
d: 2,
|
|
74
|
+
e: ['$.ggg', 3, 4, 5]
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
78
|
+
accumulator,
|
|
79
|
+
visitors: {
|
|
80
|
+
NestedSimpleTransformationExpression: visitorCallback
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
expect(visitorCallback).toHaveBeenCalledTimes(2);
|
|
84
|
+
expect(visitorCallback).toHaveBeenCalledWith(accumulator, 'a.b.c', '$[0].ddd.eee.ffff');
|
|
85
|
+
expect(visitorCallback).toHaveBeenCalledWith(accumulator, 'a.e[0]', '$.ggg');
|
|
86
|
+
});
|
|
87
|
+
describe('spread operator', () => {
|
|
88
|
+
const _times = (0, _lodash.times)(2, () => jest.fn()),
|
|
89
|
+
topLevelSpreadOperatorCallback = _times[0],
|
|
90
|
+
nestedSpreadOperatorCallback = _times[1];
|
|
91
|
+
|
|
92
|
+
const argumentExpression = '$[1].d.e.f';
|
|
93
|
+
const sibling = (0, _motionRuntimeTestContext.anObject)();
|
|
94
|
+
const siblingKeys = Object.keys(sibling);
|
|
95
|
+
const path = `${siblingKeys[0]}.b.c`;
|
|
96
|
+
beforeEach(() => {
|
|
97
|
+
[topLevelSpreadOperatorCallback, nestedSpreadOperatorCallback].forEach(mock => mock.mockClear());
|
|
98
|
+
});
|
|
99
|
+
test('invokes the spread operator visitor prior to its children', () => {
|
|
100
|
+
const nestedOmitCallback = jest.fn();
|
|
101
|
+
const omitExpression = {
|
|
102
|
+
'@source': argumentExpression,
|
|
103
|
+
'@omit': (0, _lodash.times)(2, () => (0, _motionRuntimeTestContext.aString)())
|
|
104
|
+
};
|
|
105
|
+
const transformation = {
|
|
106
|
+
'*': omitExpression,
|
|
107
|
+
...sibling
|
|
108
|
+
};
|
|
109
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
110
|
+
accumulator,
|
|
111
|
+
visitors: {
|
|
112
|
+
TopLevelSpreadExpression: topLevelSpreadOperatorCallback,
|
|
113
|
+
NestedOmit: nestedOmitCallback
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
expect(topLevelSpreadOperatorCallback).toHaveBeenCalledTimes(1);
|
|
117
|
+
expect(topLevelSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, omitExpression, siblingKeys); // expect(nestedOmitCallback).toHaveBeenCalled();
|
|
118
|
+
});
|
|
119
|
+
test('traverses top-level spread-operator transformation nodes', () => {
|
|
120
|
+
const transformation = {
|
|
121
|
+
'*': argumentExpression,
|
|
122
|
+
...sibling
|
|
123
|
+
};
|
|
124
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
125
|
+
accumulator,
|
|
126
|
+
visitors: {
|
|
127
|
+
TopLevelSpreadExpression: topLevelSpreadOperatorCallback,
|
|
128
|
+
NestedSpreadExpression: nestedSpreadOperatorCallback
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
expect(topLevelSpreadOperatorCallback).toHaveBeenCalledTimes(1);
|
|
132
|
+
expect(topLevelSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, argumentExpression, siblingKeys);
|
|
133
|
+
expect(nestedSpreadOperatorCallback).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
test('traverses nested spread-operator transformation nodes', () => {
|
|
136
|
+
const transformation = (0, _lodash.set)({}, path, {
|
|
137
|
+
'*': argumentExpression,
|
|
138
|
+
...sibling
|
|
139
|
+
});
|
|
140
|
+
const simpleTransformationCallback = jest.fn();
|
|
141
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
142
|
+
accumulator,
|
|
143
|
+
visitors: {
|
|
144
|
+
TopLevelSpreadExpression: topLevelSpreadOperatorCallback,
|
|
145
|
+
NestedSpreadExpression: nestedSpreadOperatorCallback,
|
|
146
|
+
NestedSimpleTransformationExpression: simpleTransformationCallback
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
expect(topLevelSpreadOperatorCallback).not.toHaveBeenCalled();
|
|
150
|
+
expect(simpleTransformationCallback).not.toHaveBeenCalled();
|
|
151
|
+
expect(nestedSpreadOperatorCallback).toHaveBeenCalledTimes(1);
|
|
152
|
+
expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, path, argumentExpression, siblingKeys);
|
|
153
|
+
});
|
|
154
|
+
test('traverses items within an array of a spread-operator transformation nodes', () => {
|
|
155
|
+
const simpleTransformationCallback = jest.fn();
|
|
156
|
+
const transformation = (0, _lodash.set)({}, path, {
|
|
157
|
+
'*': ['$[0].x.y.z', '$[1].d.e.f'],
|
|
158
|
+
...sibling
|
|
159
|
+
});
|
|
160
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
161
|
+
accumulator,
|
|
162
|
+
visitors: {
|
|
163
|
+
NestedSpreadExpression: nestedSpreadOperatorCallback,
|
|
164
|
+
NestedSimpleTransformationExpression: simpleTransformationCallback
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
expect(nestedSpreadOperatorCallback).toHaveBeenCalledTimes(2);
|
|
168
|
+
expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, path, '$[0].x.y.z', siblingKeys);
|
|
169
|
+
expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, path, '$[1].d.e.f', siblingKeys);
|
|
170
|
+
expect(simpleTransformationCallback).not.toHaveBeenCalled();
|
|
171
|
+
});
|
|
172
|
+
test('sets the path to be the parent of the spread operator', () => {
|
|
173
|
+
const anotherArgumentExpression = '$[0].x.y.z';
|
|
174
|
+
const topLevelArgumentExpression = '$[1]';
|
|
175
|
+
const transformation = (0, _lodash.set)({
|
|
176
|
+
'*': topLevelArgumentExpression,
|
|
177
|
+
...sibling
|
|
178
|
+
}, path, {
|
|
179
|
+
'*': [anotherArgumentExpression, argumentExpression]
|
|
180
|
+
});
|
|
181
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
182
|
+
accumulator,
|
|
183
|
+
visitors: {
|
|
184
|
+
NestedSpreadExpression: nestedSpreadOperatorCallback,
|
|
185
|
+
TopLevelSpreadExpression: topLevelSpreadOperatorCallback
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
expect(nestedSpreadOperatorCallback).toHaveBeenCalledTimes(2);
|
|
189
|
+
expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, path, argumentExpression, []);
|
|
190
|
+
expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, path, anotherArgumentExpression, []);
|
|
191
|
+
expect(topLevelSpreadOperatorCallback).toHaveBeenCalledTimes(1);
|
|
192
|
+
expect(topLevelSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, topLevelArgumentExpression, siblingKeys);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
describe('custom functions', () => {
|
|
196
|
+
test('traverses custom-function nodes', () => {
|
|
197
|
+
const customFunctionExpressionCallback = jest.fn();
|
|
198
|
+
const simpleTransformationCallback = jest.fn();
|
|
199
|
+
const customFunctionExpression = '#someCustomFunction($[0].someCustomFunction)';
|
|
200
|
+
const transformation = {
|
|
201
|
+
a: {
|
|
202
|
+
b: customFunctionExpression
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
206
|
+
accumulator,
|
|
207
|
+
visitors: {
|
|
208
|
+
CustomFunctionExpression: customFunctionExpressionCallback,
|
|
209
|
+
NestedSimpleTransformationExpression: simpleTransformationCallback
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
expect(customFunctionExpressionCallback).toHaveBeenCalledTimes(1);
|
|
213
|
+
expect(customFunctionExpressionCallback).toHaveBeenCalledWith(accumulator, 'a.b', 'someCustomFunction', ['$[0].someCustomFunction'], customFunctionExpression);
|
|
214
|
+
expect(simpleTransformationCallback).not.toHaveBeenCalled();
|
|
215
|
+
});
|
|
216
|
+
test('does not fail on invalid custom-function nodes', () => {
|
|
217
|
+
const customFunctionExpressionCallback = jest.fn();
|
|
218
|
+
const simpleTransformationCallback = jest.fn();
|
|
219
|
+
const invalidCustomFunctionExpression = '#($[0].someCustomFunction)';
|
|
220
|
+
const transformation = {
|
|
221
|
+
a: {
|
|
222
|
+
b: invalidCustomFunctionExpression
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
226
|
+
accumulator,
|
|
227
|
+
visitors: {
|
|
228
|
+
CustomFunctionExpression: customFunctionExpressionCallback,
|
|
229
|
+
NestedSimpleTransformationExpression: simpleTransformationCallback
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
expect(customFunctionExpressionCallback).toHaveBeenCalledTimes(1);
|
|
233
|
+
expect(customFunctionExpressionCallback).toHaveBeenCalledWith(accumulator, 'a.b', null, null, invalidCustomFunctionExpression);
|
|
234
|
+
expect(simpleTransformationCallback).not.toHaveBeenCalled();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
describe('constant annotation', () => {
|
|
238
|
+
test('traverses a nested constant annotation expression', () => {
|
|
239
|
+
const nestedConstantExpressionCallback = jest.fn();
|
|
240
|
+
const undesiredVisitor = jest.fn();
|
|
241
|
+
const transformation = {
|
|
242
|
+
a: {
|
|
243
|
+
b: {
|
|
244
|
+
c: {
|
|
245
|
+
'@constant': {
|
|
246
|
+
someConst: '$.value123'
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
253
|
+
accumulator,
|
|
254
|
+
visitors: {
|
|
255
|
+
NestedConstantValue: nestedConstantExpressionCallback,
|
|
256
|
+
NestedSimpleTransformationExpression: undesiredVisitor
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
expect(nestedConstantExpressionCallback).toHaveBeenCalledTimes(1);
|
|
260
|
+
expect(nestedConstantExpressionCallback).toHaveBeenCalledWith({
|
|
261
|
+
accumulator,
|
|
262
|
+
path: 'a.b.c',
|
|
263
|
+
value: {
|
|
264
|
+
someConst: '$.value123'
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
expect(undesiredVisitor).not.toHaveBeenCalled();
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
test('returns the accumulator with changes made to it', () => {
|
|
271
|
+
const countAccumulator = {
|
|
272
|
+
count: 0
|
|
273
|
+
};
|
|
274
|
+
const transformation = {
|
|
275
|
+
a: {
|
|
276
|
+
b: 1,
|
|
277
|
+
'*': '$[0].a.b.c'
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const result = (0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
281
|
+
accumulator: countAccumulator,
|
|
282
|
+
visitors: {
|
|
283
|
+
NestedSpreadExpression: () => {
|
|
284
|
+
countAccumulator.count += 1;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
expect(result).toStrictEqual({
|
|
289
|
+
count: 1
|
|
290
|
+
});
|
|
291
|
+
}); // TODO: replace with returning the invalid value, for constant-transformation
|
|
292
|
+
|
|
293
|
+
test('invokes the NestedUnsupportedTransformationExpression otherwise', () => {
|
|
294
|
+
const visitorCallback = jest.fn();
|
|
295
|
+
const unsupportedTransformationValue = (0, _motionRuntimeTestContext.aString)();
|
|
296
|
+
const transformation = {
|
|
297
|
+
a: {
|
|
298
|
+
b: {
|
|
299
|
+
c: unsupportedTransformationValue
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
304
|
+
visitors: {
|
|
305
|
+
NestedUnsupportedTransformationExpression: visitorCallback
|
|
306
|
+
},
|
|
307
|
+
accumulator
|
|
308
|
+
});
|
|
309
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
310
|
+
expect(visitorCallback).toHaveBeenCalledWith(accumulator, 'a.b.c', unsupportedTransformationValue);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
describe('mapping array items', () => {
|
|
314
|
+
const visitorCallback = jest.fn();
|
|
315
|
+
beforeEach(() => {
|
|
316
|
+
visitorCallback.mockClear();
|
|
317
|
+
});
|
|
318
|
+
describe('top-level transformation', () => {
|
|
319
|
+
test('invokes the TopLevelMapArrayItems visitor', () => {
|
|
320
|
+
const transformation = {
|
|
321
|
+
'@path': '$.d.e.f',
|
|
322
|
+
'@itemTransformation': '$.g.h.i'
|
|
323
|
+
};
|
|
324
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
325
|
+
visitors: {
|
|
326
|
+
TopLevelMapArrayItems: visitorCallback
|
|
327
|
+
},
|
|
328
|
+
accumulator: {}
|
|
329
|
+
});
|
|
330
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
331
|
+
expect(visitorCallback).toHaveBeenCalledWith('$.d.e.f', '$.g.h.i');
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
describe('nested transformation', () => {
|
|
335
|
+
const accumulator = {};
|
|
336
|
+
const path = 'a.b.c';
|
|
337
|
+
|
|
338
|
+
const withItemTransformation = itemTransformation => (0, _lodash.set)({}, path, {
|
|
339
|
+
'@path': '$.d.e.f',
|
|
340
|
+
'@itemTransformation': itemTransformation
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
describe('simple item-transformation', () => {
|
|
344
|
+
test('invokes the MapArrayItems visitor', () => {
|
|
345
|
+
(0, _reduceTransformation.reduceTransformation)(withItemTransformation('$.g.h.i'), {
|
|
346
|
+
visitors: {
|
|
347
|
+
MapArrayItems: visitorCallback
|
|
348
|
+
},
|
|
349
|
+
accumulator
|
|
350
|
+
});
|
|
351
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
352
|
+
expect(visitorCallback).toHaveBeenCalledWith(accumulator, path, '$.d.e.f', '$.g.h.i');
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
describe('complex item-transformation', () => {
|
|
356
|
+
test('invokes the MapArrayItems visitor', () => {
|
|
357
|
+
const nestedSimpleTransformationVisitor = jest.fn();
|
|
358
|
+
(0, _reduceTransformation.reduceTransformation)(withItemTransformation({
|
|
359
|
+
yyy: '$.g.h.i',
|
|
360
|
+
zzz: '$.j.k.l'
|
|
361
|
+
}), {
|
|
362
|
+
visitors: {
|
|
363
|
+
MapArrayItems: visitorCallback,
|
|
364
|
+
NestedSimpleTransformationExpression: nestedSimpleTransformationVisitor
|
|
365
|
+
},
|
|
366
|
+
accumulator
|
|
367
|
+
});
|
|
368
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
369
|
+
expect(visitorCallback).toHaveBeenCalledWith(accumulator, path, '$.d.e.f', {
|
|
370
|
+
yyy: '$.g.h.i',
|
|
371
|
+
zzz: '$.j.k.l'
|
|
372
|
+
});
|
|
373
|
+
expect(nestedSimpleTransformationVisitor).not.toHaveBeenCalled();
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
describe('omit notation', () => {
|
|
379
|
+
const fieldsToOmit = (0, _lodash.times)(2, () => (0, _motionRuntimeTestContext.aString)());
|
|
380
|
+
const visitorCallback = jest.fn();
|
|
381
|
+
const sourcePathExpression = '$.d.e.f';
|
|
382
|
+
const path = 'a.b.c';
|
|
383
|
+
const accumulator = {};
|
|
384
|
+
beforeEach(() => {
|
|
385
|
+
visitorCallback.mockClear();
|
|
386
|
+
});
|
|
387
|
+
describe('top-level transformation', () => {
|
|
388
|
+
test('invokes the TopLevelOmit visitor', () => {
|
|
389
|
+
const transformation = {
|
|
390
|
+
'@source': sourcePathExpression,
|
|
391
|
+
'@omit': fieldsToOmit
|
|
392
|
+
};
|
|
393
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
394
|
+
visitors: {
|
|
395
|
+
TopLevelOmit: visitorCallback
|
|
396
|
+
},
|
|
397
|
+
accumulator
|
|
398
|
+
});
|
|
399
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
400
|
+
expect(visitorCallback).toHaveBeenCalledWith(sourcePathExpression, fieldsToOmit);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
describe('nested transformation', () => {
|
|
404
|
+
test('invokes the NestedOmit visitor', () => {
|
|
405
|
+
const transformation = (0, _lodash.set)({}, path, {
|
|
406
|
+
'@source': sourcePathExpression,
|
|
407
|
+
'@omit': fieldsToOmit
|
|
408
|
+
});
|
|
409
|
+
(0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
410
|
+
visitors: {
|
|
411
|
+
NestedOmit: visitorCallback
|
|
412
|
+
},
|
|
413
|
+
accumulator
|
|
414
|
+
});
|
|
415
|
+
expect(visitorCallback).toHaveBeenCalledTimes(1);
|
|
416
|
+
expect(visitorCallback).toHaveBeenCalledWith(accumulator, path, sourcePathExpression, fieldsToOmit);
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
describe('error handling', () => {
|
|
421
|
+
describe.each`
|
|
422
|
+
transformation | visitorType
|
|
423
|
+
${'$.a.b.c'} | ${'TopLevelSimpleTransformationExpression'}
|
|
424
|
+
${'#someCustomFunc($.a.b.c)'} | ${'TopLevelCustomFunctionExpression'}
|
|
425
|
+
${{
|
|
426
|
+
a: {
|
|
427
|
+
b: {
|
|
428
|
+
c: 'unsupported transformation'
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}} | ${'NestedUnsupportedTransformationExpression'}
|
|
432
|
+
${{
|
|
433
|
+
a: {
|
|
434
|
+
b: {
|
|
435
|
+
c: '$.d.e.f'
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}} | ${'NestedSimpleTransformationExpression'}
|
|
439
|
+
${{
|
|
440
|
+
'*': '$.d.e.f'
|
|
441
|
+
}} | ${'TopLevelSpreadExpression'}
|
|
442
|
+
${{
|
|
443
|
+
a: {
|
|
444
|
+
'*': '$.d.e.f'
|
|
445
|
+
}
|
|
446
|
+
}} | ${'NestedSpreadExpression'}
|
|
447
|
+
${{
|
|
448
|
+
a: {
|
|
449
|
+
b: '#someCustomFunction($.d.e.f)'
|
|
450
|
+
}
|
|
451
|
+
}} | ${'CustomFunctionExpression'}
|
|
452
|
+
`('$visitor visitor', ({
|
|
453
|
+
transformation,
|
|
454
|
+
visitorType
|
|
455
|
+
}) => {
|
|
456
|
+
test(`rethrows the error thrown by the ${visitorType} visitor`, () => {
|
|
457
|
+
const errorMessage = (0, _motionRuntimeTestContext.aString)();
|
|
458
|
+
const error = new Error(errorMessage);
|
|
459
|
+
const visitorCallback = jest.fn().mockImplementationOnce(() => {
|
|
460
|
+
throw error;
|
|
461
|
+
});
|
|
462
|
+
expect(() => (0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
463
|
+
visitors: {
|
|
464
|
+
[visitorType]: visitorCallback
|
|
465
|
+
}
|
|
466
|
+
})).toThrow(error);
|
|
467
|
+
});
|
|
468
|
+
test(`does not fail when the ${visitorType} visitor is missing`, () => {
|
|
469
|
+
expect(() => (0, _reduceTransformation.reduceTransformation)(transformation, {
|
|
470
|
+
visitors: {
|
|
471
|
+
[visitorType]: null
|
|
472
|
+
}
|
|
473
|
+
})).not.toThrow();
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
//# sourceMappingURL=reduceTransformation.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/reduceTransformation.spec.ts"],"names":["describe","visitorCallbackResult","test","visitorCallback","jest","fn","mockReturnValueOnce","transformation","result","visitors","TopLevelSimpleTransformationExpression","expect","toHaveBeenCalledTimes","toHaveBeenCalledWith","toStrictEqual","TopLevelCustomFunctionExpression","transformationWithInvalidCustomFunctionExpression","TopLevelUnsupportedTransformationExpression","accumulator","a","b","c","d","e","NestedSimpleTransformationExpression","topLevelSpreadOperatorCallback","nestedSpreadOperatorCallback","argumentExpression","sibling","siblingKeys","Object","keys","path","beforeEach","forEach","mock","mockClear","nestedOmitCallback","omitExpression","TopLevelSpreadExpression","NestedOmit","NestedSpreadExpression","not","toHaveBeenCalled","simpleTransformationCallback","anotherArgumentExpression","topLevelArgumentExpression","customFunctionExpressionCallback","customFunctionExpression","CustomFunctionExpression","invalidCustomFunctionExpression","nestedConstantExpressionCallback","undesiredVisitor","someConst","NestedConstantValue","value","countAccumulator","count","unsupportedTransformationValue","NestedUnsupportedTransformationExpression","TopLevelMapArrayItems","withItemTransformation","itemTransformation","MapArrayItems","nestedSimpleTransformationVisitor","yyy","zzz","fieldsToOmit","sourcePathExpression","TopLevelOmit","each","visitorType","errorMessage","error","Error","mockImplementationOnce","toThrow"],"mappings":";;AAAA;;AACA;;AACA;;AAEAA,QAAQ,CAAC,sBAAD,EAAyB,MAAM;AACrCA,EAAAA,QAAQ,CAAC,wBAAD,EAA2B,MAAM;AACvC,UAAMC,qBAAqB,GAAG,wCAA9B;AAEAC,IAAAA,IAAI,CAAC,mCAAD,EAAsC,MAAM;AAC9C,YAAMC,eAAe,GAAGC,IAAI,CACzBC,EADqB,GAErBC,mBAFqB,CAEDL,qBAFC,CAAxB;AAGA,YAAMM,cAAc,GAAG,SAAvB;AAEA,YAAMC,MAAM,GAAG,gDAAqBD,cAArB,EAAqC;AAClDE,QAAAA,QAAQ,EAAE;AACRC,UAAAA,sCAAsC,EAAEP;AADhC;AADwC,OAArC,CAAf;AAMAQ,MAAAA,MAAM,CAACR,eAAD,CAAN,CAAwBS,qBAAxB,CAA8C,CAA9C;AACAD,MAAAA,MAAM,CAACR,eAAD,CAAN,CAAwBU,oBAAxB,CAA6C,SAA7C;AACAF,MAAAA,MAAM,CAACH,MAAD,CAAN,CAAeM,aAAf,CAA6Bb,qBAA7B;AACD,KAfG,CAAJ;AAiBAD,IAAAA,QAAQ,CAAC,kBAAD,EAAqB,MAAM;AACjCE,MAAAA,IAAI,CAAC,8CAAD,EAAiD,MAAM;AACzD,cAAMC,eAAe,GAAGC,IAAI,CACzBC,EADqB,GAErBC,mBAFqB,CAEDL,qBAFC,CAAxB;AAGA,cAAMM,cAAc,GAAG,2CAAvB;AAEA,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CAAd;AACA,cAAMrE,eAAe,GAAGC,IAAI,CAACC,EAAL,GAAUsE,sBAAV,CAAiC,MAAM;AAC7D,gBAAMF,KAAN;AACD,SAFuB,CAAxB;AAIA9D,QAAAA,MAAM,CAAC,MACL,gDAAqBJ,cAArB,EAAqC;AACnCE,UAAAA,QAAQ,EAAE;AACR,aAAC8D,WAAD,GAAepE;AADP;AADyB,SAArC,CADI,CAAN,CAMEyE,OANF,CAMUH,KANV;AAOD,OAdG,CAAJ;AAgBAvE,MAAAA,IAAI,CAAE,0BAAyBqE,WAAY,qBAAvC,EAA6D,MAAM;AACrE5D,QAAAA,MAAM,CAAC,MACL,gDAAqBJ,cAArB,EAAqC;AACnCE,UAAAA,QAAQ,EAAE;AACR,aAAC8D,WAAD,GAAe;AADP;AADyB,SAArC,CADI,CAAN,CAME7B,GANF,CAMMkC,OANN;AAOD,OARG,CAAJ;AASD,KAnCD;AAoCD,GArCO,CAAR;AAsCD,CA1lBO,CAAR","sourcesContent":["import { anObject, aString } from '@wix/motion-runtime-test-context';\nimport { set, times } from 'lodash';\nimport { reduceTransformation } from '../lib/transformations/reduceTransformation';\n\ndescribe('reduceTransformation', () => {\n describe('simple transformations', () => {\n const visitorCallbackResult = aString();\n\n test('traverses a simple transformation', () => {\n const visitorCallback = jest\n .fn()\n .mockReturnValueOnce(visitorCallbackResult);\n const transformation = '$.a.b.c';\n\n const result = reduceTransformation(transformation, {\n visitors: {\n TopLevelSimpleTransformationExpression: visitorCallback,\n },\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith('$.a.b.c');\n expect(result).toStrictEqual(visitorCallbackResult);\n });\n\n describe('custom-functions', () => {\n test('traverses a valid custom-function expression', () => {\n const visitorCallback = jest\n .fn()\n .mockReturnValueOnce(visitorCallbackResult);\n const transformation = '#someCustomFunction($.a.b.c,someOtherArg)';\n\n const result = reduceTransformation(transformation, {\n visitors: {\n TopLevelCustomFunctionExpression: visitorCallback,\n },\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith(\n 'someCustomFunction',\n ['$.a.b.c', 'someOtherArg'],\n transformation,\n );\n expect(result).toStrictEqual(visitorCallbackResult);\n });\n\n test('does not fail for invalid custom-function expression', () => {\n const visitorCallback = jest\n .fn()\n .mockReturnValueOnce(visitorCallbackResult);\n const transformationWithInvalidCustomFunctionExpression = '#($.a.b.c)';\n\n const result = reduceTransformation(\n transformationWithInvalidCustomFunctionExpression,\n {\n visitors: {\n TopLevelCustomFunctionExpression: visitorCallback,\n },\n },\n );\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith(\n null,\n null,\n transformationWithInvalidCustomFunctionExpression,\n );\n expect(result).toStrictEqual(visitorCallbackResult);\n });\n });\n\n // TODO: replace with returning the invalid value, for constant-transformation\n test('invokes the TopLevelUnsupportedTransformationExpression otherwise', () => {\n const visitorCallback = jest\n .fn()\n .mockReturnValueOnce(visitorCallbackResult);\n\n const transformation = aString();\n\n const result = reduceTransformation(transformation, {\n visitors: {\n TopLevelUnsupportedTransformationExpression: visitorCallback,\n },\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith(transformation);\n expect(result).toStrictEqual(visitorCallbackResult);\n });\n });\n\n describe('complex transformation', () => {\n const accumulator = anObject();\n\n test('traverses all string nodes that are transformation expressions', () => {\n const visitorCallback = jest.fn();\n\n const transformation = {\n a: {\n b: { c: '$[0].ddd.eee.ffff' },\n d: 2,\n e: ['$.ggg', 3, 4, 5],\n },\n };\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n NestedSimpleTransformationExpression: visitorCallback,\n },\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(2);\n expect(visitorCallback).toHaveBeenCalledWith(\n accumulator,\n 'a.b.c',\n '$[0].ddd.eee.ffff',\n );\n expect(visitorCallback).toHaveBeenCalledWith(\n accumulator,\n 'a.e[0]',\n '$.ggg',\n );\n });\n\n describe('spread operator', () => {\n const [topLevelSpreadOperatorCallback, nestedSpreadOperatorCallback] =\n times(2, () => jest.fn());\n const argumentExpression = '$[1].d.e.f';\n const sibling = anObject();\n const siblingKeys = Object.keys(sibling);\n const path = `${siblingKeys[0]}.b.c`;\n\n beforeEach(() => {\n [topLevelSpreadOperatorCallback, nestedSpreadOperatorCallback].forEach(\n (mock) => mock.mockClear(),\n );\n });\n\n test('invokes the spread operator visitor prior to its children', () => {\n const nestedOmitCallback = jest.fn();\n const omitExpression = {\n '@source': argumentExpression,\n '@omit': times(2, () => aString()),\n };\n const transformation = { '*': omitExpression, ...sibling };\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n TopLevelSpreadExpression: topLevelSpreadOperatorCallback,\n NestedOmit: nestedOmitCallback,\n },\n });\n\n expect(topLevelSpreadOperatorCallback).toHaveBeenCalledTimes(1);\n expect(topLevelSpreadOperatorCallback).toHaveBeenCalledWith(\n accumulator,\n omitExpression,\n siblingKeys,\n );\n\n // expect(nestedOmitCallback).toHaveBeenCalled();\n });\n\n test('traverses top-level spread-operator transformation nodes', () => {\n const transformation = { '*': argumentExpression, ...sibling };\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n TopLevelSpreadExpression: topLevelSpreadOperatorCallback,\n NestedSpreadExpression: nestedSpreadOperatorCallback,\n },\n });\n\n expect(topLevelSpreadOperatorCallback).toHaveBeenCalledTimes(1);\n expect(topLevelSpreadOperatorCallback).toHaveBeenCalledWith(\n accumulator,\n argumentExpression,\n siblingKeys,\n );\n expect(nestedSpreadOperatorCallback).not.toHaveBeenCalled();\n });\n\n test('traverses nested spread-operator transformation nodes', () => {\n const transformation = set({}, path, {\n '*': argumentExpression,\n ...sibling,\n });\n const simpleTransformationCallback = jest.fn();\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n TopLevelSpreadExpression: topLevelSpreadOperatorCallback,\n NestedSpreadExpression: nestedSpreadOperatorCallback,\n NestedSimpleTransformationExpression: simpleTransformationCallback,\n },\n });\n\n expect(topLevelSpreadOperatorCallback).not.toHaveBeenCalled();\n expect(simpleTransformationCallback).not.toHaveBeenCalled();\n expect(nestedSpreadOperatorCallback).toHaveBeenCalledTimes(1);\n expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(\n accumulator,\n path,\n argumentExpression,\n siblingKeys,\n );\n });\n\n test('traverses items within an array of a spread-operator transformation nodes', () => {\n const simpleTransformationCallback = jest.fn();\n const transformation = set({}, path, {\n '*': ['$[0].x.y.z', '$[1].d.e.f'],\n ...sibling,\n });\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n NestedSpreadExpression: nestedSpreadOperatorCallback,\n NestedSimpleTransformationExpression: simpleTransformationCallback,\n },\n });\n\n expect(nestedSpreadOperatorCallback).toHaveBeenCalledTimes(2);\n expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(\n accumulator,\n path,\n '$[0].x.y.z',\n siblingKeys,\n );\n expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(\n accumulator,\n path,\n '$[1].d.e.f',\n siblingKeys,\n );\n\n expect(simpleTransformationCallback).not.toHaveBeenCalled();\n });\n\n test('sets the path to be the parent of the spread operator', () => {\n const anotherArgumentExpression = '$[0].x.y.z';\n const topLevelArgumentExpression = '$[1]';\n const transformation = set(\n { '*': topLevelArgumentExpression, ...sibling },\n path,\n {\n '*': [anotherArgumentExpression, argumentExpression],\n },\n );\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n NestedSpreadExpression: nestedSpreadOperatorCallback,\n TopLevelSpreadExpression: topLevelSpreadOperatorCallback,\n },\n });\n\n expect(nestedSpreadOperatorCallback).toHaveBeenCalledTimes(2);\n expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(\n accumulator,\n path,\n argumentExpression,\n [],\n );\n expect(nestedSpreadOperatorCallback).toHaveBeenCalledWith(\n accumulator,\n path,\n anotherArgumentExpression,\n [],\n );\n\n expect(topLevelSpreadOperatorCallback).toHaveBeenCalledTimes(1);\n expect(topLevelSpreadOperatorCallback).toHaveBeenCalledWith(\n accumulator,\n topLevelArgumentExpression,\n siblingKeys,\n );\n });\n });\n\n describe('custom functions', () => {\n test('traverses custom-function nodes', () => {\n const customFunctionExpressionCallback = jest.fn();\n const simpleTransformationCallback = jest.fn();\n const customFunctionExpression =\n '#someCustomFunction($[0].someCustomFunction)';\n const transformation = {\n a: {\n b: customFunctionExpression,\n },\n };\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n CustomFunctionExpression: customFunctionExpressionCallback,\n NestedSimpleTransformationExpression: simpleTransformationCallback,\n },\n });\n\n expect(customFunctionExpressionCallback).toHaveBeenCalledTimes(1);\n expect(customFunctionExpressionCallback).toHaveBeenCalledWith(\n accumulator,\n 'a.b',\n 'someCustomFunction',\n ['$[0].someCustomFunction'],\n customFunctionExpression,\n );\n\n expect(simpleTransformationCallback).not.toHaveBeenCalled();\n });\n\n test('does not fail on invalid custom-function nodes', () => {\n const customFunctionExpressionCallback = jest.fn();\n const simpleTransformationCallback = jest.fn();\n const invalidCustomFunctionExpression = '#($[0].someCustomFunction)';\n\n const transformation = {\n a: {\n b: invalidCustomFunctionExpression,\n },\n };\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n CustomFunctionExpression: customFunctionExpressionCallback,\n NestedSimpleTransformationExpression: simpleTransformationCallback,\n },\n });\n\n expect(customFunctionExpressionCallback).toHaveBeenCalledTimes(1);\n expect(customFunctionExpressionCallback).toHaveBeenCalledWith(\n accumulator,\n 'a.b',\n null,\n null,\n invalidCustomFunctionExpression,\n );\n\n expect(simpleTransformationCallback).not.toHaveBeenCalled();\n });\n });\n\n describe('constant annotation', () => {\n test('traverses a nested constant annotation expression', () => {\n const nestedConstantExpressionCallback = jest.fn();\n const undesiredVisitor = jest.fn();\n const transformation = {\n a: { b: { c: { '@constant': { someConst: '$.value123' } } } },\n };\n\n reduceTransformation(transformation, {\n accumulator,\n visitors: {\n NestedConstantValue: nestedConstantExpressionCallback,\n NestedSimpleTransformationExpression: undesiredVisitor,\n },\n });\n\n expect(nestedConstantExpressionCallback).toHaveBeenCalledTimes(1);\n expect(nestedConstantExpressionCallback).toHaveBeenCalledWith({\n accumulator,\n path: 'a.b.c',\n value: { someConst: '$.value123' },\n });\n expect(undesiredVisitor).not.toHaveBeenCalled();\n });\n });\n\n test('returns the accumulator with changes made to it', () => {\n const countAccumulator = { count: 0 };\n\n const transformation = {\n a: {\n b: 1,\n '*': '$[0].a.b.c',\n },\n };\n\n const result = reduceTransformation(transformation, {\n accumulator: countAccumulator,\n visitors: {\n NestedSpreadExpression: () => {\n countAccumulator.count += 1;\n },\n },\n });\n\n expect(result).toStrictEqual({ count: 1 });\n });\n\n // TODO: replace with returning the invalid value, for constant-transformation\n test('invokes the NestedUnsupportedTransformationExpression otherwise', () => {\n const visitorCallback = jest.fn();\n const unsupportedTransformationValue = aString();\n const transformation = {\n a: { b: { c: unsupportedTransformationValue } },\n };\n\n reduceTransformation(transformation, {\n visitors: {\n NestedUnsupportedTransformationExpression: visitorCallback,\n },\n accumulator,\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith(\n accumulator,\n 'a.b.c',\n unsupportedTransformationValue,\n );\n });\n });\n\n describe('mapping array items', () => {\n const visitorCallback = jest.fn();\n\n beforeEach(() => {\n visitorCallback.mockClear();\n });\n\n describe('top-level transformation', () => {\n test('invokes the TopLevelMapArrayItems visitor', () => {\n const transformation = {\n '@path': '$.d.e.f',\n '@itemTransformation': '$.g.h.i',\n };\n\n reduceTransformation(transformation, {\n visitors: {\n TopLevelMapArrayItems: visitorCallback,\n },\n accumulator: {},\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith('$.d.e.f', '$.g.h.i');\n });\n });\n\n describe('nested transformation', () => {\n const accumulator = {};\n const path = 'a.b.c';\n\n const withItemTransformation = (itemTransformation) =>\n set({}, path, {\n '@path': '$.d.e.f',\n '@itemTransformation': itemTransformation,\n });\n\n describe('simple item-transformation', () => {\n test('invokes the MapArrayItems visitor', () => {\n reduceTransformation(withItemTransformation('$.g.h.i'), {\n visitors: {\n MapArrayItems: visitorCallback,\n },\n accumulator,\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith(\n accumulator,\n path,\n '$.d.e.f',\n '$.g.h.i',\n );\n });\n });\n\n describe('complex item-transformation', () => {\n test('invokes the MapArrayItems visitor', () => {\n const nestedSimpleTransformationVisitor = jest.fn();\n\n reduceTransformation(\n withItemTransformation({ yyy: '$.g.h.i', zzz: '$.j.k.l' }),\n {\n visitors: {\n MapArrayItems: visitorCallback,\n NestedSimpleTransformationExpression:\n nestedSimpleTransformationVisitor,\n },\n accumulator,\n },\n );\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith(\n accumulator,\n path,\n '$.d.e.f',\n {\n yyy: '$.g.h.i',\n zzz: '$.j.k.l',\n },\n );\n expect(nestedSimpleTransformationVisitor).not.toHaveBeenCalled();\n });\n });\n });\n });\n\n describe('omit notation', () => {\n const fieldsToOmit = times(2, () => aString());\n const visitorCallback = jest.fn();\n const sourcePathExpression = '$.d.e.f';\n const path = 'a.b.c';\n const accumulator = {};\n\n beforeEach(() => {\n visitorCallback.mockClear();\n });\n\n describe('top-level transformation', () => {\n test('invokes the TopLevelOmit visitor', () => {\n const transformation = {\n '@source': sourcePathExpression,\n '@omit': fieldsToOmit,\n };\n\n reduceTransformation(transformation, {\n visitors: {\n TopLevelOmit: visitorCallback,\n },\n accumulator,\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith(\n sourcePathExpression,\n fieldsToOmit,\n );\n });\n });\n\n describe('nested transformation', () => {\n test('invokes the NestedOmit visitor', () => {\n const transformation = set({}, path, {\n '@source': sourcePathExpression,\n '@omit': fieldsToOmit,\n });\n\n reduceTransformation(transformation, {\n visitors: {\n NestedOmit: visitorCallback,\n },\n accumulator,\n });\n\n expect(visitorCallback).toHaveBeenCalledTimes(1);\n expect(visitorCallback).toHaveBeenCalledWith(\n accumulator,\n path,\n sourcePathExpression,\n fieldsToOmit,\n );\n });\n });\n });\n\n describe('error handling', () => {\n describe.each`\n transformation | visitorType\n ${'$.a.b.c'} | ${'TopLevelSimpleTransformationExpression'}\n ${'#someCustomFunc($.a.b.c)'} | ${'TopLevelCustomFunctionExpression'}\n ${{ a: { b: { c: 'unsupported transformation' } } }} | ${'NestedUnsupportedTransformationExpression'}\n ${{ a: { b: { c: '$.d.e.f' } } }} | ${'NestedSimpleTransformationExpression'}\n ${{ '*': '$.d.e.f' }} | ${'TopLevelSpreadExpression'}\n ${{ a: { '*': '$.d.e.f' } }} | ${'NestedSpreadExpression'}\n ${{ a: { b: '#someCustomFunction($.d.e.f)' } }} | ${'CustomFunctionExpression'}\n `('$visitor visitor', ({ transformation, visitorType }) => {\n test(`rethrows the error thrown by the ${visitorType} visitor`, () => {\n const errorMessage = aString();\n const error = new Error(errorMessage);\n const visitorCallback = jest.fn().mockImplementationOnce(() => {\n throw error;\n });\n\n expect(() =>\n reduceTransformation(transformation, {\n visitors: {\n [visitorType]: visitorCallback,\n },\n }),\n ).toThrow(error);\n });\n\n test(`does not fail when the ${visitorType} visitor is missing`, () => {\n expect(() =>\n reduceTransformation(transformation, {\n visitors: {\n [visitorType]: null,\n },\n }),\n ).not.toThrow();\n });\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
|
|
4
|
+
|
|
5
|
+
var _lodash = require("lodash");
|
|
6
|
+
|
|
7
|
+
var _ = require("../..");
|
|
8
|
+
|
|
9
|
+
var _customFunctions = require("../../lib/transformations/custom-functions");
|
|
10
|
+
|
|
11
|
+
describe('parseCustomFunctionCall', () => {
|
|
12
|
+
/* eslint-disable max-len */
|
|
13
|
+
test.each`
|
|
14
|
+
argumentCount | argumentExpressions | expectedArgumentExpressions
|
|
15
|
+
${'a single argument'} | ${'$[0].some.path'} | ${['$[0].some.path']}
|
|
16
|
+
${'multiple arguments'} | ${'$[0].some.path,someString'} | ${['$[0].some.path', 'someString']}
|
|
17
|
+
${'multiple arguments with whitespaces'} | ${'$[0].some.path, someString , $[1]'} | ${['$[0].some.path', 'someString', '$[1]']}
|
|
18
|
+
${'no arguments'} | ${''} | ${[]}
|
|
19
|
+
`(
|
|
20
|
+
/* eslint-enable max-len */
|
|
21
|
+
'parses a custom-function call applied with $argumentCount', ({
|
|
22
|
+
argumentExpressions,
|
|
23
|
+
expectedArgumentExpressions
|
|
24
|
+
}) => {
|
|
25
|
+
const functionName = (0, _motionRuntimeTestContext.aString)();
|
|
26
|
+
const functionExpression = `#${functionName}(${argumentExpressions})`;
|
|
27
|
+
expect((0, _.parseCustomFunctionCall)(functionExpression)).toStrictEqual({
|
|
28
|
+
functionName,
|
|
29
|
+
argumentExpressions: expectedArgumentExpressions
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('isFunctionCallExpression', () => {
|
|
34
|
+
test.each`
|
|
35
|
+
description | expression | expectedResult
|
|
36
|
+
${'a #-prefixed with a valid function name'} | ${'#someInvalidName$#@#>'} | ${true}
|
|
37
|
+
${'a non-# prefixed with a valid function name'} | ${'someFunctions($[1])'} | ${false}
|
|
38
|
+
${'a non-string value'} | ${[1, 2, 3]} | ${false}
|
|
39
|
+
`('returns $expectedResult when $description function call expression is provided', ({
|
|
40
|
+
expression,
|
|
41
|
+
expectedResult
|
|
42
|
+
}) => {
|
|
43
|
+
expect((0, _.isFunctionCallExpression)(expression)).toStrictEqual(expectedResult);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('runCustomFunctionCallExpression', () => {
|
|
47
|
+
const value = (0, _motionRuntimeTestContext.aString)();
|
|
48
|
+
const transformationParentPath = (0, _motionRuntimeTestContext.aString)();
|
|
49
|
+
|
|
50
|
+
const joinWithDots = (...args) => args.join('|');
|
|
51
|
+
|
|
52
|
+
describe.each`
|
|
53
|
+
argumentCount | argumentValues | expectedResult
|
|
54
|
+
${'single'} | ${[value]} | ${value}
|
|
55
|
+
${'multi'} | ${[value, value]} | ${`${value}|${value}`}
|
|
56
|
+
${'no'} | ${[]} | ${''}
|
|
57
|
+
`('$argumentCount-argument expression', ({
|
|
58
|
+
argumentValues,
|
|
59
|
+
expectedResult
|
|
60
|
+
}) => {
|
|
61
|
+
describe.each`
|
|
62
|
+
functionName | description
|
|
63
|
+
${'someFunction'} | ${'an unscoped'}
|
|
64
|
+
${'someScope.someFunction'} | ${'a scoped'}
|
|
65
|
+
`('$description custom function', ({
|
|
66
|
+
functionName
|
|
67
|
+
}) => {
|
|
68
|
+
const customFunctions = (0, _lodash.set)({}, functionName, joinWithDots);
|
|
69
|
+
test('runs it and returns its result', () => {
|
|
70
|
+
const result = (0, _customFunctions.runCustomFunctionCallExpression)({
|
|
71
|
+
functionName,
|
|
72
|
+
customFunctions,
|
|
73
|
+
argumentValues,
|
|
74
|
+
transformationParentPath
|
|
75
|
+
});
|
|
76
|
+
expect(result).toStrictEqual(expectedResult);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('error handling', () => {
|
|
81
|
+
const argumentValues = (0, _lodash.times)(2, () => (0, _motionRuntimeTestContext.aString)());
|
|
82
|
+
test('throws when the function is not recognized', () => {
|
|
83
|
+
const customFunctions = {};
|
|
84
|
+
expect(() => (0, _customFunctions.runCustomFunctionCallExpression)({
|
|
85
|
+
functionName: 'someNonexistentFunction',
|
|
86
|
+
customFunctions,
|
|
87
|
+
argumentValues,
|
|
88
|
+
transformationParentPath
|
|
89
|
+
})).toThrow(`unrecognized custom function "someNonexistentFunction"`);
|
|
90
|
+
});
|
|
91
|
+
test('throws an error when the function call throws an error', () => {
|
|
92
|
+
const functionName = (0, _motionRuntimeTestContext.aString)();
|
|
93
|
+
const customFunctions = {
|
|
94
|
+
[functionName]: () => {
|
|
95
|
+
throw new Error('Something went wrong in the custom function');
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const t = () => (0, _customFunctions.runCustomFunctionCallExpression)({
|
|
100
|
+
functionName,
|
|
101
|
+
customFunctions,
|
|
102
|
+
argumentValues,
|
|
103
|
+
transformationParentPath
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(t).toThrow(Error);
|
|
107
|
+
expect(t).toThrow(new RegExp(`Transforming ${transformationParentPath} failed, #${functionName} threw: "Something went wrong in the custom function" for arguments: .+`));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=custom-functions.spec.js.map
|