@wix/motion-edm-autogen-transformations-core 1.17.0 → 1.19.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.
Files changed (131) hide show
  1. package/dist/cjs/__tests__/corvid-entity.spec.js +1 -4
  2. package/dist/cjs/__tests__/corvid-entity.spec.js.map +1 -1
  3. package/dist/cjs/__tests__/getArgumentCardinality.spec.js +6 -5
  4. package/dist/cjs/__tests__/getArgumentCardinality.spec.js.map +1 -1
  5. package/dist/cjs/__tests__/helpers.spec.js +2 -6
  6. package/dist/cjs/__tests__/helpers.spec.js.map +1 -1
  7. package/dist/cjs/__tests__/reduceTransformation.spec.js +10 -11
  8. package/dist/cjs/__tests__/reduceTransformation.spec.js.map +1 -1
  9. package/dist/cjs/__tests__/transformations/custom-functions.spec.js +1 -10
  10. package/dist/cjs/__tests__/transformations/custom-functions.spec.js.map +1 -1
  11. package/dist/cjs/__tests__/transformations/preset/create-transformation.spec.js +2 -5
  12. package/dist/cjs/__tests__/transformations/preset/create-transformation.spec.js.map +1 -1
  13. package/dist/cjs/__tests__/transformations/preset/delete-transformation.spec.js +4 -7
  14. package/dist/cjs/__tests__/transformations/preset/delete-transformation.spec.js.map +1 -1
  15. package/dist/cjs/__tests__/transformations/preset/get-transformation.spec.js +2 -5
  16. package/dist/cjs/__tests__/transformations/preset/get-transformation.spec.js.map +1 -1
  17. package/dist/cjs/__tests__/transformations/preset/list-transformation.spec.js +2 -4
  18. package/dist/cjs/__tests__/transformations/preset/list-transformation.spec.js.map +1 -1
  19. package/dist/cjs/__tests__/transformations/preset/query-transformation.spec.js +6 -9
  20. package/dist/cjs/__tests__/transformations/preset/query-transformation.spec.js.map +1 -1
  21. package/dist/cjs/__tests__/transformations/preset/update-transformation.spec.js +4 -7
  22. package/dist/cjs/__tests__/transformations/preset/update-transformation.spec.js.map +1 -1
  23. package/dist/cjs/__tests__/validations/validateRequestTransformation.spec.js +5 -11
  24. package/dist/cjs/__tests__/validations/validateRequestTransformation.spec.js.map +1 -1
  25. package/dist/cjs/__tests__/validations/validateResponseTransformation.spec.js +1 -9
  26. package/dist/cjs/__tests__/validations/validateResponseTransformation.spec.js.map +1 -1
  27. package/dist/cjs/index.js +16 -36
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/lib/corvid-entity/index.js +0 -10
  30. package/dist/cjs/lib/corvid-entity/index.js.map +1 -1
  31. package/dist/cjs/lib/getArgumentCardinality.js +0 -9
  32. package/dist/cjs/lib/getArgumentCardinality.js.map +1 -1
  33. package/dist/cjs/lib/helpers.js +8 -48
  34. package/dist/cjs/lib/helpers.js.map +1 -1
  35. package/dist/cjs/lib/transformations/common.js +0 -3
  36. package/dist/cjs/lib/transformations/common.js.map +1 -1
  37. package/dist/cjs/lib/transformations/constants.js.map +1 -1
  38. package/dist/cjs/lib/transformations/custom-functions.js +0 -10
  39. package/dist/cjs/lib/transformations/custom-functions.js.map +1 -1
  40. package/dist/cjs/lib/transformations/preset/create.js +0 -5
  41. package/dist/cjs/lib/transformations/preset/create.js.map +1 -1
  42. package/dist/cjs/lib/transformations/preset/delete.js +0 -12
  43. package/dist/cjs/lib/transformations/preset/delete.js.map +1 -1
  44. package/dist/cjs/lib/transformations/preset/get.js +0 -5
  45. package/dist/cjs/lib/transformations/preset/get.js.map +1 -1
  46. package/dist/cjs/lib/transformations/preset/list.js +0 -4
  47. package/dist/cjs/lib/transformations/preset/list.js.map +1 -1
  48. package/dist/cjs/lib/transformations/preset/query.js +1 -8
  49. package/dist/cjs/lib/transformations/preset/query.js.map +1 -1
  50. package/dist/cjs/lib/transformations/preset/update.js +0 -9
  51. package/dist/cjs/lib/transformations/preset/update.js.map +1 -1
  52. package/dist/cjs/lib/transformations/reduceTransformation.js +28 -64
  53. package/dist/cjs/lib/transformations/reduceTransformation.js.map +1 -1
  54. package/dist/cjs/lib/transformations/validations/common.js +3 -13
  55. package/dist/cjs/lib/transformations/validations/common.js.map +1 -1
  56. package/dist/cjs/lib/transformations/validations/validateRequestTransformation.js +2 -23
  57. package/dist/cjs/lib/transformations/validations/validateRequestTransformation.js.map +1 -1
  58. package/dist/cjs/lib/transformations/validations/validateResponseTransformation.js +10 -36
  59. package/dist/cjs/lib/transformations/validations/validateResponseTransformation.js.map +1 -1
  60. package/dist/esm/__tests__/corvid-entity.spec.js +2 -2
  61. package/dist/esm/__tests__/corvid-entity.spec.js.map +1 -1
  62. package/dist/esm/__tests__/getArgumentCardinality.spec.js +1 -1
  63. package/dist/esm/__tests__/getArgumentCardinality.spec.js.map +1 -1
  64. package/dist/esm/__tests__/helpers.spec.js +2 -2
  65. package/dist/esm/__tests__/helpers.spec.js.map +1 -1
  66. package/dist/esm/__tests__/reduceTransformation.spec.js.map +1 -1
  67. package/dist/esm/__tests__/transformations/custom-functions.spec.js +1 -1
  68. package/dist/esm/__tests__/transformations/custom-functions.spec.js.map +1 -1
  69. package/dist/esm/__tests__/transformations/preset/create-transformation.spec.js.map +1 -1
  70. package/dist/esm/__tests__/transformations/preset/delete-transformation.spec.js +1 -1
  71. package/dist/esm/__tests__/transformations/preset/delete-transformation.spec.js.map +1 -1
  72. package/dist/esm/__tests__/transformations/preset/get-transformation.spec.js.map +1 -1
  73. package/dist/esm/__tests__/transformations/preset/list-transformation.spec.js.map +1 -1
  74. package/dist/esm/__tests__/transformations/preset/query-transformation.spec.js.map +1 -1
  75. package/dist/esm/__tests__/transformations/preset/update-transformation.spec.js.map +1 -1
  76. package/dist/esm/__tests__/validations/validateRequestTransformation.spec.js +1 -1
  77. package/dist/esm/__tests__/validations/validateRequestTransformation.spec.js.map +1 -1
  78. package/dist/esm/__tests__/validations/validateResponseTransformation.spec.js +1 -1
  79. package/dist/esm/__tests__/validations/validateResponseTransformation.spec.js.map +1 -1
  80. package/dist/esm/index.js +4 -4
  81. package/dist/esm/index.js.map +1 -1
  82. package/dist/esm/lib/corvid-entity/index.js +1 -1
  83. package/dist/esm/lib/corvid-entity/index.js.map +1 -1
  84. package/dist/esm/lib/getArgumentCardinality.js +1 -1
  85. package/dist/esm/lib/getArgumentCardinality.js.map +1 -1
  86. package/dist/esm/lib/helpers.js +2 -2
  87. package/dist/esm/lib/helpers.js.map +1 -1
  88. package/dist/esm/lib/transformations/constants.js +1 -1
  89. package/dist/esm/lib/transformations/constants.js.map +1 -1
  90. package/dist/esm/lib/transformations/custom-functions.js +2 -2
  91. package/dist/esm/lib/transformations/custom-functions.js.map +1 -1
  92. package/dist/esm/lib/transformations/preset/create.js.map +1 -1
  93. package/dist/esm/lib/transformations/preset/delete.js +1 -1
  94. package/dist/esm/lib/transformations/preset/delete.js.map +1 -1
  95. package/dist/esm/lib/transformations/preset/get.js.map +1 -1
  96. package/dist/esm/lib/transformations/preset/list.js +1 -1
  97. package/dist/esm/lib/transformations/preset/list.js.map +1 -1
  98. package/dist/esm/lib/transformations/preset/query.js.map +1 -1
  99. package/dist/esm/lib/transformations/preset/update.js +1 -1
  100. package/dist/esm/lib/transformations/preset/update.js.map +1 -1
  101. package/dist/esm/lib/transformations/reduceTransformation.js +3 -3
  102. package/dist/esm/lib/transformations/reduceTransformation.js.map +1 -1
  103. package/dist/esm/lib/transformations/validations/common.js +2 -2
  104. package/dist/esm/lib/transformations/validations/common.js.map +1 -1
  105. package/dist/esm/lib/transformations/validations/validateRequestTransformation.js +3 -3
  106. package/dist/esm/lib/transformations/validations/validateRequestTransformation.js.map +1 -1
  107. package/dist/esm/lib/transformations/validations/validateResponseTransformation.js +3 -3
  108. package/dist/esm/lib/transformations/validations/validateResponseTransformation.js.map +1 -1
  109. package/dist/tsconfig.tsbuildinfo +1 -1
  110. package/dist/types/index.d.ts +3 -3
  111. package/dist/types/index.d.ts.map +1 -1
  112. package/dist/types/lib/corvid-entity/index.d.ts +1 -1
  113. package/dist/types/lib/corvid-entity/index.d.ts.map +1 -1
  114. package/dist/types/lib/helpers.d.ts +1 -1
  115. package/dist/types/lib/helpers.d.ts.map +1 -1
  116. package/dist/types/lib/transformations/constants.d.ts +1 -1
  117. package/dist/types/lib/transformations/constants.d.ts.map +1 -1
  118. package/dist/types/lib/transformations/custom-functions.d.ts +1 -1
  119. package/dist/types/lib/transformations/custom-functions.d.ts.map +1 -1
  120. package/dist/types/lib/transformations/preset/create.d.ts.map +1 -1
  121. package/dist/types/lib/transformations/preset/delete.d.ts.map +1 -1
  122. package/dist/types/lib/transformations/preset/get.d.ts.map +1 -1
  123. package/dist/types/lib/transformations/preset/list.d.ts.map +1 -1
  124. package/dist/types/lib/transformations/preset/query.d.ts.map +1 -1
  125. package/dist/types/lib/transformations/preset/update.d.ts.map +1 -1
  126. package/dist/types/lib/transformations/reduceTransformation.d.ts.map +1 -1
  127. package/dist/types/lib/transformations/validations/common.d.ts +1 -1
  128. package/dist/types/lib/transformations/validations/common.d.ts.map +1 -1
  129. package/dist/types/lib/transformations/validations/validateRequestTransformation.d.ts.map +1 -1
  130. package/dist/types/lib/transformations/validations/validateResponseTransformation.d.ts.map +1 -1
  131. package/package.json +6 -5
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
4
-
5
4
  var _ = require("..");
6
-
7
5
  var _corvidEntity = require("../lib/corvid-entity");
8
-
9
6
  const toCorvidName = _.corvidEntities.toCorvidName,
10
- fromCorvidName = _.corvidEntities.fromCorvidName;
7
+ fromCorvidName = _.corvidEntities.fromCorvidName;
11
8
  describe('corvid entities transformers', () => {
12
9
  describe('toCorvidName', () => {
13
10
  test.each`
@@ -1 +1 @@
1
- {"version":3,"names":["toCorvidName","corvidEntities","fromCorvidName","describe","test","each","name","expected","expect","toStrictEqual","aString","nonReservedName","reservedCorvidName","aRandomItemFrom","isReservedCorvidFieldName","toBeTruthy","toBeFalsy","commonReservedName","isReservedCommonFieldName"],"sources":["../../../src/__tests__/corvid-entity.spec.ts"],"sourcesContent":["import { aString, aRandomItemFrom } from '@wix/motion-runtime-test-context';\nimport { corvidEntities } from '..';\nimport {\n isReservedCorvidFieldName,\n isReservedCommonFieldName,\n} from '../lib/corvid-entity';\n\nconst { toCorvidName, fromCorvidName } = corvidEntities;\n\ndescribe('corvid entities transformers', () => {\n describe('toCorvidName', () => {\n test.each`\n name | expected\n ${'id'} | ${'_id'}\n ${'createdDate'} | ${'_createdDate'}\n ${'updatedDate'} | ${'_updatedDate'}\n `('adjusts $name to $expected', ({ name, expected }) => {\n expect(toCorvidName(name)).toStrictEqual(expected);\n });\n\n test('returns the given name when it should not be changed', () => {\n const name = aString();\n\n expect(toCorvidName(name)).toStrictEqual(name);\n });\n });\n\n describe('fromCorvidName', () => {\n test.each`\n name | expected\n ${'_id'} | ${'id'}\n ${'_createdDate'} | ${'createdDate'}\n ${'_updatedDate'} | ${'updatedDate'}\n `('adjusts $name to $expected', ({ name, expected }) => {\n expect(fromCorvidName(name)).toStrictEqual(expected);\n });\n\n test('returns the given name when it should not be changed', () => {\n const name = aString();\n\n expect(fromCorvidName(name)).toStrictEqual(name);\n });\n });\n\n describe('internal methods', () => {\n const nonReservedName = aString();\n\n describe('isReservedCorvidFieldName', () => {\n test('returns true if the provided name is a reserved Corvid field-name', () => {\n const reservedCorvidName = aRandomItemFrom([\n '_id',\n '_createdDate',\n '_updatedDate',\n ]);\n\n expect(isReservedCorvidFieldName(reservedCorvidName)).toBeTruthy();\n });\n\n test('returns false if the provided name is not a reserved common field-name', () => {\n expect(isReservedCorvidFieldName(nonReservedName)).toBeFalsy();\n });\n });\n\n describe('isReservedCommonFieldName', () => {\n test('returns true if the provided name is a reserved common field-name', () => {\n const commonReservedName = aRandomItemFrom([\n 'id',\n 'createdDate',\n 'updatedDate',\n ]);\n\n expect(isReservedCommonFieldName(commonReservedName)).toBeTruthy();\n });\n\n test('returns false if the provided name is not a reserved common field-name', () => {\n expect(isReservedCommonFieldName(nonReservedName)).toBeFalsy();\n });\n });\n });\n});\n"],"mappings":";;AAAA;;AACA;;AACA;;AAKA,MAAQA,YAAR,GAAyCC,gBAAzC,CAAQD,YAAR;AAAA,MAAsBE,c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GAAxB;IAEAP,QAAQ,CAAC,2BAAD,EAA8B,MAAM;MAC1CC,IAAI,CAAC,mEAAD,EAAsE,MAAM;QAC9E,MAAMQ,kBAAkB,GAAG,IAAAC,yCAAA,EAAgB,CACzC,KADyC,EAEzC,cAFyC,EAGzC,cAHyC,CAAhB,CAA3B;QAMAL,MAAM,CAAC,IAAAM,uCAAA,EAA0BF,kBAA1B,CAAD,CAAN,CAAsDG,UAAtD;MACD,CARG,CAAJ;MAUAX,IAAI,CAAC,wEAAD,EAA2E,MAAM;QACnFI,MAAM,CAAC,IAAAM,uCAAA,EAA0BH,eAA1B,CAAD,CAAN,CAAmDK,SAAnD;MACD,CAFG,CAAJ;IAGD,CAdO,CAAR;IAgBAb,QAAQ,CAAC,2BAAD,EAA8B,MAAM;MAC1CC,IAAI,CAAC,mEAAD,EAAsE,MAAM;QAC9E,MAAMa,kBAAkB,GAAG,IAAAJ,yCAAA,EAAgB,CACzC,IADyC,EAEzC,aAFyC,EAGzC,aAHyC,CAAhB,CAA3B;QAMAL,MAAM,CAAC,IAAAU,uCAAA,EAA0BD,kBAA1B,CAAD,CAAN,CAAsDF,UAAtD;MACD,CARG,CAAJ;MAUAX,IAAI,CAAC,wEAAD,EAA2E,MAAM;QACnFI,MAAM,CAAC,IAAAU,uCAAA,EAA0BP,eAA1B,CAAD,CAAN,CAAmDK,SAAnD;MACD,CAFG,CAAJ;IAGD,CAdO,CAAR;EAeD,CAlCO,CAAR;AAmCD,CAtEO,CAAR"}
1
+ {"version":3,"names":["_motionRuntimeTestContext","require","_","_corvidEntity","toCorvidName","corvidEntities","fromCorvidName","describe","test","each","name","expected","expect","toStrictEqual","aString","nonReservedName","reservedCorvidName","aRandomItemFrom","isReservedCorvidFieldName","toBeTruthy","toBeFalsy","commonReservedName","isReservedCommonFieldName"],"sources":["../../../src/__tests__/corvid-entity.spec.ts"],"sourcesContent":["import { aRandomItemFrom, aString } from '@wix/motion-runtime-test-context';\n\nimport { corvidEntities } from '..';\nimport {\n isReservedCommonFieldName,\n isReservedCorvidFieldName,\n} from '../lib/corvid-entity';\n\nconst { toCorvidName, fromCorvidName } = corvidEntities;\n\ndescribe('corvid entities transformers', () => {\n describe('toCorvidName', () => {\n test.each`\n name | expected\n ${'id'} | ${'_id'}\n ${'createdDate'} | ${'_createdDate'}\n ${'updatedDate'} | ${'_updatedDate'}\n `('adjusts $name to $expected', ({ name, expected }) => {\n expect(toCorvidName(name)).toStrictEqual(expected);\n });\n\n test('returns the given name when it should not be changed', () => {\n const name = aString();\n\n expect(toCorvidName(name)).toStrictEqual(name);\n });\n });\n\n describe('fromCorvidName', () => {\n test.each`\n name | expected\n ${'_id'} | ${'id'}\n ${'_createdDate'} | ${'createdDate'}\n ${'_updatedDate'} | ${'updatedDate'}\n `('adjusts $name to $expected', ({ name, expected }) => {\n expect(fromCorvidName(name)).toStrictEqual(expected);\n });\n\n test('returns the given name when it should not be changed', () => {\n const name = aString();\n\n expect(fromCorvidName(name)).toStrictEqual(name);\n });\n });\n\n describe('internal methods', () => {\n const nonReservedName = aString();\n\n describe('isReservedCorvidFieldName', () => {\n test('returns true if the provided name is a reserved Corvid field-name', () => {\n const reservedCorvidName = aRandomItemFrom([\n '_id',\n '_createdDate',\n '_updatedDate',\n ]);\n\n expect(isReservedCorvidFieldName(reservedCorvidName)).toBeTruthy();\n });\n\n test('returns false if the provided name is not a reserved common field-name', () => {\n expect(isReservedCorvidFieldName(nonReservedName)).toBeFalsy();\n });\n });\n\n describe('isReservedCommonFieldName', () => {\n test('returns true if the provided name is a reserved common field-name', () => {\n const commonReservedName = aRandomItemFrom([\n 'id',\n 'createdDate',\n 'updatedDate',\n ]);\n\n expect(isReservedCommonFieldName(commonReservedName)).toBeTruthy();\n });\n\n test('returns false if the provided name is not a reserved common field-name', () => {\n expect(isReservedCommonFieldName(nonReservedName)).toBeFalsy();\n });\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AAEA,IAAAC,CAAA,GAAAD,O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IAClD,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFH,QAAQ,CAAC,kBAAkB,EAAE,MAAM;IACjC,MAAMQ,eAAe,GAAG,IAAAD,iCAAO,EAAC,CAAC;IAEjCP,QAAQ,CAAC,2BAA2B,EAAE,MAAM;MAC1CC,IAAI,CAAC,mEAAmE,EAAE,MAAM;QAC9E,MAAMQ,kBAAkB,GAAG,IAAAC,yCAAe,EAAC,CACzC,KAAK,EACL,cAAc,EACd,cAAc,CACf,CAAC;QAEFL,MAAM,CAAC,IAAAM,uCAAyB,EAACF,kBAAkB,CAAC,CAAC,CAACG,UAAU,CAAC,CAAC;MACpE,CAAC,CAAC;MAEFX,IAAI,CAAC,wEAAwE,EAAE,MAAM;QACnFI,MAAM,CAAC,IAAAM,uCAAyB,EAACH,eAAe,CAAC,CAAC,CAACK,SAAS,CAAC,CAAC;MAChE,CAAC,CAAC;IACJ,CAAC,CAAC;IAEFb,QAAQ,CAAC,2BAA2B,EAAE,MAAM;MAC1CC,IAAI,CAAC,mEAAmE,EAAE,MAAM;QAC9E,MAAMa,kBAAkB,GAAG,IAAAJ,yCAAe,EAAC,CACzC,IAAI,EACJ,aAAa,EACb,aAAa,CACd,CAAC;QAEFL,MAAM,CAAC,IAAAU,uCAAyB,EAACD,kBAAkB,CAAC,CAAC,CAACF,UAAU,CAAC,CAAC;MACpE,CAAC,CAAC;MAEFX,IAAI,CAAC,wEAAwE,EAAE,MAAM;QACnFI,MAAM,CAAC,IAAAU,uCAAyB,EAACP,eAAe,CAAC,CAAC,CAACK,SAAS,CAAC,CAAC;MAChE,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
4
-
5
4
  var _ = require("..");
6
-
7
5
  describe('getArgumentCardinality', () => {
8
6
  describe('simple transformation', () => {
9
7
  const simpleTransformation = `$[${(0, _motionRuntimeTestContext.aNumber)({
@@ -23,19 +21,22 @@ describe('getArgumentCardinality', () => {
23
21
  };
24
22
  const argumentMappingArray = ['$[0].a', '$[1].b', 'a.b.c'];
25
23
  test('counts the number of arguments referenced in a given transformation object', () => {
26
- const complexMappingTransformation = { ...nonArgumentMapping,
24
+ const complexMappingTransformation = {
25
+ ...nonArgumentMapping,
27
26
  ...argumentMapping
28
27
  };
29
28
  expect((0, _.getArgumentCardinality)(complexMappingTransformation)).toStrictEqual(4);
30
29
  });
31
30
  test('counts the number of arguments referenced in a transformation object with arrays', () => {
32
- const complexMappingTransformation = { ...nonArgumentMapping,
31
+ const complexMappingTransformation = {
32
+ ...nonArgumentMapping,
33
33
  [(0, _motionRuntimeTestContext.aString)()]: argumentMappingArray
34
34
  };
35
35
  expect((0, _.getArgumentCardinality)(complexMappingTransformation)).toStrictEqual(2);
36
36
  });
37
37
  test('counts only unique occurrences', () => {
38
- const complexMappingTransformation = { ...nonArgumentMapping,
38
+ const complexMappingTransformation = {
39
+ ...nonArgumentMapping,
39
40
  ...argumentMapping,
40
41
  [(0, _motionRuntimeTestContext.aString)()]: argumentMappingArray
41
42
  };
@@ -1 +1 @@
1
- {"version":3,"names":["describe","simpleTransformation","aNumber","min","max","aString","expect","getArgumentCardinality","toStrictEqual","nonArgumentMapping","anObject","argumentMapping","argumentMappingArray","test","complexMappingTransformation","specialTransformation"],"sources":["../../../src/__tests__/getArgumentCardinality.spec.ts"],"sourcesContent":["import { aNumber, aString, anObject } from '@wix/motion-runtime-test-context';\nimport { getArgumentCardinality } from '..';\n\ndescribe('getArgumentCardinality', () => {\n describe('simple transformation', () => {\n const simpleTransformation = `$[${aNumber({\n min: 0,\n max: 9,\n })}].${aString()}`;\n\n expect(getArgumentCardinality(simpleTransformation)).toStrictEqual(1);\n });\n\n describe('complex transformations', () => {\n const nonArgumentMapping = anObject();\n\n const argumentMapping = {\n [aString()]: '$[0].abc',\n [aString()]: '$[1].id',\n [aString()]: '$[2].a',\n [aString()]: '$[3].a.b.c',\n ...nonArgumentMapping,\n };\n\n const argumentMappingArray = ['$[0].a', '$[1].b', 'a.b.c'];\n\n test('counts the number of arguments referenced in a given transformation object', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n ...argumentMapping,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(4);\n });\n\n test('counts the number of arguments referenced in a transformation object with arrays', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n [aString()]: argumentMappingArray,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(2);\n });\n\n test('counts only unique occurrences', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n ...argumentMapping,\n [aString()]: argumentMappingArray,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(4);\n });\n\n test('does not fail on special transformation cases', () => {\n const specialTransformation = {\n [aString()]: { '@constant': true },\n [aString()]: { '@constant': null },\n [aString()]: '$[0].a.b.c.',\n };\n\n expect(getArgumentCardinality(specialTransformation)).toStrictEqual(1);\n });\n });\n});\n"],"mappings":";;AAAA;;AACA;;AAEAA,QAAQ,CAAC,wBAAD,EAA2B,MAAM;EACvCA,QAAQ,CAAC,uBAAD,EAA0B,MAAM;IACtC,MAAMC,oBAAoB,GAAI,KAAI,IAAAC,iCAAA,EAAQ;MACxCC,GAAG,EAAE,CADmC;MAExCC,GAAG,EAAE;IAFmC,CAAR,CAG/B,KAAI,IAAAC,iCAAA,GAAU,EAHjB;IAKAC,MAAM,CAAC,IAAAC,wBAAA,EAAuBN,oBAAvB,CAAD,CAAN,CAAqDO,aAArD,CAAmE,CAAnE;EACD,CAPO,CAAR;EASAR,QAAQ,CAAC,yBAAD,EAA4B,MAAM;IACxC,MAAMS,kBAAkB,GAAG,IAAAC,kCAAA,GAA3B;IAEA,MAAMC,eAAe,GAAG;MACtB,CAAC,IAAAN,iCAAA,GAAD,GAAa,UADS;MAEtB,CAAC,IAAAA,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AC,wBAAA,EAAuBQ,qBAAvB,CAAD,CAAN,CAAsDP,aAAtD,CAAoE,CAApE;IACD,CARG,CAAJ;EASD,CAxDO,CAAR;AAyDD,CAnEO,CAAR"}
1
+ {"version":3,"names":["_motionRuntimeTestContext","require","_","describe","simpleTransformation","aNumber","min","max","aString","expect","getArgumentCardinality","toStrictEqual","nonArgumentMapping","anObject","argumentMapping","argumentMappingArray","test","complexMappingTransformation","specialTransformation"],"sources":["../../../src/__tests__/getArgumentCardinality.spec.ts"],"sourcesContent":["import { anObject, aNumber, aString } from '@wix/motion-runtime-test-context';\n\nimport { getArgumentCardinality } from '..';\n\ndescribe('getArgumentCardinality', () => {\n describe('simple transformation', () => {\n const simpleTransformation = `$[${aNumber({\n min: 0,\n max: 9,\n })}].${aString()}`;\n\n expect(getArgumentCardinality(simpleTransformation)).toStrictEqual(1);\n });\n\n describe('complex transformations', () => {\n const nonArgumentMapping = anObject();\n\n const argumentMapping = {\n [aString()]: '$[0].abc',\n [aString()]: '$[1].id',\n [aString()]: '$[2].a',\n [aString()]: '$[3].a.b.c',\n ...nonArgumentMapping,\n };\n\n const argumentMappingArray = ['$[0].a', '$[1].b', 'a.b.c'];\n\n test('counts the number of arguments referenced in a given transformation object', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n ...argumentMapping,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(4);\n });\n\n test('counts the number of arguments referenced in a transformation object with arrays', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n [aString()]: argumentMappingArray,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(2);\n });\n\n test('counts only unique occurrences', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n ...argumentMapping,\n [aString()]: argumentMappingArray,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(4);\n });\n\n test('does not fail on special transformation cases', () => {\n const specialTransformation = {\n [aString()]: { '@constant': true },\n [aString()]: { '@constant': null },\n [aString()]: '$[0].a.b.c.',\n };\n\n expect(getArgumentCardinality(specialTransformation)).toStrictEqual(1);\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AAEA,IAAAC,CAAA,GAAAD,OAAA;AAEAE,QAAQ,CAAC,wBAAwB,EAAE,MAAM;EACvCA,QAAQ,CAAC,uBAAuB,EAAE,MAAM;IACtC,MAAMC,oBAAoB,GAAI,KAAI,IAAAC,iCAAO,EAAC;MACxCC,GAAG,EAAE,CAAC;MACNC,GAAG,EAAE;IACP,CAAC,CAAE,KAAI,IAAAC,iCAAO,EAAC,CAAE,EAAC;IAElBC,MAAM,CAAC,IAAAC,wBAAsB,EAACN,oBAAoB,CAAC,CAAC,CAACO,aAAa,CAAC,CAAC,CAAC;EACvE,CAAC,CAAC;EAEFR,QAAQ,CAAC,yBAAyB,EAAE,MAAM;IACxC,MAAMS,kBAAkB,GAAG,IAAAC,kCAAQ,EAAC,CAAC;IAErC,MAAMC,eAAe,GAAG;MACtB,CAAC,IAAAN,iCAAO,EAAC,CAAC,GAAG,UAAU;MACvB,CAAC,IAAAA,iCAAO,EAAC,CAAC,GAAG,SAAS;MACtB,CAAC,IAAAA,iCAAO,EAAC,CAAC,GAAG,QAAQ;MACrB,CAAC,IAAAA,iCAAO,EAAC,CAAC,GAAG,YAAY;MACzB,GAAGI;IACL,CAAC;IAED,MAAMG,oBAAoB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC;IAE1DC,IAAI,CAAC,4EAA4E,EAAE,MAAM;MACvF,MAAMC,4BAA4B,GAAG;QACnC,GAAGL,kBAAkB;QACrB,GAAGE;MACL,CAAC;MAEDL,MAAM,CACJ,IAAAC,wBAAsB,EAACO,4BAA4B,CACrD,CAAC,CAACN,aAAa,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC;IAEFK,IAAI,CAAC,kFAAkF,EAAE,MAAM;MAC7F,MAAMC,4BAA4B,GAAG;QACnC,GAAGL,kBAAkB;QACrB,CAAC,IAAAJ,iCAAO,EAAC,CAAC,GAAGO;MACf,CAAC;MAEDN,MAAM,CACJ,IAAAC,wBAAsB,EAACO,4BAA4B,CACrD,CAAC,CAACN,aAAa,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC;IAEFK,IAAI,CAAC,gCAAgC,EAAE,MAAM;MAC3C,MAAMC,4BAA4B,GAAG;QACnC,GAAGL,kBAAkB;QACrB,GAAGE,eAAe;QAClB,CAAC,IAAAN,iCAAO,EAAC,CAAC,GAAGO;MACf,CAAC;MAEDN,MAAM,CACJ,IAAAC,wBAAsB,EAACO,4BAA4B,CACrD,CAAC,CAACN,aAAa,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC;IAEFK,IAAI,CAAC,+CAA+C,EAAE,MAAM;MAC1D,MAAME,qBAAqB,GAAG;QAC5B,CAAC,IAAAV,iCAAO,EAAC,CAAC,GAAG;UAAE,WAAW,EAAE;QAAK,CAAC;QAClC,CAAC,IAAAA,iCAAO,EAAC,CAAC,GAAG;UAAE,WAAW,EAAE;QAAK,CAAC;QAClC,CAAC,IAAAA,iCAAO,EAAC,CAAC,GAAG;MACf,CAAC;MAEDC,MAAM,CAAC,IAAAC,wBAAsB,EAACQ,qBAAqB,CAAC,CAAC,CAACP,aAAa,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,19 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _motionEdmAutogenTestContext = require("@wix/motion-edm-autogen-test-context");
4
-
5
4
  var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
6
-
7
5
  var _lodash = require("lodash");
8
-
9
6
  var _helpers = require("../lib/helpers");
10
-
11
7
  describe('helper functions', () => {
12
8
  const index = (0, _motionRuntimeTestContext.aNumber)({
13
9
  min: 0,
14
10
  max: 1
15
- }); // @ts-expect-error
16
-
11
+ });
12
+ // @ts-expect-error
17
13
  const nestedPath = (0, _lodash.times)(3, (0, _motionRuntimeTestContext.aString)()).join('.');
18
14
  const simpleTransformation = `$[${index}]`;
19
15
  const simpleTransformationWithNestedPath = `$[${index}].${nestedPath}`;
@@ -1 +1 @@
1
- {"version":3,"names":["describe","index","aNumber","min","max","nestedPath","times","aString","join","simpleTransformation","simpleTransformationWithNestedPath","test","each","aSimpleMappingTransformation","simpleMapping","aComplexMappingTransformation","complexMapping","transformation","expectedValue","expect","isSimpleTransformation","toStrictEqual","extractIndexAndPath","getArgumentIndex","toBeNull","aRandomJsonPath","expression","expectedResult","isJsonPathExpression","nonJsonPathString","jsonPath","aRandomResponseTransformationJsonPath","slice","stripJsonPathRootPrefix","isInvalidJsonValue","toBeTruthy","toBeFalsy"],"sources":["../../../src/__tests__/helpers.spec.ts"],"sourcesContent":["import {\n aSimpleMappingTransformation,\n aComplexMappingTransformation,\n aRandomJsonPath,\n aRandomResponseTransformationJsonPath,\n} from '@wix/motion-edm-autogen-test-context';\nimport { aNumber, aString } from '@wix/motion-runtime-test-context';\nimport { times } from 'lodash';\nimport {\n isSimpleTransformation,\n extractIndexAndPath,\n getArgumentIndex,\n isJsonPathExpression,\n stripJsonPathRootPrefix,\n isInvalidJsonValue,\n} from '../lib/helpers';\n\ndescribe('helper functions', () => {\n const index = aNumber({ min: 0, max: 1 });\n // @ts-expect-error\n const nestedPath = times(3, aString()).join('.');\n const simpleTransformation = `$[${index}]`;\n const simpleTransformationWithNestedPath = `$[${index}].${nestedPath}`;\n\n describe('isSimpleTransformation', () => {\n test.each`\n transformation | expectedValue | transformationType\n ${aSimpleMappingTransformation().simpleMapping} | ${true} | ${'simple'}\n ${aComplexMappingTransformation().complexMapping} | ${false} | ${'complex'}\n `(\n 'returns $expectedValue for $transformationType transformation',\n ({ transformation, expectedValue }) => {\n expect(isSimpleTransformation(transformation)).toStrictEqual(\n expectedValue,\n );\n },\n );\n });\n\n describe('extractIndexAndPath', () => {\n test('extracts the index and nested-path of the argument from a simple tranformation', () => {\n expect(\n extractIndexAndPath(simpleTransformationWithNestedPath),\n ).toStrictEqual({ index, nestedPath });\n });\n\n test('sets the nestedPath to null when one could not be found', () => {\n expect(extractIndexAndPath(simpleTransformation)).toStrictEqual({\n index,\n nestedPath: null,\n });\n });\n });\n\n describe('getArgumentIndex', () => {\n test('extracts the index of an argument within a jsonpath', () => {\n expect(getArgumentIndex(simpleTransformation)).toStrictEqual(index);\n });\n\n test('return null when no index was found', () => {\n expect(getArgumentIndex(aString())).toBeNull();\n });\n });\n\n describe('isJsonPathExpression', () => {\n test.each`\n description | expression | expectedResult\n ${'starts with $'} | ${aRandomJsonPath()} | ${true}\n ${'does not start with $'} | ${aString()} | ${false}\n `(\n 'return $expectedResult when the expression $description',\n ({ expression, expectedResult }) => {\n expect(isJsonPathExpression(expression)).toStrictEqual(expectedResult);\n },\n );\n });\n\n describe('stripJsonPathRootPrefix', () => {\n const nonJsonPathString = aString();\n const jsonPath = aRandomResponseTransformationJsonPath();\n\n test.each`\n description | expression | expectedResult\n ${'is $'} | ${'$'} | ${'$'}\n ${'does not start with $'} | ${nonJsonPathString} | ${nonJsonPathString}\n ${'starts with $.'} | ${jsonPath} | ${jsonPath.slice(2)}\n `(\n 'return $expectedResult when the expression $description',\n ({ expression, expectedResult }) => {\n expect(stripJsonPathRootPrefix(expression)).toStrictEqual(\n expectedResult,\n );\n },\n );\n });\n\n describe('isInvalidJsonValue', () => {\n test('returns true for an invalid json-value', () => {\n expect(isInvalidJsonValue('x-y-z')).toBeTruthy();\n });\n\n test('returns false for a valid json-value', () => {\n expect(isInvalidJsonValue('\"string\"')).toBeFalsy();\n });\n });\n});\n"],"mappings":";;AAAA;;AAMA;;AACA;;AACA;;AASAA,QAAQ,CAAC,kBAAD,EAAqB,MAAM;EACjC,MAAMC,KAAK,GAAG,IAAAC,iCAAA,EAAQ;IAAEC,GAAG,EAAE,CAAP;IAAUC,GAAG,EAAE;EAAf,CAAR,CAAd,CADiC,CAEjC;;EACA,MAAMC,UAAU,G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AN,CAAoCC,UAApC;IACD,CAFG,CAAJ;IAIAxB,IAAI,CAAC,sCAAD,EAAyC,MAAM;MACjDQ,MAAM,CAAC,IAAAe,2BAAA,EAAmB,UAAnB,CAAD,CAAN,CAAuCE,SAAvC;IACD,CAFG,CAAJ;EAGD,CARO,CAAR;AASD,CAxFO,CAAR"}
1
+ {"version":3,"names":["_motionEdmAutogenTestContext","require","_motionRuntimeTestContext","_lodash","_helpers","describe","index","aNumber","min","max","nestedPath","times","aString","join","simpleTransformation","simpleTransformationWithNestedPath","test","each","aSimpleMappingTransformation","simpleMapping","aComplexMappingTransformation","complexMapping","transformation","expectedValue","expect","isSimpleTransformation","toStrictEqual","extractIndexAndPath","getArgumentIndex","toBeNull","aRandomJsonPath","expression","expectedResult","isJsonPathExpression","nonJsonPathString","jsonPath","aRandomResponseTransformationJsonPath","slice","stripJsonPathRootPrefix","isInvalidJsonValue","toBeTruthy","toBeFalsy"],"sources":["../../../src/__tests__/helpers.spec.ts"],"sourcesContent":["import {\n aComplexMappingTransformation,\n aRandomJsonPath,\n aRandomResponseTransformationJsonPath,\n aSimpleMappingTransformation,\n} from '@wix/motion-edm-autogen-test-context';\nimport { aNumber, aString } from '@wix/motion-runtime-test-context';\nimport { times } from 'lodash';\n\nimport {\n extractIndexAndPath,\n getArgumentIndex,\n isInvalidJsonValue,\n isJsonPathExpression,\n isSimpleTransformation,\n stripJsonPathRootPrefix,\n} from '../lib/helpers';\n\ndescribe('helper functions', () => {\n const index = aNumber({ min: 0, max: 1 });\n // @ts-expect-error\n const nestedPath = times(3, aString()).join('.');\n const simpleTransformation = `$[${index}]`;\n const simpleTransformationWithNestedPath = `$[${index}].${nestedPath}`;\n\n describe('isSimpleTransformation', () => {\n test.each`\n transformation | expectedValue | transformationType\n ${aSimpleMappingTransformation().simpleMapping} | ${true} | ${'simple'}\n ${aComplexMappingTransformation().complexMapping} | ${false} | ${'complex'}\n `(\n 'returns $expectedValue for $transformationType transformation',\n ({ transformation, expectedValue }) => {\n expect(isSimpleTransformation(transformation)).toStrictEqual(\n expectedValue,\n );\n },\n );\n });\n\n describe('extractIndexAndPath', () => {\n test('extracts the index and nested-path of the argument from a simple tranformation', () => {\n expect(\n extractIndexAndPath(simpleTransformationWithNestedPath),\n ).toStrictEqual({ index, nestedPath });\n });\n\n test('sets the nestedPath to null when one could not be found', () => {\n expect(extractIndexAndPath(simpleTransformation)).toStrictEqual({\n index,\n nestedPath: null,\n });\n });\n });\n\n describe('getArgumentIndex', () => {\n test('extracts the index of an argument within a jsonpath', () => {\n expect(getArgumentIndex(simpleTransformation)).toStrictEqual(index);\n });\n\n test('return null when no index was found', () => {\n expect(getArgumentIndex(aString())).toBeNull();\n });\n });\n\n describe('isJsonPathExpression', () => {\n test.each`\n description | expression | expectedResult\n ${'starts with $'} | ${aRandomJsonPath()} | ${true}\n ${'does not start with $'} | ${aString()} | ${false}\n `(\n 'return $expectedResult when the expression $description',\n ({ expression, expectedResult }) => {\n expect(isJsonPathExpression(expression)).toStrictEqual(expectedResult);\n },\n );\n });\n\n describe('stripJsonPathRootPrefix', () => {\n const nonJsonPathString = aString();\n const jsonPath = aRandomResponseTransformationJsonPath();\n\n test.each`\n description | expression | expectedResult\n ${'is $'} | ${'$'} | ${'$'}\n ${'does not start with $'} | ${nonJsonPathString} | ${nonJsonPathString}\n ${'starts with $.'} | ${jsonPath} | ${jsonPath.slice(2)}\n `(\n 'return $expectedResult when the expression $description',\n ({ expression, expectedResult }) => {\n expect(stripJsonPathRootPrefix(expression)).toStrictEqual(\n expectedResult,\n );\n },\n );\n });\n\n describe('isInvalidJsonValue', () => {\n test('returns true for an invalid json-value', () => {\n expect(isInvalidJsonValue('x-y-z')).toBeTruthy();\n });\n\n test('returns false for a valid json-value', () => {\n expect(isInvalidJsonValue('\"string\"')).toBeFalsy();\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,4BAAA,GAAAC,OAAA;AAMA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAA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EN,UAAU;MAAEC;IAAe,CAAC,KAAK;MAClCR,MAAM,CAAC,IAAAc,gCAAuB,EAACP,UAAU,CAAC,CAAC,CAACL,aAAa,CACvDM,cACF,CAAC;IACH,CACF,CAAC;EACH,CAAC,CAAC;EAEF3B,QAAQ,CAAC,oBAAoB,EAAE,MAAM;IACnCW,IAAI,CAAC,wCAAwC,EAAE,MAAM;MACnDQ,MAAM,CAAC,IAAAe,2BAAkB,EAAC,OAAO,CAAC,CAAC,CAACC,UAAU,CAAC,CAAC;IAClD,CAAC,CAAC;IAEFxB,IAAI,CAAC,sCAAsC,EAAE,MAAM;MACjDQ,MAAM,CAAC,IAAAe,2BAAkB,EAAC,UAAU,CAAC,CAAC,CAACE,SAAS,CAAC,CAAC;IACpD,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
4
-
5
4
  var _lodash = require("lodash");
6
-
7
5
  var _reduceTransformation = require("../lib/transformations/reduceTransformation");
8
-
9
6
  describe('reduceTransformation', () => {
10
7
  describe('simple transformations', () => {
11
8
  const visitorCallbackResult = (0, _motionRuntimeTestContext.aString)();
@@ -46,8 +43,9 @@ describe('reduceTransformation', () => {
46
43
  expect(visitorCallback).toHaveBeenCalledWith(null, null, transformationWithInvalidCustomFunctionExpression);
47
44
  expect(result).toStrictEqual(visitorCallbackResult);
48
45
  });
49
- }); // TODO: replace with returning the invalid value, for constant-transformation
46
+ });
50
47
 
48
+ // TODO: replace with returning the invalid value, for constant-transformation
51
49
  test('invokes the TopLevelUnsupportedTransformationExpression otherwise', () => {
52
50
  const visitorCallback = jest.fn().mockReturnValueOnce(visitorCallbackResult);
53
51
  const transformation = (0, _motionRuntimeTestContext.aString)();
@@ -86,9 +84,8 @@ describe('reduceTransformation', () => {
86
84
  });
87
85
  describe('spread operator', () => {
88
86
  const _times = (0, _lodash.times)(2, () => jest.fn()),
89
- topLevelSpreadOperatorCallback = _times[0],
90
- nestedSpreadOperatorCallback = _times[1];
91
-
87
+ topLevelSpreadOperatorCallback = _times[0],
88
+ nestedSpreadOperatorCallback = _times[1];
92
89
  const argumentExpression = '$[1].d.e.f';
93
90
  const sibling = (0, _motionRuntimeTestContext.anObject)();
94
91
  const siblingKeys = Object.keys(sibling);
@@ -114,8 +111,11 @@ describe('reduceTransformation', () => {
114
111
  }
115
112
  });
116
113
  expect(topLevelSpreadOperatorCallback).toHaveBeenCalledTimes(1);
117
- expect(topLevelSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, omitExpression, siblingKeys); // expect(nestedOmitCallback).toHaveBeenCalled();
114
+ expect(topLevelSpreadOperatorCallback).toHaveBeenCalledWith(accumulator, omitExpression, siblingKeys);
115
+
116
+ // expect(nestedOmitCallback).toHaveBeenCalled();
118
117
  });
118
+
119
119
  test('traverses top-level spread-operator transformation nodes', () => {
120
120
  const transformation = {
121
121
  '*': argumentExpression,
@@ -288,8 +288,9 @@ describe('reduceTransformation', () => {
288
288
  expect(result).toStrictEqual({
289
289
  count: 1
290
290
  });
291
- }); // TODO: replace with returning the invalid value, for constant-transformation
291
+ });
292
292
 
293
+ // TODO: replace with returning the invalid value, for constant-transformation
293
294
  test('invokes the NestedUnsupportedTransformationExpression otherwise', () => {
294
295
  const visitorCallback = jest.fn();
295
296
  const unsupportedTransformationValue = (0, _motionRuntimeTestContext.aString)();
@@ -334,12 +335,10 @@ describe('reduceTransformation', () => {
334
335
  describe('nested transformation', () => {
335
336
  const accumulator = {};
336
337
  const path = 'a.b.c';
337
-
338
338
  const withItemTransformation = itemTransformation => (0, _lodash.set)({}, path, {
339
339
  '@path': '$.d.e.f',
340
340
  '@itemTransformation': itemTransformation
341
341
  });
342
-
343
342
  describe('simple item-transformation', () => {
344
343
  test('invokes the MapArrayItems visitor', () => {
345
344
  (0, _reduceTransformation.reduceTransformation)(withItemTransformation('$.g.h.i'), {
@@ -1 +1 @@
1
- {"version":3,"names":["describe","visitorCallbackResult","aString","test","visitorCallback","jest","fn","mockReturnValueOnce","transformation","result","reduceTransformation","visitors","TopLevelSimpleTransformationExpression","expect","toHaveBeenCalledTimes","toHaveBeenCalledWith","toStrictEqual","TopLevelCustomFunctionExpression","transformationWithInvalidCustomFunctionExpression","TopLevelUnsupportedTransformationExpression","accumulator","anObject","a","b","c","d","e","NestedSimpleTransformationExpression","times","topLevelSpreadOperatorCallback","nestedSpreadOperatorCallback","argumentExpression","sibling","siblingKeys","Object","keys","path","beforeEach","forEach","mock","mockClear","nestedOmitCallback","omitExpression","TopLevelSpreadExpression","NestedOmit","NestedSpreadExpression","not","toHaveBeenCalled","set","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"],"sources":["../../../src/__tests__/reduceTransformation.spec.ts"],"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"],"mappings":";;AAAA;;AACA;;AACA;;AAEAA,QAAQ,CAAC,sBAAD,EAAyB,MAAM;EACrCA,QAAQ,CA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AArB,EAAqC;UACnCG,QAAQ,EAAE;YACR,CAACiE,WAAD,GAAexE;UADP;QADyB,CAArC,CADI,CAAN,CAME6E,OANF,CAMUH,KANV;MAOD,CAdG,CAAJ;MAgBA3E,IAAI,CAAE,0BAAyByE,WAAY,qBAAvC,EAA6D,MAAM;QACrE/D,MAAM,CAAC,MACL,IAAAH,0CAAA,EAAqBF,cAArB,EAAqC;UACnCG,QAAQ,EAAE;YACR,CAACiE,WAAD,GAAe;UADP;QADyB,CAArC,CADI,CAAN,CAME9B,GANF,CAMMmC,OANN;MAOD,CARG,CAAJ;IASD,CAnCD;EAoCD,CArCO,CAAR;AAsCD,CA1lBO,CAAR"}
1
+ {"version":3,"names":["_motionRuntimeTestContext","require","_lodash","_reduceTransformation","describe","visitorCallbackResult","aString","test","visitorCallback","jest","fn","mockReturnValueOnce","transformation","result","reduceTransformation","visitors","TopLevelSimpleTransformationExpression","expect","toHaveBeenCalledTimes","toHaveBeenCalledWith","toStrictEqual","TopLevelCustomFunctionExpression","transformationWithInvalidCustomFunctionExpression","TopLevelUnsupportedTransformationExpression","accumulator","anObject","a","b","c","d","e","NestedSimpleTransformationExpression","_times","times","topLevelSpreadOperatorCallback","nestedSpreadOperatorCallback","argumentExpression","sibling","siblingKeys","Object","keys","path","beforeEach","forEach","mock","mockClear","nestedOmitCallback","omitExpression","TopLevelSpreadExpression","NestedOmit","NestedSpreadExpression","not","toHaveBeenCalled","set","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"],"sources":["../../../src/__tests__/reduceTransformation.spec.ts"],"sourcesContent":["import { anObject, aString } from '@wix/motion-runtime-test-context';\nimport { set, times } from 'lodash';\n\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"],"mappings":";;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,qBAAA,GAAAF,OAAA;AAEAG,QAAQ,CAAC,sBAAsB,EAAE,MAAM;EACrCA,QAAQ,CAAC,wBAAwB,EAAE,MAAM;IACvC,MAAMC,qBAAqB,GAAG,IAAAC,iCAAO,EAAC,CAAC;IAEvCC,IAAI,CAAC,mCAAmC,EAAE,MAAM;MAC9C,MAAMC,eAAe,GAAGC,IAAI,CACzBC,EAAE,CAAC,CAAC,CACJC,mBAAmB,CAACN,qBAAqB,CAAC;MAC7C,MAAMO,cAAc,GAAG,SAAS;MAEhC,MAAMC,MAAM,GAAG,IAAAC,0CAAoB,EAACF,cAAc,EAAE;QAClDG,QAAQ,EAAE;UACRC,sCAAsC,EAAER;QAC1C;MACF,CAAC,CAAC;MAEFS,MAAM,CAACT,eAAe,CAAC,CAACU,qBAAqB,CAAC,CAAC,CAAC;MAChDD,MAAM,CAACT,eAAe,CAAC,CAACW,oBAAoB,CAAC,SAAS,CAAC;MACvDF,MAAM,CAACJ,MAAM,CAAC,CAACO,aAAa,CAACf,qBAAqB,CAAC;IACrD,CAAC,CAAC;IAEFD,QAAQ,CAAC,kBAAkB,EAAE,MAAM;MACjCG,IAAI,CAAC,8CAA8C,EAAE,MAAM;QACzD,MAAMC,eAAe,GAA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;MAClB,CAAC,CAAC;MAEF5E,IAAI,CAAE,0BAAyB0E,WAAY,qBAAoB,EAAE,MAAM;QACrEhE,MAAM,CAAC,MACL,IAAAH,0CAAoB,EAACF,cAAc,EAAE;UACnCG,QAAQ,EAAE;YACR,CAACkE,WAAW,GAAG;UACjB;QACF,CAAC,CACH,CAAC,CAAC9B,GAAG,CAACmC,OAAO,CAAC,CAAC;MACjB,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
4
-
5
4
  var _lodash = require("lodash");
6
-
7
5
  var _ = require("../..");
8
-
9
6
  var _customFunctions = require("../../lib/transformations/custom-functions");
10
-
11
7
  describe('parseCustomFunctionCall', () => {
12
8
  /* eslint-disable max-len */
13
9
  test.each`
@@ -16,8 +12,7 @@ describe('parseCustomFunctionCall', () => {
16
12
  ${'multiple arguments'} | ${'$[0].some.path,someString'} | ${['$[0].some.path', 'someString']}
17
13
  ${'multiple arguments with whitespaces'} | ${'$[0].some.path, someString , $[1]'} | ${['$[0].some.path', 'someString', '$[1]']}
18
14
  ${'no arguments'} | ${''} | ${[]}
19
- `(
20
- /* eslint-enable max-len */
15
+ `( /* eslint-enable max-len */
21
16
  'parses a custom-function call applied with $argumentCount', ({
22
17
  argumentExpressions,
23
18
  expectedArgumentExpressions
@@ -46,9 +41,7 @@ describe('isFunctionCallExpression', () => {
46
41
  describe('runCustomFunctionCallExpression', () => {
47
42
  const value = (0, _motionRuntimeTestContext.aString)();
48
43
  const transformationParentPath = (0, _motionRuntimeTestContext.aString)();
49
-
50
44
  const joinWithDots = (...args) => args.join('|');
51
-
52
45
  describe.each`
53
46
  argumentCount | argumentValues | expectedResult
54
47
  ${'single'} | ${[value]} | ${value}
@@ -95,14 +88,12 @@ describe('runCustomFunctionCallExpression', () => {
95
88
  throw new Error('Something went wrong in the custom function');
96
89
  }
97
90
  };
98
-
99
91
  const t = () => (0, _customFunctions.runCustomFunctionCallExpression)({
100
92
  functionName,
101
93
  customFunctions,
102
94
  argumentValues,
103
95
  transformationParentPath
104
96
  });
105
-
106
97
  expect(t).toThrow(Error);
107
98
  expect(t).toThrow(new RegExp(`Transforming ${transformationParentPath} failed, #${functionName} threw: "Something went wrong in the custom function" for arguments: .+`));
108
99
  });
@@ -1 +1 @@
1
- {"version":3,"names":["describe","test","each","argumentExpressions","expectedArgumentExpressions","functionName","aString","functionExpression","expect","parseCustomFunctionCall","toStrictEqual","expression","expectedResult","isFunctionCallExpression","value","transformationParentPath","joinWithDots","args","join","argumentValues","customFunctions","set","result","runCustomFunctionCallExpression","times","toThrow","Error","t","RegExp"],"sources":["../../../../src/__tests__/transformations/custom-functions.spec.ts"],"sourcesContent":["import { aString } from '@wix/motion-runtime-test-context';\nimport { set, times } from 'lodash';\nimport { parseCustomFunctionCall, isFunctionCallExpression } from '../..';\nimport { runCustomFunctionCallExpression } from '../../lib/transformations/custom-functions';\n\ndescribe('parseCustomFunctionCall', () => {\n /* eslint-disable max-len */\n test.each`\n argumentCount | argumentExpressions | expectedArgumentExpressions\n ${'a single argument'} | ${'$[0].some.path'} | ${['$[0].some.path']}\n ${'multiple arguments'} | ${'$[0].some.path,someString'} | ${['$[0].some.path', 'someString']}\n ${'multiple arguments with whitespaces'} | ${'$[0].some.path, someString , $[1]'} | ${['$[0].some.path', 'someString', '$[1]']}\n ${'no arguments'} | ${''} | ${[]}\n `(\n /* eslint-enable max-len */\n 'parses a custom-function call applied with $argumentCount',\n ({ argumentExpressions, expectedArgumentExpressions }) => {\n const functionName = aString();\n const functionExpression = `#${functionName}(${argumentExpressions})`;\n\n expect(parseCustomFunctionCall(functionExpression)).toStrictEqual({\n functionName,\n argumentExpressions: expectedArgumentExpressions,\n });\n },\n );\n});\n\ndescribe('isFunctionCallExpression', () => {\n test.each`\n description | expression | expectedResult\n ${'a #-prefixed with a valid function name'} | ${'#someInvalidName$#@#>'} | ${true}\n ${'a non-# prefixed with a valid function name'} | ${'someFunctions($[1])'} | ${false}\n ${'a non-string value'} | ${[1, 2, 3]} | ${false}\n `(\n 'returns $expectedResult when $description function call expression is provided',\n ({ expression, expectedResult }) => {\n expect(isFunctionCallExpression(expression)).toStrictEqual(\n expectedResult,\n );\n },\n );\n});\n\ndescribe('runCustomFunctionCallExpression', () => {\n const value = aString();\n const transformationParentPath = aString();\n const joinWithDots = (...args) => args.join('|');\n\n describe.each`\n argumentCount | argumentValues | expectedResult\n ${'single'} | ${[value]} | ${value}\n ${'multi'} | ${[value, value]} | ${`${value}|${value}`}\n ${'no'} | ${[]} | ${''}\n `(\n '$argumentCount-argument expression',\n ({ argumentValues, expectedResult }) => {\n describe.each`\n functionName | description\n ${'someFunction'} | ${'an unscoped'}\n ${'someScope.someFunction'} | ${'a scoped'}\n `('$description custom function', ({ functionName }) => {\n const customFunctions = set({}, functionName, joinWithDots);\n\n test('runs it and returns its result', () => {\n const result = runCustomFunctionCallExpression({\n functionName,\n customFunctions,\n argumentValues,\n transformationParentPath,\n });\n\n expect(result).toStrictEqual(expectedResult);\n });\n });\n },\n );\n\n describe('error handling', () => {\n const argumentValues = times(2, () => aString());\n\n test('throws when the function is not recognized', () => {\n const customFunctions = {};\n\n expect(() =>\n runCustomFunctionCallExpression({\n functionName: 'someNonexistentFunction',\n customFunctions,\n argumentValues,\n transformationParentPath,\n }),\n ).toThrow(`unrecognized custom function \"someNonexistentFunction\"`);\n });\n\n test('throws an error when the function call throws an error', () => {\n const functionName = aString();\n\n const customFunctions = {\n [functionName]: () => {\n throw new Error('Something went wrong in the custom function');\n },\n };\n\n const t = () =>\n runCustomFunctionCallExpression({\n functionName,\n customFunctions,\n argumentValues,\n transformationParentPath,\n });\n\n expect(t).toThrow(Error);\n expect(t).toThrow(\n new RegExp(\n `Transforming ${transformationParentPath} failed, #${functionName} threw: \"Something went wrong in the custom function\" for arguments: .+`,\n ),\n );\n });\n });\n});\n"],"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G,EAAxB;MAEAZ,MAAM,CAAC,MACL,IAAAe,gDAAA,EAAgC;QAC9BlB,YAAY,EAAE,yBADgB;QAE9Be,eAF8B;QAG9BD,cAH8B;QAI9BJ;MAJ8B,CAAhC,CADI,CAAN,CAOEU,OAPF,CAOW,wDAPX;IAQD,CAXG,CAAJ;IAaAxB,IAAI,CAAC,wDAAD,EAA2D,MAAM;MACnE,MAAMI,YAAY,GAAG,IAAAC,iCAAA,GAArB;MAEA,MAAMc,eAAe,GAAG;QACtB,CAACf,YAAD,GAAgB,MAAM;UACpB,MAAM,IAAIqB,KAAJ,CAAU,6CAAV,CAAN;QACD;MAHqB,CAAxB;;MAMA,MAAMC,CAAC,GAAG,MACR,IAAAJ,gDAAA,EAAgC;QAC9BlB,YAD8B;QAE9Be,eAF8B;QAG9BD,cAH8B;QAI9BJ;MAJ8B,CAAhC,CADF;;MAQAP,MAAM,CAACmB,CAAD,CAAN,CAAUF,OAAV,CAAkBC,KAAlB;MACAlB,MAAM,CAACmB,CAAD,CAAN,CAAUF,OAAV,CACE,IAAIG,MAAJ,CACG,gBAAeb,wBAAyB,aAAYV,YAAa,yEADpE,CADF;IAKD,CAvBG,CAAJ;EAwBD,CAxCO,CAAR;AAyCD,CA3EO,CAAR"}
1
+ {"version":3,"names":["_motionRuntimeTestContext","require","_lodash","_","_customFunctions","describe","test","each","argumentExpressions","expectedArgumentExpressions","functionName","aString","functionExpression","expect","parseCustomFunctionCall","toStrictEqual","expression","expectedResult","isFunctionCallExpression","value","transformationParentPath","joinWithDots","args","join","argumentValues","customFunctions","set","result","runCustomFunctionCallExpression","times","toThrow","Error","t","RegExp"],"sources":["../../../../src/__tests__/transformations/custom-functions.spec.ts"],"sourcesContent":["import { aString } from '@wix/motion-runtime-test-context';\nimport { set, times } from 'lodash';\n\nimport { isFunctionCallExpression, parseCustomFunctionCall } from '../..';\nimport { runCustomFunctionCallExpression } from '../../lib/transformations/custom-functions';\n\ndescribe('parseCustomFunctionCall', () => {\n /* eslint-disable max-len */\n test.each`\n argumentCount | argumentExpressions | expectedArgumentExpressions\n ${'a single argument'} | ${'$[0].some.path'} | ${['$[0].some.path']}\n ${'multiple arguments'} | ${'$[0].some.path,someString'} | ${['$[0].some.path', 'someString']}\n ${'multiple arguments with whitespaces'} | ${'$[0].some.path, someString , $[1]'} | ${['$[0].some.path', 'someString', '$[1]']}\n ${'no arguments'} | ${''} | ${[]}\n `(\n /* eslint-enable max-len */\n 'parses a custom-function call applied with $argumentCount',\n ({ argumentExpressions, expectedArgumentExpressions }) => {\n const functionName = aString();\n const functionExpression = `#${functionName}(${argumentExpressions})`;\n\n expect(parseCustomFunctionCall(functionExpression)).toStrictEqual({\n functionName,\n argumentExpressions: expectedArgumentExpressions,\n });\n },\n );\n});\n\ndescribe('isFunctionCallExpression', () => {\n test.each`\n description | expression | expectedResult\n ${'a #-prefixed with a valid function name'} | ${'#someInvalidName$#@#>'} | ${true}\n ${'a non-# prefixed with a valid function name'} | ${'someFunctions($[1])'} | ${false}\n ${'a non-string value'} | ${[1, 2, 3]} | ${false}\n `(\n 'returns $expectedResult when $description function call expression is provided',\n ({ expression, expectedResult }) => {\n expect(isFunctionCallExpression(expression)).toStrictEqual(\n expectedResult,\n );\n },\n );\n});\n\ndescribe('runCustomFunctionCallExpression', () => {\n const value = aString();\n const transformationParentPath = aString();\n const joinWithDots = (...args) => args.join('|');\n\n describe.each`\n argumentCount | argumentValues | expectedResult\n ${'single'} | ${[value]} | ${value}\n ${'multi'} | ${[value, value]} | ${`${value}|${value}`}\n ${'no'} | ${[]} | ${''}\n `(\n '$argumentCount-argument expression',\n ({ argumentValues, expectedResult }) => {\n describe.each`\n functionName | description\n ${'someFunction'} | ${'an unscoped'}\n ${'someScope.someFunction'} | ${'a scoped'}\n `('$description custom function', ({ functionName }) => {\n const customFunctions = set({}, functionName, joinWithDots);\n\n test('runs it and returns its result', () => {\n const result = runCustomFunctionCallExpression({\n functionName,\n customFunctions,\n argumentValues,\n transformationParentPath,\n });\n\n expect(result).toStrictEqual(expectedResult);\n });\n });\n },\n );\n\n describe('error handling', () => {\n const argumentValues = times(2, () => aString());\n\n test('throws when the function is not recognized', () => {\n const customFunctions = {};\n\n expect(() =>\n runCustomFunctionCallExpression({\n functionName: 'someNonexistentFunction',\n customFunctions,\n argumentValues,\n transformationParentPath,\n }),\n ).toThrow(`unrecognized custom function \"someNonexistentFunction\"`);\n });\n\n test('throws an error when the function call throws an error', () => {\n const functionName = aString();\n\n const customFunctions = {\n [functionName]: () => {\n throw new Error('Something went wrong in the custom function');\n },\n };\n\n const t = () =>\n runCustomFunctionCallExpression({\n functionName,\n customFunctions,\n argumentValues,\n transformationParentPath,\n });\n\n expect(t).toThrow(Error);\n expect(t).toThrow(\n new RegExp(\n `Transforming ${transformationParentPath} failed, #${functionName} threw: \"Something went wrong in the custom function\" for arguments: .+`,\n ),\n );\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,CAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEAI,QAAQ,CAAC,yBAAyB,EAAE,MAAM;EACxC;EACAC,IAAI,CAACC,IAAK;AACZ;AACA,MAAM,mBAAoB,wBAAuB,gBAAiB,2BAA0B,CAAC,gBAAgB,CAAE;AAC/G,MAAM,oBAAqB,uBAAsB,2BAA4B,gBAAe,CAAC,gBAAgB,EAAE,YAAY,CAAE;AAC7H,MAAM,qCAAsC,MAAK,qCAAsC,MAAK,CAAC,gBAAgB,EAAE,YAAY,EAAE,MAAM,CAAE;AACrI,MAAM,cAAe,6BAA4B,EAAG,yCAAwC,EAAG;AAC/F,GAAG,EACC;EACA,2DAA2D,EAC3D,CAAC;IAAEC,mBAAmB;IAAEC;EAA4B,CAAC,KAAK;IACxD,MAAMC,YAAY,GAAG,IAAAC,iCAAO,EAAC,CAAC;IAC9B,MAAMC,kBAAkB,GAAI,IAAGF,YAAa,IAAGF,mBA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AC,CAACF,OAAO,CAACC,KAAK,CAAC;MACxBlB,MAAM,CAACmB,CAAC,CAAC,CAACF,OAAO,CACf,IAAIG,MAAM,CACP,gBAAeb,wBAAyB,aAAYV,YAAa,yEACpE,CACF,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
4
-
5
4
  var _lodash = require("lodash");
6
-
7
5
  var _ = require("../../..");
8
-
9
6
  const _preset$create = _.preset.create,
10
- buildRequestTransformation = _preset$create.buildRequestTransformation,
11
- buildResponseTransformation = _preset$create.buildResponseTransformation;
7
+ buildRequestTransformation = _preset$create.buildRequestTransformation,
8
+ buildResponseTransformation = _preset$create.buildResponseTransformation;
12
9
  describe('create-method transformations', () => {
13
10
  describe('buildRequestTransformation', () => {
14
11
  test('creates a transformation that maps the first argument into requestMessageEntityPath', () => {
@@ -1 +1 @@
1
- {"version":3,"names":["preset","create","buildRequestTransformation","buildResponseTransformation","describe","test","requestMessageEntityPath","aString","tranformationObject","expect","toStrictEqual","entityPathSegments","times","join","responseMessageResultPath","tranformationString"],"sources":["../../../../../src/__tests__/transformations/preset/create-transformation.spec.ts"],"sourcesContent":["import { aString } from '@wix/motion-runtime-test-context';\nimport { times } from 'lodash';\nimport { preset } from '../../..';\n\nconst {\n create: { buildRequestTransformation, buildResponseTransformation },\n} = preset;\n\ndescribe('create-method transformations', () => {\n describe('buildRequestTransformation', () => {\n test('creates a transformation that maps the first argument into requestMessageEntityPath', () => {\n const requestMessageEntityPath = aString();\n\n const tranformationObject = buildRequestTransformation({\n requestMessageEntityPath,\n });\n\n expect(tranformationObject).toStrictEqual({\n [requestMessageEntityPath]: '$[0]',\n });\n });\n\n test('supports nested paths', () => {\n // @ts-expect-error\n const entityPathSegments = times(2, aString);\n const requestMessageEntityPath = entityPathSegments.join('.');\n\n const tranformationObject = buildRequestTransformation({\n requestMessageEntityPath,\n });\n\n expect(tranformationObject).toStrictEqual({\n [entityPathSegments[0]]: { [entityPathSegments[1]]: '$[0]' },\n });\n });\n });\n\n describe('buildResponseTransformation', () => {\n test('unwraps the value of the provided property-path', () => {\n const responseMessageResultPath = aString();\n\n const tranformationString = buildResponseTransformation({\n responseMessageResultPath,\n });\n\n expect(tranformationString).toStrictEqual(\n `$.${responseMessageResultPath}`,\n );\n });\n });\n});\n"],"mappings":";;AAAA;;AACA;;AACA;;AAEA,uBAEIA,QAFJ,CACEC,MADF;AAAA,MACYC,0BADZ,kBACYA,0BADZ;AAAA,MACwCC,2BADxC,kBACwCA,2BADxC;AAIAC,QAAQ,CAAC,+BAAD,EAAkC,MAAM;EAC9CA,QAAQ,CAAC,4BAAD,EAA+B,MAAM;IAC3CC,IAAI,CAAC,qFAAD,EAAwF,MAAM;MAChG,MAAMC,wBAAwB,GAAG,IAAAC,iCAAA,GAAjC;MAEA,MAAMC,mBAAmB,GAAGN,0BAA0B,CAAC;QACrDI;MADqD,CAAD,CAAtD;MAIAG,MAAM,CAACD,mBAAD,CAAN,CAA4BE,aAA5B,CAA0C;QACxC,CAACJ,wBAAD,GAA4B;MADY,CAA1C;IAGD,CAVG,CAAJ;IAYAD,IAAI,CAAC,uBAAD,EAA0B,MAAM;MAClC;MACA,MAAMM,kBAAkB,GAAG,IAAAC,aAAA,EAAM,CAAN,EAASL,iCAAT,CAA3B;MACA,MAAMD,wBAAwB,GAAGK,kBAAkB,CAACE,IAAnB,CAAwB,GAAxB,CAAjC;MAEA,MAAML,mBAAmB,GAAGN,0BAA0B,CAAC;QACrDI;MADqD,CAAD,CAAtD;MAIAG,MAAM,CAACD,mBAAD,CAAN,CAA4BE,aAA5B,CAA0C;QACxC,CAACC,kBAAkB,CAAC,CAAD,CAAnB,GAAyB;UAAE,CAACA,kBAAkB,CAAC,CAAD,CAAnB,GAAyB;QAA3B;MADe,CAA1C;IAGD,CAZG,CAAJ;EAaD,CA1BO,CAAR;EA4BAP,QAAQ,CAAC,6BAAD,EAAgC,MAAM;IAC5CC,IAAI,CAAC,iDAAD,EAAoD,MAAM;MAC5D,MAAMS,yBAAyB,GAAG,IAAAP,iCAAA,GAAlC;MAEA,MAAMQ,mBAAmB,GAAGZ,2BAA2B,CAAC;QACtDW;MADsD,CAAD,CAAvD;MAIAL,MAAM,CAACM,mBAAD,CAAN,CAA4BL,aAA5B,CACG,KAAII,yBAA0B,EADjC;IAGD,CAVG,CAAJ;EAWD,CAZO,CAAR;AAaD,CA1CO,CAAR"}
1
+ {"version":3,"names":["_motionRuntimeTestContext","require","_lodash","_","_preset$create","preset","create","buildRequestTransformation","buildResponseTransformation","describe","test","requestMessageEntityPath","aString","tranformationObject","expect","toStrictEqual","entityPathSegments","times","join","responseMessageResultPath","tranformationString"],"sources":["../../../../../src/__tests__/transformations/preset/create-transformation.spec.ts"],"sourcesContent":["import { aString } from '@wix/motion-runtime-test-context';\nimport { times } from 'lodash';\n\nimport { preset } from '../../..';\n\nconst {\n create: { buildRequestTransformation, buildResponseTransformation },\n} = preset;\n\ndescribe('create-method transformations', () => {\n describe('buildRequestTransformation', () => {\n test('creates a transformation that maps the first argument into requestMessageEntityPath', () => {\n const requestMessageEntityPath = aString();\n\n const tranformationObject = buildRequestTransformation({\n requestMessageEntityPath,\n });\n\n expect(tranformationObject).toStrictEqual({\n [requestMessageEntityPath]: '$[0]',\n });\n });\n\n test('supports nested paths', () => {\n // @ts-expect-error\n const entityPathSegments = times(2, aString);\n const requestMessageEntityPath = entityPathSegments.join('.');\n\n const tranformationObject = buildRequestTransformation({\n requestMessageEntityPath,\n });\n\n expect(tranformationObject).toStrictEqual({\n [entityPathSegments[0]]: { [entityPathSegments[1]]: '$[0]' },\n });\n });\n });\n\n describe('buildResponseTransformation', () => {\n test('unwraps the value of the provided property-path', () => {\n const responseMessageResultPath = aString();\n\n const tranformationString = buildResponseTransformation({\n responseMessageResultPath,\n });\n\n expect(tranformationString).toStrictEqual(\n `$.${responseMessageResult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