@integration-app/react 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (262) hide show
  1. package/node_modules/@compwright/namecase/LICENSE +26 -0
  2. package/node_modules/@compwright/namecase/README.md +49 -0
  3. package/node_modules/@compwright/namecase/bin/namecase +28 -0
  4. package/node_modules/@compwright/namecase/dist/namecase.min.js +4 -0
  5. package/node_modules/@compwright/namecase/dist/namecase.min.js.map +1 -0
  6. package/node_modules/@compwright/namecase/package.json +46 -0
  7. package/node_modules/@compwright/namecase/src/index.js +146 -0
  8. package/node_modules/@integration-app/sdk/bundle.js +404 -262
  9. package/node_modules/@integration-app/sdk/bundle.js.map +1 -1
  10. package/node_modules/@integration-app/sdk/client.d.ts +3 -3
  11. package/node_modules/@integration-app/sdk/data-builder/formulas/case.d.ts +3 -7
  12. package/node_modules/@integration-app/sdk/data-builder/formulas/case.js +16 -32
  13. package/node_modules/@integration-app/sdk/data-builder/formulas/case.js.map +1 -1
  14. package/node_modules/@integration-app/sdk/integrations/accessors.d.ts +0 -6
  15. package/node_modules/@integration-app/sdk/integrations/accessors.js +1 -87
  16. package/node_modules/@integration-app/sdk/integrations/accessors.js.map +1 -1
  17. package/node_modules/@integration-app/sdk/json-schema/index.d.ts +1 -1
  18. package/node_modules/@integration-app/sdk/src/client.ts +3 -3
  19. package/node_modules/@integration-app/sdk/src/data-builder/formulas/case.test.ts +11 -113
  20. package/node_modules/@integration-app/sdk/src/data-builder/formulas/case.ts +22 -46
  21. package/node_modules/@integration-app/sdk/src/integrations/accessors.ts +2 -122
  22. package/node_modules/@sinclair/typebox/package.json +40 -0
  23. package/node_modules/@sinclair/typebox/readme.md +740 -0
  24. package/node_modules/@sinclair/typebox/typebox.d.ts +351 -0
  25. package/node_modules/@sinclair/typebox/typebox.js +345 -0
  26. package/node_modules/@types/node/README.md +16 -0
  27. package/node_modules/@types/node/assert.d.ts +128 -0
  28. package/node_modules/@types/node/async_hooks.d.ts +229 -0
  29. package/node_modules/@types/node/buffer.d.ts +89 -0
  30. package/node_modules/@types/node/child_process.d.ts +514 -0
  31. package/node_modules/@types/node/cluster.d.ts +265 -0
  32. package/node_modules/@types/node/console.d.ts +142 -0
  33. package/node_modules/@types/node/constants.d.ts +18 -0
  34. package/node_modules/@types/node/crypto.d.ts +1283 -0
  35. package/node_modules/@types/node/dgram.d.ts +144 -0
  36. package/node_modules/@types/node/dns.d.ts +387 -0
  37. package/node_modules/@types/node/domain.d.ts +27 -0
  38. package/node_modules/@types/node/events.d.ts +82 -0
  39. package/node_modules/@types/node/fs/promises.d.ts +572 -0
  40. package/node_modules/@types/node/fs.d.ts +2281 -0
  41. package/node_modules/@types/node/globals.d.ts +747 -0
  42. package/node_modules/@types/node/globals.global.d.ts +1 -0
  43. package/node_modules/@types/node/http.d.ts +580 -0
  44. package/node_modules/@types/node/http2.d.ts +962 -0
  45. package/node_modules/@types/node/https.d.ts +271 -0
  46. package/node_modules/@types/node/index.d.ts +98 -0
  47. package/node_modules/@types/node/inspector.d.ts +3051 -0
  48. package/node_modules/@types/node/module.d.ts +56 -0
  49. package/node_modules/@types/node/net.d.ts +308 -0
  50. package/node_modules/@types/node/os.d.ts +243 -0
  51. package/node_modules/@types/node/package.json +232 -0
  52. package/node_modules/@types/node/path.d.ts +168 -0
  53. package/node_modules/@types/node/perf_hooks.d.ts +274 -0
  54. package/node_modules/@types/node/process.d.ts +413 -0
  55. package/node_modules/@types/node/punycode.d.ts +78 -0
  56. package/node_modules/@types/node/querystring.d.ts +31 -0
  57. package/node_modules/@types/node/readline.d.ts +174 -0
  58. package/node_modules/@types/node/repl.d.ts +398 -0
  59. package/node_modules/@types/node/stream.d.ts +359 -0
  60. package/node_modules/@types/node/string_decoder.d.ts +10 -0
  61. package/node_modules/@types/node/timers.d.ts +19 -0
  62. package/node_modules/@types/node/tls.d.ts +784 -0
  63. package/node_modules/@types/node/trace_events.d.ts +64 -0
  64. package/node_modules/@types/node/ts4.8/assert.d.ts +128 -0
  65. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +229 -0
  66. package/node_modules/@types/node/ts4.8/buffer.d.ts +89 -0
  67. package/node_modules/@types/node/ts4.8/child_process.d.ts +514 -0
  68. package/node_modules/@types/node/ts4.8/cluster.d.ts +265 -0
  69. package/node_modules/@types/node/ts4.8/console.d.ts +142 -0
  70. package/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
  71. package/node_modules/@types/node/ts4.8/crypto.d.ts +1283 -0
  72. package/node_modules/@types/node/ts4.8/dgram.d.ts +144 -0
  73. package/node_modules/@types/node/ts4.8/dns.d.ts +387 -0
  74. package/node_modules/@types/node/ts4.8/domain.d.ts +27 -0
  75. package/node_modules/@types/node/ts4.8/events.d.ts +82 -0
  76. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +572 -0
  77. package/node_modules/@types/node/ts4.8/fs.d.ts +2281 -0
  78. package/node_modules/@types/node/ts4.8/globals.d.ts +746 -0
  79. package/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
  80. package/node_modules/@types/node/ts4.8/http.d.ts +580 -0
  81. package/node_modules/@types/node/ts4.8/http2.d.ts +962 -0
  82. package/node_modules/@types/node/ts4.8/https.d.ts +271 -0
  83. package/node_modules/@types/node/ts4.8/index.d.ts +53 -0
  84. package/node_modules/@types/node/ts4.8/inspector.d.ts +3051 -0
  85. package/node_modules/@types/node/ts4.8/module.d.ts +56 -0
  86. package/node_modules/@types/node/ts4.8/net.d.ts +308 -0
  87. package/node_modules/@types/node/ts4.8/os.d.ts +243 -0
  88. package/node_modules/@types/node/ts4.8/path.d.ts +168 -0
  89. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +274 -0
  90. package/node_modules/@types/node/ts4.8/process.d.ts +413 -0
  91. package/node_modules/@types/node/ts4.8/punycode.d.ts +78 -0
  92. package/node_modules/@types/node/ts4.8/querystring.d.ts +31 -0
  93. package/node_modules/@types/node/ts4.8/readline.d.ts +174 -0
  94. package/node_modules/@types/node/ts4.8/repl.d.ts +398 -0
  95. package/node_modules/@types/node/ts4.8/stream.d.ts +359 -0
  96. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +10 -0
  97. package/node_modules/@types/node/ts4.8/timers.d.ts +19 -0
  98. package/node_modules/@types/node/ts4.8/tls.d.ts +784 -0
  99. package/node_modules/@types/node/ts4.8/trace_events.d.ts +64 -0
  100. package/node_modules/@types/node/ts4.8/tty.d.ts +69 -0
  101. package/node_modules/@types/node/ts4.8/url.d.ts +149 -0
  102. package/node_modules/@types/node/ts4.8/util.d.ts +216 -0
  103. package/node_modules/@types/node/ts4.8/v8.d.ts +190 -0
  104. package/node_modules/@types/node/ts4.8/vm.d.ts +155 -0
  105. package/node_modules/@types/node/ts4.8/wasi.d.ts +89 -0
  106. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +241 -0
  107. package/node_modules/@types/node/ts4.8/zlib.d.ts +364 -0
  108. package/node_modules/@types/node/tty.d.ts +69 -0
  109. package/node_modules/@types/node/url.d.ts +149 -0
  110. package/node_modules/@types/node/util.d.ts +216 -0
  111. package/node_modules/@types/node/v8.d.ts +190 -0
  112. package/node_modules/@types/node/vm.d.ts +155 -0
  113. package/node_modules/@types/node/wasi.d.ts +89 -0
  114. package/node_modules/@types/node/worker_threads.d.ts +241 -0
  115. package/node_modules/@types/node/zlib.d.ts +364 -0
  116. package/package.json +2 -5
  117. package/node_modules/@integration-app/sdk/.DS_Store +0 -0
  118. package/node_modules/@integration-app/sdk/.gitignore +0 -11
  119. package/node_modules/@integration-app/sdk/.npmignore +0 -0
  120. package/node_modules/@integration-app/sdk/app-data-collections/app-data-collections.d.ts +0 -23
  121. package/node_modules/@integration-app/sdk/app-data-collections/app-data-collections.js.map +0 -1
  122. package/node_modules/@integration-app/sdk/app-data-schemas/app-data-schemas.d.ts +0 -20
  123. package/node_modules/@integration-app/sdk/app-data-schemas/app-data-schemas.js.map +0 -1
  124. package/node_modules/@integration-app/sdk/app-events/app-events.d.ts +0 -44
  125. package/node_modules/@integration-app/sdk/app-events/app-events.js.map +0 -1
  126. package/node_modules/@integration-app/sdk/connection-client.d.ts +0 -12
  127. package/node_modules/@integration-app/sdk/connection-client.js +0 -31
  128. package/node_modules/@integration-app/sdk/connection-client.js.map +0 -1
  129. package/node_modules/@integration-app/sdk/connections/connections.d.ts +0 -46
  130. package/node_modules/@integration-app/sdk/connections/connections.js.map +0 -1
  131. package/node_modules/@integration-app/sdk/connector-api/connector-api.d.ts +0 -157
  132. package/node_modules/@integration-app/sdk/connector-api/connector-api.js.map +0 -1
  133. package/node_modules/@integration-app/sdk/data-builder/findExternalRecordId.d.ts +0 -0
  134. package/node_modules/@integration-app/sdk/data-builder/findExternalRecordId.js.map +0 -1
  135. package/node_modules/@integration-app/sdk/data-builder/first-name.test.d.ts +0 -0
  136. package/node_modules/@integration-app/sdk/data-builder/first-name.test.js +0 -2
  137. package/node_modules/@integration-app/sdk/data-builder/first-name.test.js.map +0 -1
  138. package/node_modules/@integration-app/sdk/data-builder/formulas/anyOfOption.d.ts +0 -10
  139. package/node_modules/@integration-app/sdk/data-builder/formulas/anyOfOption.js.map +0 -1
  140. package/node_modules/@integration-app/sdk/data-builder/formulas/base.test.d.ts +0 -1
  141. package/node_modules/@integration-app/sdk/data-builder/formulas/base.test.js +0 -26
  142. package/node_modules/@integration-app/sdk/data-builder/formulas/base.test.js.map +0 -1
  143. package/node_modules/@integration-app/sdk/data-builder/formulas/case.test.d.ts +0 -1
  144. package/node_modules/@integration-app/sdk/data-builder/formulas/case.test.js +0 -246
  145. package/node_modules/@integration-app/sdk/data-builder/formulas/case.test.js.map +0 -1
  146. package/node_modules/@integration-app/sdk/data-builder/formulas/concat.test.d.ts +0 -1
  147. package/node_modules/@integration-app/sdk/data-builder/formulas/concat.test.js +0 -85
  148. package/node_modules/@integration-app/sdk/data-builder/formulas/concat.test.js.map +0 -1
  149. package/node_modules/@integration-app/sdk/data-builder/formulas/copy.test.d.ts +0 -1
  150. package/node_modules/@integration-app/sdk/data-builder/formulas/copy.test.js +0 -64
  151. package/node_modules/@integration-app/sdk/data-builder/formulas/copy.test.js.map +0 -1
  152. package/node_modules/@integration-app/sdk/data-builder/formulas/extractDate.test.d.ts +0 -1
  153. package/node_modules/@integration-app/sdk/data-builder/formulas/extractDate.test.js +0 -44
  154. package/node_modules/@integration-app/sdk/data-builder/formulas/extractDate.test.js.map +0 -1
  155. package/node_modules/@integration-app/sdk/data-builder/formulas/extractTime.test.d.ts +0 -1
  156. package/node_modules/@integration-app/sdk/data-builder/formulas/extractTime.test.js +0 -44
  157. package/node_modules/@integration-app/sdk/data-builder/formulas/extractTime.test.js.map +0 -1
  158. package/node_modules/@integration-app/sdk/data-builder/formulas/findAppRecordId.test.d.ts +0 -1
  159. package/node_modules/@integration-app/sdk/data-builder/formulas/findAppRecordId.test.js +0 -26
  160. package/node_modules/@integration-app/sdk/data-builder/formulas/findAppRecordId.test.js.map +0 -1
  161. package/node_modules/@integration-app/sdk/data-builder/formulas/findExternalRecordId.test.d.ts +0 -1
  162. package/node_modules/@integration-app/sdk/data-builder/formulas/findExternalRecordId.test.js +0 -26
  163. package/node_modules/@integration-app/sdk/data-builder/formulas/findExternalRecordId.test.js.map +0 -1
  164. package/node_modules/@integration-app/sdk/data-builder/formulas/first-name.test.d.ts +0 -1
  165. package/node_modules/@integration-app/sdk/data-builder/formulas/first-name.test.js +0 -14
  166. package/node_modules/@integration-app/sdk/data-builder/formulas/first-name.test.js.map +0 -1
  167. package/node_modules/@integration-app/sdk/data-builder/formulas/index.test.d.ts +0 -1
  168. package/node_modules/@integration-app/sdk/data-builder/formulas/index.test.js +0 -63
  169. package/node_modules/@integration-app/sdk/data-builder/formulas/index.test.js.map +0 -1
  170. package/node_modules/@integration-app/sdk/data-builder/formulas/iterate.test.d.ts +0 -1
  171. package/node_modules/@integration-app/sdk/data-builder/formulas/iterate.test.js +0 -112
  172. package/node_modules/@integration-app/sdk/data-builder/formulas/iterate.test.js.map +0 -1
  173. package/node_modules/@integration-app/sdk/data-builder/formulas/lookup.test.d.ts +0 -1
  174. package/node_modules/@integration-app/sdk/data-builder/formulas/lookup.test.js +0 -18
  175. package/node_modules/@integration-app/sdk/data-builder/formulas/lookup.test.js.map +0 -1
  176. package/node_modules/@integration-app/sdk/data-builder/formulas/map.test.d.ts +0 -1
  177. package/node_modules/@integration-app/sdk/data-builder/formulas/map.test.js +0 -114
  178. package/node_modules/@integration-app/sdk/data-builder/formulas/map.test.js.map +0 -1
  179. package/node_modules/@integration-app/sdk/data-builder/formulas/tpl.test.d.ts +0 -1
  180. package/node_modules/@integration-app/sdk/data-builder/formulas/tpl.test.js +0 -49
  181. package/node_modules/@integration-app/sdk/data-builder/formulas/tpl.test.js.map +0 -1
  182. package/node_modules/@integration-app/sdk/data-builder/formulas/types.d.ts +0 -0
  183. package/node_modules/@integration-app/sdk/data-builder/formulas/types.js.map +0 -1
  184. package/node_modules/@integration-app/sdk/data-builder/index.test.d.ts +0 -1
  185. package/node_modules/@integration-app/sdk/data-builder/index.test.js +0 -295
  186. package/node_modules/@integration-app/sdk/data-builder/index.test.js.map +0 -1
  187. package/node_modules/@integration-app/sdk/data-builder/locators.test.d.ts +0 -1
  188. package/node_modules/@integration-app/sdk/data-builder/locators.test.js +0 -775
  189. package/node_modules/@integration-app/sdk/data-builder/locators.test.js.map +0 -1
  190. package/node_modules/@integration-app/sdk/data-filter/conditions.d.ts +0 -0
  191. package/node_modules/@integration-app/sdk/data-filter/conditions.js.map +0 -1
  192. package/node_modules/@integration-app/sdk/data-filter/data-filter.test.d.ts +0 -1
  193. package/node_modules/@integration-app/sdk/data-filter/data-filter.test.js.map +0 -1
  194. package/node_modules/@integration-app/sdk/data-filter/index.test.d.ts +0 -1
  195. package/node_modules/@integration-app/sdk/data-filter/index.test.js +0 -43
  196. package/node_modules/@integration-app/sdk/data-filter/index.test.js.map +0 -1
  197. package/node_modules/@integration-app/sdk/data-filter/operators.test.d.ts +0 -1
  198. package/node_modules/@integration-app/sdk/data-filter/operators.test.js +0 -490
  199. package/node_modules/@integration-app/sdk/data-filter/operators.test.js.map +0 -1
  200. package/node_modules/@integration-app/sdk/data-links/data-links.d.ts +0 -58
  201. package/node_modules/@integration-app/sdk/data-links/data-links.js.map +0 -1
  202. package/node_modules/@integration-app/sdk/data-schema/index.test.d.ts +0 -1
  203. package/node_modules/@integration-app/sdk/data-schema/index.test.js +0 -86
  204. package/node_modules/@integration-app/sdk/data-schema/index.test.js.map +0 -1
  205. package/node_modules/@integration-app/sdk/data-sources/data-sources.d.ts +0 -41
  206. package/node_modules/@integration-app/sdk/data-sources/data-sources.js.map +0 -1
  207. package/node_modules/@integration-app/sdk/endpoints/endpoint-spec.d.ts +0 -30
  208. package/node_modules/@integration-app/sdk/endpoints/endpoint-spec.js.map +0 -1
  209. package/node_modules/@integration-app/sdk/field-mappings/field-mappings.d.ts +0 -29
  210. package/node_modules/@integration-app/sdk/field-mappings/field-mappings.js.map +0 -1
  211. package/node_modules/@integration-app/sdk/flow-runs/flow-runs.d.ts +0 -51
  212. package/node_modules/@integration-app/sdk/flow-runs/flow-runs.js.map +0 -1
  213. package/node_modules/@integration-app/sdk/flows/flows.d.ts +0 -156
  214. package/node_modules/@integration-app/sdk/flows/flows.js.map +0 -1
  215. package/node_modules/@integration-app/sdk/flows/nodes/data-record-delete-trigger.d.ts +0 -3
  216. package/node_modules/@integration-app/sdk/flows/nodes/data-record-delete-trigger.js.map +0 -1
  217. package/node_modules/@integration-app/sdk/flows/nodes/nodes.d.ts +0 -25
  218. package/node_modules/@integration-app/sdk/flows/nodes/nodes.js.map +0 -1
  219. package/node_modules/@integration-app/sdk/flows/utils.test.d.ts +0 -1
  220. package/node_modules/@integration-app/sdk/flows/utils.test.js +0 -62
  221. package/node_modules/@integration-app/sdk/flows/utils.test.js.map +0 -1
  222. package/node_modules/@integration-app/sdk/integration-elements/integration-elements.d.ts +0 -21
  223. package/node_modules/@integration-app/sdk/integration-elements/integration-elements.js.map +0 -1
  224. package/node_modules/@integration-app/sdk/integrations/integrations.d.ts +0 -48
  225. package/node_modules/@integration-app/sdk/integrations/integrations.js.map +0 -1
  226. package/node_modules/@integration-app/sdk/json-schema/json-schema.test.d.ts +0 -1
  227. package/node_modules/@integration-app/sdk/json-schema/json-schema.test.js +0 -194
  228. package/node_modules/@integration-app/sdk/json-schema/json-schema.test.js.map +0 -1
  229. package/node_modules/@integration-app/sdk/json-schema/schema-builder.test.d.ts +0 -1
  230. package/node_modules/@integration-app/sdk/json-schema/schema-builder.test.js +0 -352
  231. package/node_modules/@integration-app/sdk/json-schema/schema-builder.test.js.map +0 -1
  232. package/node_modules/@integration-app/sdk/jwt.test.d.ts +0 -1
  233. package/node_modules/@integration-app/sdk/jwt.test.js +0 -9
  234. package/node_modules/@integration-app/sdk/jwt.test.js.map +0 -1
  235. package/node_modules/@integration-app/sdk/package-lock.json +0 -3834
  236. package/node_modules/@integration-app/sdk/udm/activities.test.d.ts +0 -1
  237. package/node_modules/@integration-app/sdk/udm/activities.test.js +0 -40
  238. package/node_modules/@integration-app/sdk/udm/activities.test.js.map +0 -1
  239. package/node_modules/@integration-app/sdk/udm/campaign-members.d.ts +0 -45
  240. package/node_modules/@integration-app/sdk/udm/campaign-members.js +0 -99
  241. package/node_modules/@integration-app/sdk/udm/campaign-members.js.map +0 -1
  242. package/node_modules/@integration-app/sdk/udm/contacts.test.d.ts +0 -1
  243. package/node_modules/@integration-app/sdk/udm/contacts.test.js +0 -136
  244. package/node_modules/@integration-app/sdk/udm/contacts.test.js.map +0 -1
  245. package/node_modules/@integration-app/sdk/udm/crm-activities.d.ts +0 -17
  246. package/node_modules/@integration-app/sdk/udm/crm-activities.js.map +0 -1
  247. package/node_modules/@integration-app/sdk/udm/crm-activity.d.ts +0 -11
  248. package/node_modules/@integration-app/sdk/udm/crm-activity.js.map +0 -1
  249. package/node_modules/@integration-app/sdk/udm/crm-companies.d.ts +0 -14
  250. package/node_modules/@integration-app/sdk/udm/crm-companies.js.map +0 -1
  251. package/node_modules/@integration-app/sdk/udm/crm-contact.d.ts +0 -10
  252. package/node_modules/@integration-app/sdk/udm/crm-contact.js.map +0 -1
  253. package/node_modules/@integration-app/sdk/udm/crm-contacts.d.ts +0 -16
  254. package/node_modules/@integration-app/sdk/udm/crm-contacts.js.map +0 -1
  255. package/node_modules/@integration-app/sdk/udm/crm-deals.d.ts +0 -15
  256. package/node_modules/@integration-app/sdk/udm/crm-deals.js.map +0 -1
  257. package/node_modules/@integration-app/sdk/udm/crm-leads.d.ts +0 -16
  258. package/node_modules/@integration-app/sdk/udm/crm-leads.js.map +0 -1
  259. package/node_modules/@integration-app/sdk/udm/members.d.ts +0 -45
  260. package/node_modules/@integration-app/sdk/udm/members.js.map +0 -1
  261. package/node_modules/@integration-app/sdk/users/users.d.ts +0 -5
  262. package/node_modules/@integration-app/sdk/users/users.js.map +0 -1
@@ -1,775 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const errors_1 = require("../errors");
4
- const formulas_1 = require("./formulas");
5
- const locators_1 = require("./locators");
6
- describe('Data Composer', () => {
7
- const PROPERTY_NAME = 'testProperty';
8
- const TEST_SIMPLE_SCHEMA = { type: 'string' };
9
- const TEST_COMPLEX_SCHEMA = {
10
- type: 'object',
11
- properties: {
12
- [PROPERTY_NAME]: {
13
- anyOf: [
14
- {
15
- type: 'array',
16
- key: 'keyValue',
17
- items: {
18
- type: 'object',
19
- properties: {
20
- [PROPERTY_NAME]: {
21
- type: 'array',
22
- items: TEST_SIMPLE_SCHEMA,
23
- },
24
- },
25
- },
26
- },
27
- ],
28
- },
29
- },
30
- };
31
- const OBJECT_PROPERTY_LOCATOR = new locators_1.DataLocatorStepObjectProperty(PROPERTY_NAME);
32
- const ARRAY_ITEM_LOCATOR = new locators_1.DataLocatorStepArrayItem(2);
33
- const CURRENT_ITEM_LOCATOR = new locators_1.DataLocatorStepCurrentArrayItem();
34
- const SCHEMA_OPTION_LOCATOR = new locators_1.DataLocatorStepSchemaOption('keyValue');
35
- describe('getSchemaByLocator', () => {
36
- it('should return schema by empty locator', () => {
37
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, [])).toEqual(TEST_COMPLEX_SCHEMA);
38
- });
39
- it('should return schema for object property locator', () => {
40
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, [OBJECT_PROPERTY_LOCATOR])).toEqual(TEST_COMPLEX_SCHEMA.properties[PROPERTY_NAME]);
41
- });
42
- it('should return schema for any of locator', () => {
43
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, [
44
- OBJECT_PROPERTY_LOCATOR,
45
- SCHEMA_OPTION_LOCATOR,
46
- ])).toEqual(TEST_COMPLEX_SCHEMA.properties[PROPERTY_NAME].anyOf[0]);
47
- });
48
- it('should return schema for array item locator', () => {
49
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, [
50
- OBJECT_PROPERTY_LOCATOR,
51
- SCHEMA_OPTION_LOCATOR,
52
- ARRAY_ITEM_LOCATOR,
53
- ])).toEqual(TEST_COMPLEX_SCHEMA.properties[PROPERTY_NAME].anyOf[0].items);
54
- });
55
- it('should return schema for current array item locator', () => {
56
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, [
57
- OBJECT_PROPERTY_LOCATOR,
58
- SCHEMA_OPTION_LOCATOR,
59
- ARRAY_ITEM_LOCATOR,
60
- OBJECT_PROPERTY_LOCATOR,
61
- CURRENT_ITEM_LOCATOR,
62
- ])).toEqual(TEST_COMPLEX_SCHEMA.properties[PROPERTY_NAME].anyOf[0].items.properties[PROPERTY_NAME].items);
63
- });
64
- it('should return null if object property does not exist', () => {
65
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, '$.nonExistentProperty')).toBeNull();
66
- });
67
- it('should return null if used $current without an array', () => {
68
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, '$.$current')).toBeNull();
69
- });
70
- it('should return null if used array index not on array', () => {
71
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, `$.${PROPERTY_NAME}[1]`)).toBeNull();
72
- });
73
- it('should return null if used non-existed any of option', () => {
74
- expect((0, locators_1.getSchemaByLocator)(TEST_COMPLEX_SCHEMA, `$.${PROPERTY_NAME}<nonExistingKey>`)).toBeNull();
75
- });
76
- });
77
- describe('setSchemaAtLocator', () => {
78
- it('should set schema at root', () => {
79
- expect((0, locators_1.setSchemaAtLocator)({ type: 'string' }, '$', TEST_COMPLEX_SCHEMA)).toEqual(TEST_COMPLEX_SCHEMA);
80
- });
81
- it('should set schema for object key and keep other keys', () => {
82
- expect((0, locators_1.setSchemaAtLocator)({ type: 'object', properties: { existingKey: TEST_SIMPLE_SCHEMA } }, '$.key', TEST_COMPLEX_SCHEMA)).toEqual({
83
- type: 'object',
84
- properties: {
85
- key: TEST_COMPLEX_SCHEMA,
86
- existingKey: TEST_SIMPLE_SCHEMA,
87
- },
88
- });
89
- });
90
- it('should set schema for array items but keey existing schema as well', () => {
91
- expect((0, locators_1.setSchemaAtLocator)({
92
- type: 'array',
93
- items: {
94
- type: 'object',
95
- properties: { existingKey: TEST_SIMPLE_SCHEMA },
96
- },
97
- }, '$.$current.key', TEST_COMPLEX_SCHEMA)).toEqual({
98
- type: 'array',
99
- items: {
100
- type: 'object',
101
- properties: {
102
- key: TEST_COMPLEX_SCHEMA,
103
- existingKey: TEST_SIMPLE_SCHEMA,
104
- },
105
- },
106
- });
107
- });
108
- });
109
- describe('makeSchemaForLocator', () => {
110
- it('should make schema for empty locator', () => {
111
- expect((0, locators_1.makeSchemaForLocator)([], TEST_SIMPLE_SCHEMA)).toEqual(TEST_SIMPLE_SCHEMA);
112
- });
113
- it('should make schema for object property locator', () => {
114
- expect((0, locators_1.makeSchemaForLocator)([OBJECT_PROPERTY_LOCATOR], TEST_SIMPLE_SCHEMA)).toEqual({
115
- type: 'object',
116
- properties: {
117
- [PROPERTY_NAME]: TEST_SIMPLE_SCHEMA,
118
- },
119
- });
120
- });
121
- it('should make schema for array item locator', () => {
122
- expect((0, locators_1.makeSchemaForLocator)([ARRAY_ITEM_LOCATOR], TEST_SIMPLE_SCHEMA)).toEqual({
123
- type: 'array',
124
- items: TEST_SIMPLE_SCHEMA,
125
- });
126
- });
127
- it('should make schema for current item locator', () => {
128
- expect((0, locators_1.makeSchemaForLocator)([CURRENT_ITEM_LOCATOR], TEST_SIMPLE_SCHEMA)).toEqual({
129
- type: 'array',
130
- items: TEST_SIMPLE_SCHEMA,
131
- });
132
- });
133
- it('should make schema for schemaOption locator', () => {
134
- const schemaOption = {
135
- ...TEST_SIMPLE_SCHEMA,
136
- key: SCHEMA_OPTION_LOCATOR.key,
137
- };
138
- expect((0, locators_1.makeSchemaForLocator)([SCHEMA_OPTION_LOCATOR], schemaOption)).toEqual({
139
- anyOf: [
140
- {
141
- ...TEST_SIMPLE_SCHEMA,
142
- key: SCHEMA_OPTION_LOCATOR.key,
143
- },
144
- ],
145
- });
146
- });
147
- it('should make schema for a composite locator', () => {
148
- expect((0, locators_1.makeSchemaForLocator)([
149
- OBJECT_PROPERTY_LOCATOR,
150
- SCHEMA_OPTION_LOCATOR,
151
- CURRENT_ITEM_LOCATOR,
152
- OBJECT_PROPERTY_LOCATOR,
153
- ARRAY_ITEM_LOCATOR,
154
- ], TEST_SIMPLE_SCHEMA)).toEqual({
155
- type: 'object',
156
- properties: {
157
- [PROPERTY_NAME]: {
158
- anyOf: [
159
- {
160
- type: 'array',
161
- key: SCHEMA_OPTION_LOCATOR.key,
162
- items: {
163
- type: 'object',
164
- properties: {
165
- [PROPERTY_NAME]: {
166
- type: 'array',
167
- items: TEST_SIMPLE_SCHEMA,
168
- },
169
- },
170
- },
171
- },
172
- ],
173
- },
174
- },
175
- });
176
- });
177
- });
178
- describe('locatorToSteps', () => {
179
- it('should throw on incorrect value', () => {
180
- expect(() => (0, locators_1.locatorToSteps)(null)).toThrow(errors_1.BadRequestError);
181
- expect(() => (0, locators_1.locatorToSteps)('')).toThrow(errors_1.BadRequestError);
182
- expect(() => (0, locators_1.locatorToSteps)({ key: 'value' })).toThrow(errors_1.BadRequestError);
183
- });
184
- it('should throw error for two dots ..', () => {
185
- expect(() => (0, locators_1.locatorToSteps)('$..')).toThrow(errors_1.BadRequestError);
186
- expect(() => (0, locators_1.locatorToSteps)('$..')).toThrow('There should be a property name after a dot');
187
- });
188
- it('should throw error for not closed [ bracket', () => {
189
- expect(() => (0, locators_1.locatorToSteps)('$.prop[1')).toThrow(errors_1.BadRequestError);
190
- expect(() => (0, locators_1.locatorToSteps)('$.prop[1')).toThrow('Could not find a closing bracket for the bracket at position 6. Locator: $.prop[1');
191
- });
192
- it('should throw error for not closed < bracket', () => {
193
- expect(() => (0, locators_1.locatorToSteps)('$.prop<1')).toThrow(errors_1.BadRequestError);
194
- expect(() => (0, locators_1.locatorToSteps)('$.prop<1')).toThrow('Could not find a closing bracket for the bracket at position 6. Locator: $.prop<1');
195
- });
196
- it('should throw error for redundant ] bracket', () => {
197
- expect(() => (0, locators_1.locatorToSteps)('$.prop[1]]')).toThrow(errors_1.BadRequestError);
198
- expect(() => (0, locators_1.locatorToSteps)('$.prop[1]]')).toThrow('Unexpected symbol at position 9. Locator: $.prop[1]]');
199
- });
200
- it('should throw error for redundant > bracket', () => {
201
- expect(() => (0, locators_1.locatorToSteps)('$.prop<1>>')).toThrow(errors_1.BadRequestError);
202
- expect(() => (0, locators_1.locatorToSteps)('$.prop<1>>')).toThrow('Unexpected symbol at position 9. Locator: $.prop<1>>');
203
- });
204
- it('should throw error if [index] is not a number', () => {
205
- expect(() => (0, locators_1.locatorToSteps)('$.prop[aa]')).toThrow(errors_1.BadRequestError);
206
- expect(() => (0, locators_1.locatorToSteps)('$.prop[aa]')).toThrow('Invalid index [aa]. Index should be a positive numbe');
207
- });
208
- it('should accept locators without $.', () => {
209
- expect((0, locators_1.locatorToSteps)('prop[0]')).toEqual([
210
- new locators_1.DataLocatorStepObjectProperty('prop'),
211
- new locators_1.DataLocatorStepArrayItem(0),
212
- ]);
213
- });
214
- it('should extract locators from simple string locator', () => {
215
- expect((0, locators_1.locatorToSteps)('$.name')).toEqual([
216
- new locators_1.DataLocatorStepObjectProperty('name'),
217
- ]);
218
- });
219
- it('should extract locators from nested object string locator', () => {
220
- expect((0, locators_1.locatorToSteps)('$.name.firstName')).toEqual([
221
- new locators_1.DataLocatorStepObjectProperty('name'),
222
- new locators_1.DataLocatorStepObjectProperty('firstName'),
223
- ]);
224
- });
225
- it('should extract locators if root is array', () => {
226
- expect((0, locators_1.locatorToSteps)('$[5]')).toEqual([new locators_1.DataLocatorStepArrayItem(5)]);
227
- });
228
- it('should extract locators from string locator with $current', () => {
229
- expect((0, locators_1.locatorToSteps)('$.$current.name')).toEqual([
230
- new locators_1.DataLocatorStepCurrentArrayItem(),
231
- new locators_1.DataLocatorStepObjectProperty('name'),
232
- ]);
233
- });
234
- it('should extract locators from string locator with array item index: prop[N]', () => {
235
- expect((0, locators_1.locatorToSteps)('$.users[52].name')).toEqual([
236
- new locators_1.DataLocatorStepObjectProperty('users'),
237
- new locators_1.DataLocatorStepArrayItem(52),
238
- new locators_1.DataLocatorStepObjectProperty('name'),
239
- ]);
240
- });
241
- it('should extract locators from string locator with nested arrays: prop[N][N]', () => {
242
- expect((0, locators_1.locatorToSteps)('$.users[52][10].name')).toEqual([
243
- new locators_1.DataLocatorStepObjectProperty('users'),
244
- new locators_1.DataLocatorStepArrayItem(52),
245
- new locators_1.DataLocatorStepArrayItem(10),
246
- new locators_1.DataLocatorStepObjectProperty('name'),
247
- ]);
248
- });
249
- it('should extract locators from string locator with anyOf', () => {
250
- expect((0, locators_1.locatorToSteps)('$.users<key>.name')).toEqual([
251
- new locators_1.DataLocatorStepObjectProperty('users'),
252
- new locators_1.DataLocatorStepSchemaOption('key'),
253
- new locators_1.DataLocatorStepObjectProperty('name'),
254
- ]);
255
- });
256
- it('should extract locators from complex string locator', () => {
257
- expect((0, locators_1.locatorToSteps)('$.field<key>[0].subfield')).toEqual([
258
- new locators_1.DataLocatorStepObjectProperty('field'),
259
- new locators_1.DataLocatorStepSchemaOption('key'),
260
- new locators_1.DataLocatorStepArrayItem(0),
261
- new locators_1.DataLocatorStepObjectProperty('subfield'),
262
- ]);
263
- });
264
- it('should extract locators from nested arrays with nested anyOf locator', () => {
265
- expect((0, locators_1.locatorToSteps)('$.field<key>[0]<key2>[3].subfield')).toEqual([
266
- new locators_1.DataLocatorStepObjectProperty('field'),
267
- new locators_1.DataLocatorStepSchemaOption('key'),
268
- new locators_1.DataLocatorStepArrayItem(0),
269
- new locators_1.DataLocatorStepSchemaOption('key2'),
270
- new locators_1.DataLocatorStepArrayItem(3),
271
- new locators_1.DataLocatorStepObjectProperty('subfield'),
272
- ]);
273
- });
274
- });
275
- describe('setValueAtLocator', () => {
276
- const TEST_OBJECT = {
277
- name: 'John',
278
- lastName: 'Doe',
279
- friends: [
280
- {
281
- name: 'Jane',
282
- lastName: 'Doe',
283
- },
284
- {
285
- name: 'Jack',
286
- lastName: 'Doe',
287
- },
288
- ],
289
- };
290
- it('should set value to empty object', () => {
291
- const result = (0, locators_1.setValueAtLocator)(null, '$.name', 'John');
292
- expect(result).toEqual({ name: 'John' });
293
- });
294
- it('should return the value if locator is empty', () => {
295
- expect((0, locators_1.setValueAtLocator)(TEST_OBJECT, '$', 'value')).toEqual('value');
296
- });
297
- it('should override a simple property', () => {
298
- expect((0, locators_1.setValueAtLocator)(TEST_OBJECT, '$.name', 'Sarah')).toEqual({
299
- ...TEST_OBJECT,
300
- name: 'Sarah',
301
- });
302
- });
303
- it('should delete property if undefined is provided', () => {
304
- expect((0, locators_1.setValueAtLocator)({
305
- name: 'John',
306
- lastName: 'Doe',
307
- }, '$.name', undefined)).toEqual({
308
- lastName: 'Doe',
309
- });
310
- });
311
- it('should override a property inside an array', () => {
312
- expect((0, locators_1.setValueAtLocator)(TEST_OBJECT, '$.friends[1].lastName', 'Brown')).toEqual({
313
- ...TEST_OBJECT,
314
- friends: [
315
- TEST_OBJECT.friends[0],
316
- {
317
- ...TEST_OBJECT.friends[1],
318
- lastName: 'Brown',
319
- },
320
- ],
321
- });
322
- });
323
- it('should set value at index 0 when used with $current', () => {
324
- expect((0, locators_1.setValueAtLocator)(TEST_OBJECT, '$.friends.$current.name', 'Sarah')).toEqual({
325
- ...TEST_OBJECT,
326
- friends: [
327
- {
328
- ...TEST_OBJECT.friends[0],
329
- name: 'Sarah',
330
- },
331
- TEST_OBJECT.friends[1],
332
- ],
333
- });
334
- });
335
- it('should create a property if does not exist', () => {
336
- expect((0, locators_1.setValueAtLocator)(TEST_OBJECT, '$.email', 'john@doe.com')).toEqual({
337
- ...TEST_OBJECT,
338
- email: 'john@doe.com',
339
- });
340
- });
341
- it('should create nested arrays and properties if do not exist', () => {
342
- expect((0, locators_1.setValueAtLocator)(TEST_OBJECT, '$.enemies[2].emails[0].value', 'john@doe.com')).toEqual({
343
- ...TEST_OBJECT,
344
- enemies: [
345
- undefined,
346
- undefined,
347
- {
348
- emails: [
349
- {
350
- value: 'john@doe.com',
351
- },
352
- ],
353
- },
354
- ],
355
- });
356
- });
357
- });
358
- describe('stepsToLocator', () => {
359
- it('should convert undefined, null, and empty array values to a root locator', () => {
360
- expect((0, locators_1.stepsToLocator)(undefined)).toEqual('$');
361
- expect((0, locators_1.stepsToLocator)(null)).toEqual('$');
362
- expect((0, locators_1.stepsToLocator)([])).toEqual('$');
363
- });
364
- it('should convert steps to corresponding locator parts', () => {
365
- expect((0, locators_1.stepsToLocator)([
366
- new locators_1.DataLocatorStepObjectProperty('friends'),
367
- new locators_1.DataLocatorStepCurrentArrayItem(),
368
- new locators_1.DataLocatorStepObjectProperty('names'),
369
- new locators_1.DataLocatorStepArrayItem(2),
370
- new locators_1.DataLocatorStepSchemaOption('key'),
371
- new locators_1.DataLocatorStepObjectProperty('firstName'),
372
- ])).toEqual('$.friends.$current.names[2]<key>.firstName');
373
- });
374
- });
375
- describe('locatorToString', () => {
376
- it('should keep empty values empty', () => {
377
- expect((0, locators_1.locatorToString)(undefined)).toBeUndefined();
378
- expect((0, locators_1.locatorToString)(null)).toEqual(null);
379
- });
380
- it('should keep string values string', () => {
381
- expect((0, locators_1.locatorToString)('')).toEqual('');
382
- expect((0, locators_1.locatorToString)('$')).toEqual('$');
383
- expect((0, locators_1.locatorToString)('$.name')).toEqual('$.name');
384
- });
385
- it('should convert locator steps to string', () => {
386
- expect((0, locators_1.locatorToString)([
387
- new locators_1.DataLocatorStepObjectProperty('posts'),
388
- new locators_1.DataLocatorStepCurrentArrayItem(),
389
- ])).toEqual('$.posts.$current');
390
- });
391
- });
392
- describe('getIconUriForLocator', () => {
393
- it('should return the latest uri encountered along locator steps', () => {
394
- const schema = {
395
- type: 'object',
396
- iconUri: 'uri1',
397
- properties: {
398
- prop1: {
399
- type: 'object',
400
- iconUri: 'uri2',
401
- properties: {
402
- prop2: { type: 'string' },
403
- },
404
- },
405
- },
406
- };
407
- expect((0, locators_1.getIconUriForLocator)(schema, '$.prop1.prop2')).toEqual('uri2');
408
- });
409
- it('should return undefined if schema does not have an icon URI', () => {
410
- const schema = {
411
- type: 'object',
412
- properties: {
413
- prop1: {
414
- type: 'object',
415
- properties: {
416
- prop2: { type: 'string' },
417
- },
418
- },
419
- },
420
- };
421
- expect((0, locators_1.getIconUriForLocator)(schema, '$.prop1.prop2')).toBeUndefined();
422
- });
423
- it('should return null for non-existent locator', () => {
424
- const schema = {
425
- type: 'string',
426
- };
427
- expect((0, locators_1.getIconUriForLocator)(schema, '$.prop1.prop2')).toBeNull();
428
- });
429
- });
430
- describe('getNameForLocator', () => {
431
- it('should return title if present', () => {
432
- const schema = {
433
- type: 'object',
434
- properties: {
435
- prop1: {
436
- type: 'string',
437
- title: 'Prop Name',
438
- },
439
- },
440
- };
441
- expect((0, locators_1.getNameForLocator)(schema, '$.prop1')).toEqual('Prop Name');
442
- });
443
- it('should return key if title is not present', () => {
444
- const schema = {
445
- type: 'object',
446
- properties: {
447
- prop1: {
448
- type: 'string',
449
- },
450
- },
451
- };
452
- expect((0, locators_1.getNameForLocator)(schema, '$.prop1')).toEqual('Prop1');
453
- });
454
- describe('getNameComponentsForLocator', () => {
455
- it('should ignore schemas with title set to empty string', () => {
456
- const schema = {
457
- type: 'object',
458
- properties: {
459
- ignore: {
460
- type: 'object',
461
- title: '',
462
- properties: {
463
- prop1: {
464
- title: 'Prop 1',
465
- },
466
- },
467
- },
468
- },
469
- };
470
- expect((0, locators_1.getNameComponentsForLocator)(schema, '$.ignore.prop1')).toEqual([
471
- 'Prop 1',
472
- ]);
473
- });
474
- });
475
- it('should return undefined if locator does not exist', () => {
476
- const schema = {
477
- type: 'object',
478
- };
479
- expect((0, locators_1.getNameForLocator)(schema, '$.prop1')).toBeNull();
480
- });
481
- });
482
- describe('getValueAtLocator', () => {
483
- const variables = {
484
- obj: {
485
- prop: 'objPropValue',
486
- },
487
- arr: [
488
- {
489
- arrProp: 'aprPropValue',
490
- },
491
- {
492
- arrProp: 'aprPropValue2',
493
- },
494
- ],
495
- };
496
- it('should return original variable with empty locator', () => {
497
- expect((0, locators_1.getValueAtLocator)(variables, '$')).toEqual(variables);
498
- });
499
- it('should return value from object property locator', () => {
500
- expect((0, locators_1.getValueAtLocator)(variables, '$.obj.prop')).toEqual(variables.obj.prop);
501
- });
502
- it('should return value from array item locator', () => {
503
- expect((0, locators_1.getValueAtLocator)(variables, '$.arr[1].arrProp')).toEqual(variables.arr[1].arrProp);
504
- });
505
- it('should return value from currentItem locator', () => {
506
- expect((0, locators_1.getValueAtLocator)(variables, '$.arr.$current.arrProp')).toEqual(variables.arr[0].arrProp);
507
- });
508
- it('should ignore anyOf locator', () => {
509
- expect((0, locators_1.getValueAtLocator)(variables, '$.arr<0>.$current<1>.arrProp')).toEqual(variables.arr[0].arrProp);
510
- });
511
- });
512
- describe('isLocatorUserVisible', () => {
513
- const schema = {
514
- type: 'object',
515
- properties: {
516
- visibleObject: {
517
- type: 'object',
518
- properties: {
519
- visibleProperty: {
520
- type: 'string',
521
- },
522
- invisibleProperty: {
523
- type: 'string',
524
- userVisible: false,
525
- },
526
- },
527
- },
528
- invisibleObject: {
529
- type: 'object',
530
- userVisible: false,
531
- properties: {
532
- visibleProperty: {
533
- type: 'string',
534
- },
535
- invisibleProperty: {
536
- type: 'string',
537
- userVisible: false,
538
- },
539
- },
540
- },
541
- visibleProperty: {
542
- type: 'string',
543
- },
544
- invisibleProperty: {
545
- type: 'string',
546
- userVisible: false,
547
- },
548
- },
549
- };
550
- expect((0, locators_1.isLocatorUserVisible)(schema, '$')).toBe(true);
551
- expect((0, locators_1.isLocatorUserVisible)(schema, '$.visibleProperty')).toBe(true);
552
- expect((0, locators_1.isLocatorUserVisible)(schema, '$.invisibleProperty')).toBe(false);
553
- expect((0, locators_1.isLocatorUserVisible)(schema, '$.visibleObject.visibleProperty')).toBe(true);
554
- expect((0, locators_1.isLocatorUserVisible)(schema, '$.visibleObject.invisibleProperty')).toBe(false);
555
- expect((0, locators_1.isLocatorUserVisible)(schema, '$.invisibleObject.visibleProperty')).toBe(false);
556
- expect((0, locators_1.isLocatorUserVisible)(schema, '$.invisibleObject.invisibleProperty')).toBe(false);
557
- });
558
- describe('getFormulaLocators', () => {
559
- it('should return empty list for an empty value', () => {
560
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, null)).toEqual([]);
561
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, undefined)).toEqual([]);
562
- });
563
- it('should return empty list for a scalar value', () => {
564
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, 'value')).toEqual([]);
565
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, 5)).toEqual([]);
566
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, false)).toEqual([]);
567
- });
568
- it('should return empty list for an object without $ui', () => {
569
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, { key: 'value' })).toEqual([]);
570
- });
571
- it('should return root locator', () => {
572
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, { $var: '$.abc' })).toEqual(['$']);
573
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.ITERATE, {
574
- $iterate: { locator: '$.abc' },
575
- })).toEqual(['$']);
576
- });
577
- it('should return locators inside nested objects', () => {
578
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, {
579
- obj: {
580
- key1: {
581
- $var: true,
582
- },
583
- key2: {
584
- $var: {
585
- uiConfig: 'value',
586
- },
587
- },
588
- },
589
- key: {
590
- $var: true,
591
- },
592
- })).toEqual(['$.obj.key1', '$.obj.key2', '$.key']);
593
- });
594
- it('should return locators inside nested lists', () => {
595
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, {
596
- obj: {
597
- list: [
598
- {
599
- $var: true,
600
- },
601
- {
602
- listKey: {
603
- $var: true,
604
- },
605
- },
606
- ],
607
- },
608
- })).toEqual(['$.obj.list[0]', '$.obj.list[1].listKey']);
609
- });
610
- it('should not return locator if $ui is not the only key', () => {
611
- expect((0, locators_1.getFormulaLocators)(formulas_1.DataBuilderFormulaType.VAR, {
612
- $var: true,
613
- anotherKey: true,
614
- })).toEqual([]);
615
- });
616
- });
617
- describe('findValueLocator', () => {
618
- it('should work correctly with empty data', () => {
619
- expect((0, locators_1.findValueLocators)(null, 'value')).toEqual([]);
620
- expect((0, locators_1.findValueLocators)(undefined, 'value')).toEqual([]);
621
- });
622
- it('should find value if it equals data', () => {
623
- expect((0, locators_1.findValueLocators)('value', 'value')).toEqual(['$']);
624
- expect((0, locators_1.findValueLocators)(5, 5)).toEqual(['$']);
625
- expect((0, locators_1.findValueLocators)(false, false)).toEqual(['$']);
626
- expect((0, locators_1.findValueLocators)({ key: 'value' }, { key: 'value' })).toEqual([
627
- '$',
628
- ]);
629
- });
630
- it('should find value in object', () => {
631
- expect((0, locators_1.findValueLocators)({ key: 'value' }, 'value')).toEqual(['$.key']);
632
- expect((0, locators_1.findValueLocators)({ key: { subkey: 'value' } }, { subkey: 'value' })).toEqual(['$.key']);
633
- });
634
- it('sholud find value in array', () => {
635
- expect((0, locators_1.findValueLocators)([1, 2, 3], 1)).toEqual(['$[0]']);
636
- expect((0, locators_1.findValueLocators)([{ key: 'not value' }, { key: 'value' }, { key: 'value' }], { key: 'value' })).toEqual(['$[1]', '$[2]']);
637
- });
638
- it('sholud find value in nested object', () => {
639
- expect((0, locators_1.findValueLocators)([
640
- 1,
641
- 2,
642
- {
643
- key: 1,
644
- },
645
- ], 1)).toEqual(['$[0]', '$[2].key']);
646
- });
647
- });
648
- });
649
- describe('pickFieldsFromValue', () => {
650
- const value = {
651
- key: 'value',
652
- objKey: {
653
- subKey: 'subKeyValue',
654
- },
655
- listKey: [
656
- {
657
- listSubKey: 'listSubKeyValue',
658
- },
659
- ],
660
- };
661
- it('should pick empty list of fields', () => {
662
- expect((0, locators_1.pickFieldsFromValue)(value, [])).toBeUndefined();
663
- });
664
- it('should pick non-existent values correctly', () => {
665
- expect((0, locators_1.pickFieldsFromValue)(value, ['$.nonexistent'])).toBeUndefined();
666
- });
667
- it('should pick values correctly', () => {
668
- expect((0, locators_1.pickFieldsFromValue)(value, ['$.key'])).toEqual({ key: 'value' });
669
- expect((0, locators_1.pickFieldsFromValue)(value, ['$.objKey.subKey'])).toEqual({
670
- objKey: { subKey: 'subKeyValue' },
671
- });
672
- expect((0, locators_1.pickFieldsFromValue)(value, ['$.listKey[0].listSubKey'])).toEqual({
673
- listKey: [{ listSubKey: 'listSubKeyValue' }],
674
- });
675
- });
676
- });
677
- describe('extractFieldLocator', () => {
678
- it('should return original locator for locators without formula', () => {
679
- expect((0, locators_1.extractFieldLocator)('$')).toEqual('$');
680
- expect((0, locators_1.extractFieldLocator)('$.key')).toEqual('$.key');
681
- expect((0, locators_1.extractFieldLocator)('$.objKey.subKey')).toEqual('$.objKey.subKey');
682
- expect((0, locators_1.extractFieldLocator)('$.listKey[0].listSubKey')).toEqual('$.listKey[0].listSubKey');
683
- });
684
- it('should return field part of the locator if it encounters formula', () => {
685
- expect((0, locators_1.extractFieldLocator)('$.$map.value')).toEqual('$');
686
- expect((0, locators_1.extractFieldLocator)('field.$firstName.value')).toEqual('$.field');
687
- expect((0, locators_1.extractFieldLocator)('field.$firstName')).toEqual('$.field');
688
- });
689
- });
690
- describe('getLocatorsFromData', () => {
691
- it('should return no locators for empty data', () => {
692
- expect((0, locators_1.getLocatorsFromData)(null)).toEqual([]);
693
- expect((0, locators_1.getLocatorsFromData)(undefined)).toEqual([]);
694
- });
695
- it('should return parent locator if data is not an object or array', () => {
696
- expect((0, locators_1.getLocatorsFromData)('value', '$')).toEqual(['$']);
697
- expect((0, locators_1.getLocatorsFromData)(5, '$')).toEqual(['$']);
698
- expect((0, locators_1.getLocatorsFromData)(false, '$')).toEqual(['$']);
699
- });
700
- it('should return object keys if data is object', () => {
701
- expect((0, locators_1.getLocatorsFromData)({ key: 'value', key2: 'value2' }, '$')).toEqual([
702
- '$.key',
703
- '$.key2',
704
- ]);
705
- });
706
- it('should return array items if data is array', () => {
707
- expect((0, locators_1.getLocatorsFromData)([{ key: 'value' }, 0], '$')).toEqual([
708
- '$[0].key',
709
- '$[1]',
710
- ]);
711
- });
712
- });
713
- describe('getLocatorsFromSchema', () => {
714
- it('should return no locators if schema is empty', () => {
715
- expect((0, locators_1.getLocatorsFromSchema)(null)).toEqual([]);
716
- expect((0, locators_1.getLocatorsFromSchema)(undefined)).toEqual([]);
717
- expect((0, locators_1.getLocatorsFromSchema)({})).toEqual([]);
718
- });
719
- it('should return parent locator for scalar schema', () => {
720
- expect((0, locators_1.getLocatorsFromSchema)({ type: 'string' }, '$')).toEqual(['$']);
721
- expect((0, locators_1.getLocatorsFromSchema)({ type: 'number' }, '$')).toEqual(['$']);
722
- expect((0, locators_1.getLocatorsFromSchema)({ type: 'boolean' }, '$')).toEqual(['$']);
723
- });
724
- it('should return object keys for object schema', () => {
725
- expect((0, locators_1.getLocatorsFromSchema)({
726
- type: 'object',
727
- properties: {
728
- key: { type: 'string' },
729
- key2: { type: 'number' },
730
- },
731
- }, '$')).toEqual(['$.key', '$.key2']);
732
- });
733
- it('should return first array item for array schema', () => {
734
- expect((0, locators_1.getLocatorsFromSchema)({
735
- type: 'array',
736
- items: {
737
- type: 'object',
738
- properties: {
739
- key: { type: 'string' },
740
- },
741
- },
742
- }, '$')).toEqual(['$[0].key']);
743
- });
744
- });
745
- describe('excludeFieldsFromValue', () => {
746
- it('should exclude simple field', () => {
747
- expect((0, locators_1.excludeFieldsFromValue)({ key: 'value', key2: 'value2' }, ['key'])).toEqual({
748
- key2: 'value2',
749
- });
750
- });
751
- it('should exclude object key', () => {
752
- expect((0, locators_1.excludeFieldsFromValue)({
753
- key: 'value',
754
- objKey: {
755
- subKey: 'subKeyValue',
756
- },
757
- }, ['objKey.subKey'])).toEqual({
758
- key: 'value',
759
- objKey: {},
760
- });
761
- });
762
- it('should exclude whole array item', () => {
763
- expect((0, locators_1.excludeFieldsFromValue)([1, 2], ['$[0]'])).toEqual([2]);
764
- });
765
- it('should exclude property from array item', () => {
766
- expect((0, locators_1.excludeFieldsFromValue)({
767
- key: 'value',
768
- listKey: [{ listSubKey: 'listSubKeyValue' }],
769
- }, ['listKey[0].listSubKey'])).toEqual({
770
- key: 'value',
771
- listKey: [{}],
772
- });
773
- });
774
- });
775
- //# sourceMappingURL=locators.test.js.map