@hubspot/ui-extensions 0.11.1 → 0.11.3

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 (236) hide show
  1. package/dist/__tests__/crm/hooks/useAssociations.spec.js +36 -32
  2. package/dist/__tests__/crm/hooks/useCrmProperties.spec.js +20 -19
  3. package/dist/__tests__/crm/utils/fetchAssociations.spec.js +13 -12
  4. package/dist/__tests__/crm/utils/fetchCrmProperties.spec.js +38 -37
  5. package/dist/clientTypes.d.ts +1 -0
  6. package/dist/clientTypes.js +1 -1
  7. package/dist/crm/hooks/useAssociations.d.ts +5 -3
  8. package/dist/crm/hooks/useAssociations.js +4 -2
  9. package/dist/crm/hooks/useCrmProperties.d.ts +4 -2
  10. package/dist/crm/hooks/useCrmProperties.js +4 -2
  11. package/dist/crm/index.d.ts +4 -4
  12. package/dist/crm/index.js +3 -3
  13. package/dist/crm/utils/fetchAssociations.d.ts +1 -1
  14. package/dist/experimental/index.d.ts +4 -4
  15. package/dist/experimental/index.js +3 -3
  16. package/dist/experimental/testing/__tests__/createRenderer.spec.js +23 -0
  17. package/dist/experimental/testing/__tests__/debug.spec.js +57 -0
  18. package/dist/experimental/testing/__tests__/find.spec.js +48 -0
  19. package/dist/experimental/testing/__tests__/findAll.spec.js +13 -0
  20. package/dist/experimental/testing/__tests__/findAllChildren.spec.js +54 -0
  21. package/dist/experimental/testing/__tests__/findByTestId.spec.js +126 -0
  22. package/dist/experimental/testing/__tests__/findChild.spec.js +33 -0
  23. package/dist/experimental/testing/__tests__/fragments.spec.js +66 -0
  24. package/dist/experimental/testing/__tests__/invalid-components.spec.js +96 -0
  25. package/dist/experimental/testing/__tests__/isMatch.spec.js +113 -0
  26. package/dist/experimental/testing/__tests__/logger.spec.js +10 -0
  27. package/dist/experimental/testing/__tests__/maybeFind.spec.js +67 -0
  28. package/dist/experimental/testing/__tests__/maybeFindByTestId.spec.js +65 -0
  29. package/dist/experimental/testing/__tests__/maybeFindChild.spec.js +75 -0
  30. package/dist/experimental/testing/__tests__/mocks.actions.spec.js +19 -0
  31. package/dist/experimental/testing/__tests__/mocks.context.spec.js +24 -0
  32. package/dist/experimental/testing/__tests__/mocks.runServerlessFunction.spec.js +35 -0
  33. package/dist/experimental/testing/__tests__/mocks.useAssociations.spec.js +47 -0
  34. package/dist/experimental/testing/__tests__/mocks.useCrmProperties.spec.js +58 -0
  35. package/dist/experimental/testing/__tests__/props.spec.js +13 -0
  36. package/dist/experimental/testing/__tests__/testId.spec.js +18 -0
  37. package/dist/experimental/testing/__tests__/trigger.spec.js +43 -0
  38. package/dist/experimental/testing/__tests__/type-utils.spec.js +165 -0
  39. package/dist/experimental/testing/__tests__/waitFor.spec.js +57 -0
  40. package/dist/experimental/testing/index.d.ts +4 -0
  41. package/dist/experimental/testing/index.js +4 -0
  42. package/dist/experimental/testing/internal/constants.d.ts +2 -2
  43. package/dist/experimental/testing/internal/constants.js +1 -1
  44. package/dist/experimental/testing/internal/convert.d.ts +10 -0
  45. package/dist/experimental/testing/internal/convert.js +149 -0
  46. package/dist/experimental/testing/internal/debug.d.ts +3 -3
  47. package/dist/experimental/testing/internal/debug.js +12 -4
  48. package/dist/experimental/testing/internal/document.d.ts +14 -0
  49. package/dist/experimental/testing/internal/document.js +40 -0
  50. package/dist/experimental/testing/internal/element.d.ts +4 -3
  51. package/dist/experimental/testing/internal/element.js +15 -10
  52. package/dist/experimental/testing/internal/errors.d.ts +57 -2
  53. package/dist/experimental/testing/internal/errors.js +62 -2
  54. package/dist/experimental/testing/internal/fragment.d.ts +3 -2
  55. package/dist/experimental/testing/internal/fragment.js +13 -9
  56. package/dist/experimental/testing/internal/match.d.ts +10 -0
  57. package/dist/experimental/testing/internal/match.js +19 -0
  58. package/dist/experimental/testing/internal/mocks/index.d.ts +17 -0
  59. package/dist/experimental/testing/internal/mocks/index.js +46 -0
  60. package/dist/experimental/testing/internal/mocks/mock-extension-point-api.d.ts +2 -0
  61. package/dist/experimental/testing/internal/mocks/mock-extension-point-api.js +166 -0
  62. package/dist/experimental/testing/internal/mocks/mock-hooks.d.ts +2 -0
  63. package/dist/experimental/testing/internal/mocks/mock-hooks.js +59 -0
  64. package/dist/experimental/testing/internal/print.d.ts +2 -2
  65. package/dist/experimental/testing/internal/print.js +17 -11
  66. package/dist/experimental/testing/internal/query.d.ts +19 -9
  67. package/dist/experimental/testing/internal/query.js +91 -46
  68. package/dist/experimental/testing/internal/root.d.ts +1 -1
  69. package/dist/experimental/testing/internal/root.js +12 -8
  70. package/dist/experimental/testing/internal/text.d.ts +3 -2
  71. package/dist/experimental/testing/internal/text.js +12 -3
  72. package/dist/experimental/testing/internal/type-utils-internal.d.ts +44 -0
  73. package/dist/experimental/testing/internal/type-utils-internal.js +54 -0
  74. package/dist/experimental/testing/internal/types-internal.d.ts +20 -2
  75. package/dist/experimental/testing/internal/utils/promise-utils.d.ts +14 -0
  76. package/dist/experimental/testing/internal/utils/promise-utils.js +14 -0
  77. package/dist/experimental/testing/render.d.ts +35 -0
  78. package/dist/experimental/testing/render.js +219 -0
  79. package/dist/experimental/testing/type-utils.d.ts +2 -2
  80. package/dist/experimental/testing/type-utils.js +1 -1
  81. package/dist/experimental/testing/types.d.ts +127 -9
  82. package/dist/experimental/testing/utils.d.ts +11 -0
  83. package/dist/experimental/testing/utils.js +24 -0
  84. package/dist/hubspot.d.ts +2 -4
  85. package/dist/hubspot.js +3 -3
  86. package/dist/index.d.ts +5 -5
  87. package/dist/index.js +5 -5
  88. package/dist/internal/global-utils.d.ts +6 -0
  89. package/dist/internal/global-utils.js +37 -0
  90. package/dist/internal/hook-utils.d.ts +19 -0
  91. package/dist/internal/hook-utils.js +34 -0
  92. package/dist/logger.d.ts +1 -8
  93. package/dist/logger.js +3 -2
  94. package/dist/pages/home/index.d.ts +1 -1
  95. package/dist/pages/home/index.js +1 -1
  96. package/dist/{__synced__/remoteComponents.synced.d.ts → shared/remoteComponents.d.ts} +159 -77
  97. package/dist/{__synced__/remoteComponents.synced.js → shared/remoteComponents.js} +99 -1
  98. package/dist/{__synced__/types/components/accordion.synced.d.ts → shared/types/components/accordion.d.ts} +2 -2
  99. package/dist/{__synced__/types/components/alert.synced.d.ts → shared/types/components/alert.d.ts} +2 -1
  100. package/dist/{__synced__/types/components/app-home-header-actions.synced.d.ts → shared/types/components/app-home-header-actions.d.ts} +4 -4
  101. package/dist/{__synced__/types/components/button-row.synced.d.ts → shared/types/components/button-row.d.ts} +2 -2
  102. package/dist/{__synced__/types/components/button.synced.d.ts → shared/types/components/button.d.ts} +9 -3
  103. package/dist/{__synced__/types/components/card.synced.d.ts → shared/types/components/card.d.ts} +2 -1
  104. package/dist/{__synced__/types/components/chart.synced.d.ts → shared/types/components/chart.d.ts} +2 -1
  105. package/dist/{__synced__/types/components/description-list.synced.d.ts → shared/types/components/description-list.d.ts} +3 -2
  106. package/dist/{__synced__/types/components/divider.synced.d.ts → shared/types/components/divider.d.ts} +2 -2
  107. package/dist/{__synced__/types/components/dropdown.synced.d.ts → shared/types/components/dropdown.d.ts} +5 -5
  108. package/dist/{__synced__/types/components/empty-state.synced.d.ts → shared/types/components/empty-state.d.ts} +2 -1
  109. package/dist/{__synced__/types/components/error-state.synced.d.ts → shared/types/components/error-state.d.ts} +2 -1
  110. package/dist/{__synced__/types/components/form.synced.d.ts → shared/types/components/form.d.ts} +3 -3
  111. package/dist/{__synced__/types/components/heading.synced.d.ts → shared/types/components/heading.d.ts} +2 -1
  112. package/dist/{__synced__/types/components/icon.synced.d.ts → shared/types/components/icon.d.ts} +2 -2
  113. package/dist/{__synced__/types/components/iframe.synced.d.ts → shared/types/components/iframe.d.ts} +2 -2
  114. package/dist/{__synced__/types/components/illustration.synced.d.ts → shared/types/components/illustration.d.ts} +2 -1
  115. package/dist/{__synced__/types/components/image.synced.d.ts → shared/types/components/image.d.ts} +3 -3
  116. package/dist/shared/types/components/index.d.ts +38 -0
  117. package/dist/shared/types/components/index.js +1 -0
  118. package/dist/{__synced__/types/components/inputs.synced.d.ts → shared/types/components/inputs.d.ts} +2 -1
  119. package/dist/shared/types/components/inputs.js +1 -0
  120. package/dist/{__synced__/types/components/layouts.synced.d.ts → shared/types/components/layouts.d.ts} +6 -6
  121. package/dist/shared/types/components/layouts.js +1 -0
  122. package/dist/{__synced__/types/components/link.synced.d.ts → shared/types/components/link.d.ts} +3 -3
  123. package/dist/shared/types/components/link.js +1 -0
  124. package/dist/{__synced__/types/components/list.synced.d.ts → shared/types/components/list.d.ts} +2 -1
  125. package/dist/shared/types/components/list.js +1 -0
  126. package/dist/{__synced__/types/components/loading-spinner.synced.d.ts → shared/types/components/loading-spinner.d.ts} +2 -2
  127. package/dist/shared/types/components/loading-spinner.js +1 -0
  128. package/dist/{__synced__/types/components/modal.synced.d.ts → shared/types/components/modal.d.ts} +4 -4
  129. package/dist/shared/types/components/modal.js +1 -0
  130. package/dist/{__synced__/types/components/panel.synced.d.ts → shared/types/components/panel.d.ts} +5 -5
  131. package/dist/shared/types/components/panel.js +1 -0
  132. package/dist/{__synced__/types/components/progress-bar.synced.d.ts → shared/types/components/progress-bar.d.ts} +2 -1
  133. package/dist/shared/types/components/progress-bar.js +1 -0
  134. package/dist/{__synced__/types/components/selects.synced.d.ts → shared/types/components/selects.d.ts} +2 -1
  135. package/dist/shared/types/components/selects.js +1 -0
  136. package/dist/{__synced__/types/components/statistics.synced.d.ts → shared/types/components/statistics.d.ts} +4 -3
  137. package/dist/shared/types/components/statistics.js +1 -0
  138. package/dist/{__synced__/types/components/status-tag.synced.d.ts → shared/types/components/status-tag.d.ts} +2 -1
  139. package/dist/shared/types/components/status-tag.js +1 -0
  140. package/dist/{__synced__/types/components/step-indicator.synced.d.ts → shared/types/components/step-indicator.d.ts} +2 -2
  141. package/dist/shared/types/components/step-indicator.js +1 -0
  142. package/dist/{__synced__/types/components/table.synced.d.ts → shared/types/components/table.d.ts} +5 -4
  143. package/dist/shared/types/components/table.js +1 -0
  144. package/dist/{__synced__/types/components/tabs.synced.d.ts → shared/types/components/tabs.d.ts} +3 -2
  145. package/dist/shared/types/components/tabs.js +1 -0
  146. package/dist/{__synced__/types/components/tag.synced.d.ts → shared/types/components/tag.d.ts} +3 -3
  147. package/dist/shared/types/components/tag.js +1 -0
  148. package/dist/{__synced__/types/components/text.synced.d.ts → shared/types/components/text.d.ts} +2 -1
  149. package/dist/shared/types/components/text.js +1 -0
  150. package/dist/{__synced__/types/components/tile.synced.d.ts → shared/types/components/tile.d.ts} +2 -1
  151. package/dist/shared/types/components/tile.js +1 -0
  152. package/dist/{__synced__/types/components/toggle.synced.d.ts → shared/types/components/toggle.d.ts} +2 -2
  153. package/dist/shared/types/components/toggle.js +1 -0
  154. package/dist/{__synced__/types/components/toggleInputs.synced.d.ts → shared/types/components/toggleInputs.d.ts} +4 -4
  155. package/dist/shared/types/components/toggleInputs.js +1 -0
  156. package/dist/{__synced__/types/components/tooltip.synced.d.ts → shared/types/components/tooltip.d.ts} +2 -1
  157. package/dist/shared/types/components/tooltip.js +1 -0
  158. package/dist/{__synced__/types/context.synced.d.ts → shared/types/context.d.ts} +1 -1
  159. package/dist/shared/types/context.js +1 -0
  160. package/dist/{__synced__/types/crm.synced.d.ts → shared/types/crm.d.ts} +13 -13
  161. package/dist/shared/types/crm.js +1 -0
  162. package/dist/{__synced__/experimental/types.synced.d.ts → shared/types/experimental.d.ts} +12 -17
  163. package/dist/shared/types/experimental.js +1 -0
  164. package/dist/shared/types/extend.d.ts +4 -0
  165. package/dist/shared/types/extend.js +1 -0
  166. package/dist/{__synced__/types/extension-points.synced.d.ts → shared/types/extension-points.d.ts} +18 -10
  167. package/dist/{__synced__/types/http-requests.synced.d.ts → shared/types/http-requests.d.ts} +1 -1
  168. package/dist/shared/types/index.d.ts +8 -0
  169. package/dist/shared/types/index.js +1 -0
  170. package/dist/shared/types/logger.d.ts +7 -0
  171. package/dist/shared/types/logger.js +1 -0
  172. package/dist/shared/types/reactions.js +1 -0
  173. package/dist/{__synced__/types/shared.synced.d.ts → shared/types/shared.d.ts} +3 -0
  174. package/dist/shared/types/worker-globals.d.ts +17 -0
  175. package/dist/shared/types/worker-globals.js +1 -0
  176. package/dist/{__synced__/utils/remote-component-registry.synced.d.ts → shared/utils/remote-component-registry.d.ts} +1 -1
  177. package/dist/{__synced__/utils/remote-component-registry.synced.js → shared/utils/remote-component-registry.js} +0 -1
  178. package/package.json +13 -14
  179. package/dist/__synced__/appHomeRemoteComponents.synced.d.ts +0 -28
  180. package/dist/__synced__/appHomeRemoteComponents.synced.js +0 -21
  181. package/dist/__synced__/crmRemoteComponents.synced.d.ts +0 -66
  182. package/dist/__synced__/crmRemoteComponents.synced.js +0 -15
  183. package/dist/__synced__/experimental/types.synced.js +0 -5
  184. package/dist/__synced__/experimentalRemoteComponents.synced.d.ts +0 -94
  185. package/dist/__synced__/experimentalRemoteComponents.synced.js +0 -56
  186. package/dist/__synced__/types/components/index.synced.d.ts +0 -38
  187. package/dist/__synced__/types/index.synced.d.ts +0 -8
  188. package/dist/__synced__/types/index.synced.js +0 -1
  189. /package/dist/{__synced__/types/actions.synced.js → experimental/testing/__tests__/createRenderer.spec.d.ts} +0 -0
  190. /package/dist/{__synced__/types/components/accordion.synced.js → experimental/testing/__tests__/debug.spec.d.ts} +0 -0
  191. /package/dist/{__synced__/types/components/alert.synced.js → experimental/testing/__tests__/find.spec.d.ts} +0 -0
  192. /package/dist/{__synced__/types/components/app-home-header-actions.synced.js → experimental/testing/__tests__/findAll.spec.d.ts} +0 -0
  193. /package/dist/{__synced__/types/components/button-row.synced.js → experimental/testing/__tests__/findAllChildren.spec.d.ts} +0 -0
  194. /package/dist/{__synced__/types/components/button.synced.js → experimental/testing/__tests__/findByTestId.spec.d.ts} +0 -0
  195. /package/dist/{__synced__/types/components/card.synced.js → experimental/testing/__tests__/findChild.spec.d.ts} +0 -0
  196. /package/dist/{__synced__/types/components/description-list.synced.js → experimental/testing/__tests__/fragments.spec.d.ts} +0 -0
  197. /package/dist/{__synced__/types/components/divider.synced.js → experimental/testing/__tests__/invalid-components.spec.d.ts} +0 -0
  198. /package/dist/{__synced__/types/components/dropdown.synced.js → experimental/testing/__tests__/isMatch.spec.d.ts} +0 -0
  199. /package/dist/{__synced__/types/components/empty-state.synced.js → experimental/testing/__tests__/logger.spec.d.ts} +0 -0
  200. /package/dist/{__synced__/types/components/error-state.synced.js → experimental/testing/__tests__/maybeFind.spec.d.ts} +0 -0
  201. /package/dist/{__synced__/types/components/form.synced.js → experimental/testing/__tests__/maybeFindByTestId.spec.d.ts} +0 -0
  202. /package/dist/{__synced__/types/components/heading.synced.js → experimental/testing/__tests__/maybeFindChild.spec.d.ts} +0 -0
  203. /package/dist/{__synced__/types/components/icon.synced.js → experimental/testing/__tests__/mocks.actions.spec.d.ts} +0 -0
  204. /package/dist/{__synced__/types/components/iframe.synced.js → experimental/testing/__tests__/mocks.context.spec.d.ts} +0 -0
  205. /package/dist/{__synced__/types/components/image.synced.js → experimental/testing/__tests__/mocks.runServerlessFunction.spec.d.ts} +0 -0
  206. /package/dist/{__synced__/types/components/index.synced.js → experimental/testing/__tests__/mocks.useAssociations.spec.d.ts} +0 -0
  207. /package/dist/{__synced__/types/components/inputs.synced.js → experimental/testing/__tests__/mocks.useCrmProperties.spec.d.ts} +0 -0
  208. /package/dist/{__synced__/types/components/layouts.synced.js → experimental/testing/__tests__/props.spec.d.ts} +0 -0
  209. /package/dist/{__synced__/types/components/link.synced.js → experimental/testing/__tests__/testId.spec.d.ts} +0 -0
  210. /package/dist/{__synced__/types/components/list.synced.js → experimental/testing/__tests__/trigger.spec.d.ts} +0 -0
  211. /package/dist/{__synced__/types/components/loading-spinner.synced.js → experimental/testing/__tests__/type-utils.spec.d.ts} +0 -0
  212. /package/dist/{__synced__/types/components/modal.synced.js → experimental/testing/__tests__/waitFor.spec.d.ts} +0 -0
  213. /package/dist/{__synced__/types/actions.synced.d.ts → shared/types/actions.d.ts} +0 -0
  214. /package/dist/{__synced__/types/components/panel.synced.js → shared/types/actions.js} +0 -0
  215. /package/dist/{__synced__/types/components/progress-bar.synced.js → shared/types/components/accordion.js} +0 -0
  216. /package/dist/{__synced__/types/components/selects.synced.js → shared/types/components/alert.js} +0 -0
  217. /package/dist/{__synced__/types/components/statistics.synced.js → shared/types/components/app-home-header-actions.js} +0 -0
  218. /package/dist/{__synced__/types/components/status-tag.synced.js → shared/types/components/button-row.js} +0 -0
  219. /package/dist/{__synced__/types/components/step-indicator.synced.js → shared/types/components/button.js} +0 -0
  220. /package/dist/{__synced__/types/components/table.synced.js → shared/types/components/card.js} +0 -0
  221. /package/dist/{__synced__/types/components/chart.synced.js → shared/types/components/chart.js} +0 -0
  222. /package/dist/{__synced__/types/components/tabs.synced.js → shared/types/components/description-list.js} +0 -0
  223. /package/dist/{__synced__/types/components/tag.synced.js → shared/types/components/divider.js} +0 -0
  224. /package/dist/{__synced__/types/components/text.synced.js → shared/types/components/dropdown.js} +0 -0
  225. /package/dist/{__synced__/types/components/tile.synced.js → shared/types/components/empty-state.js} +0 -0
  226. /package/dist/{__synced__/types/components/toggle.synced.js → shared/types/components/error-state.js} +0 -0
  227. /package/dist/{__synced__/types/components/toggleInputs.synced.js → shared/types/components/form.js} +0 -0
  228. /package/dist/{__synced__/types/components/tooltip.synced.js → shared/types/components/heading.js} +0 -0
  229. /package/dist/{__synced__/types/context.synced.js → shared/types/components/icon.js} +0 -0
  230. /package/dist/{__synced__/types/crm.synced.js → shared/types/components/iframe.js} +0 -0
  231. /package/dist/{__synced__/types/components/illustration.synced.js → shared/types/components/illustration.js} +0 -0
  232. /package/dist/{__synced__/types/reactions.synced.js → shared/types/components/image.js} +0 -0
  233. /package/dist/{__synced__/types/extension-points.synced.js → shared/types/extension-points.js} +0 -0
  234. /package/dist/{__synced__/types/http-requests.synced.js → shared/types/http-requests.js} +0 -0
  235. /package/dist/{__synced__/types/reactions.synced.d.ts → shared/types/reactions.d.ts} +0 -0
  236. /package/dist/{__synced__/types/shared.synced.js → shared/types/shared.js} +0 -0
@@ -1,20 +1,24 @@
1
1
  import { renderHook, waitFor } from '@testing-library/react';
2
- import { useAssociations } from '../../../crm/hooks/useAssociations';
3
- import { fetchAssociations } from '../../../crm/utils/fetchAssociations';
2
+ import { vi } from 'vitest';
3
+ import { useAssociations } from "../../../crm/hooks/useAssociations.js";
4
+ import { fetchAssociations } from "../../../crm/utils/fetchAssociations.js";
4
5
  // Mock the logger module
5
- jest.mock('../../../logger', () => ({
6
+ vi.mock('../../../logger', () => ({
6
7
  logger: {
7
- debug: jest.fn(),
8
- info: jest.fn(),
9
- warn: jest.fn(),
10
- error: jest.fn(),
8
+ debug: vi.fn(),
9
+ info: vi.fn(),
10
+ warn: vi.fn(),
11
+ error: vi.fn(),
11
12
  },
12
13
  }));
13
14
  // Mock the fetchAssociations function, keep utility functions
14
- jest.mock('../../../crm/utils/fetchAssociations', () => ({
15
- ...jest.requireActual('../../../crm/utils/fetchAssociations'),
16
- fetchAssociations: jest.fn(),
17
- }));
15
+ vi.mock('../../../crm/utils/fetchAssociations.ts', async (importOriginal) => {
16
+ const actual = (await importOriginal());
17
+ return {
18
+ ...actual,
19
+ fetchAssociations: vi.fn(),
20
+ };
21
+ });
18
22
  // Get reference to the mocked function
19
23
  const mockFetchAssociations = fetchAssociations;
20
24
  describe('useAssociations with Pagination', () => {
@@ -45,7 +49,7 @@ describe('useAssociations with Pagination', () => {
45
49
  hasMore: false,
46
50
  nextOffset: 0,
47
51
  },
48
- cleanup: jest.fn(),
52
+ cleanup: vi.fn(),
49
53
  });
50
54
  const { result } = renderHook(() => useAssociations({
51
55
  toObjectType: '0-1',
@@ -69,7 +73,7 @@ describe('useAssociations with Pagination', () => {
69
73
  hasMore: false,
70
74
  nextOffset: 0,
71
75
  },
72
- cleanup: jest.fn(),
76
+ cleanup: vi.fn(),
73
77
  });
74
78
  const { result } = renderHook(() => useAssociations({
75
79
  toObjectType: '0-1',
@@ -99,7 +103,7 @@ describe('useAssociations with Pagination', () => {
99
103
  hasMore: true,
100
104
  nextOffset: 10,
101
105
  },
102
- cleanup: jest.fn(),
106
+ cleanup: vi.fn(),
103
107
  });
104
108
  const { result } = renderHook(() => useAssociations({
105
109
  toObjectType: '0-1',
@@ -128,7 +132,7 @@ describe('useAssociations with Pagination', () => {
128
132
  hasMore: false,
129
133
  nextOffset: 0,
130
134
  },
131
- cleanup: jest.fn(),
135
+ cleanup: vi.fn(),
132
136
  });
133
137
  const { result } = renderHook(() => useAssociations({
134
138
  toObjectType: '0-1',
@@ -153,7 +157,7 @@ describe('useAssociations with Pagination', () => {
153
157
  hasMore: true,
154
158
  nextOffset: 10,
155
159
  },
156
- cleanup: jest.fn(),
160
+ cleanup: vi.fn(),
157
161
  });
158
162
  // Second page response
159
163
  mockFetchAssociations.mockResolvedValueOnce({
@@ -162,7 +166,7 @@ describe('useAssociations with Pagination', () => {
162
166
  hasMore: false,
163
167
  nextOffset: 20,
164
168
  },
165
- cleanup: jest.fn(),
169
+ cleanup: vi.fn(),
166
170
  });
167
171
  const { result } = renderHook(() => useAssociations({
168
172
  toObjectType: '0-1',
@@ -193,7 +197,7 @@ describe('useAssociations with Pagination', () => {
193
197
  hasMore: true,
194
198
  nextOffset: 10,
195
199
  },
196
- cleanup: jest.fn(),
200
+ cleanup: vi.fn(),
197
201
  });
198
202
  // Second call: page 2 with hasMore: false
199
203
  mockFetchAssociations.mockResolvedValueOnce({
@@ -202,7 +206,7 @@ describe('useAssociations with Pagination', () => {
202
206
  hasMore: false,
203
207
  nextOffset: 20,
204
208
  },
205
- cleanup: jest.fn(),
209
+ cleanup: vi.fn(),
206
210
  });
207
211
  // Third call: back to page 1
208
212
  mockFetchAssociations.mockResolvedValueOnce({
@@ -211,7 +215,7 @@ describe('useAssociations with Pagination', () => {
211
215
  hasMore: true,
212
216
  nextOffset: 10,
213
217
  },
214
- cleanup: jest.fn(),
218
+ cleanup: vi.fn(),
215
219
  });
216
220
  const { result } = renderHook(() => useAssociations({
217
221
  toObjectType: '0-1',
@@ -243,7 +247,7 @@ describe('useAssociations with Pagination', () => {
243
247
  hasMore: true,
244
248
  nextOffset: 10,
245
249
  },
246
- cleanup: jest.fn(),
250
+ cleanup: vi.fn(),
247
251
  });
248
252
  const { result } = renderHook(() => useAssociations({
249
253
  toObjectType: '0-1',
@@ -274,10 +278,10 @@ describe('useAssociations with Pagination', () => {
274
278
  mockFetchAssociations.mockResolvedValue({
275
279
  data: {
276
280
  results: [],
277
- hasMore: false,
281
+ hasMore: false, // No more pages
278
282
  nextOffset: 10,
279
283
  },
280
- cleanup: jest.fn(),
284
+ cleanup: vi.fn(),
281
285
  });
282
286
  const { result } = renderHook(() => useAssociations({
283
287
  toObjectType: '0-1',
@@ -320,7 +324,7 @@ describe('useAssociations with Pagination', () => {
320
324
  hasMore: false,
321
325
  nextOffset: 0,
322
326
  },
323
- cleanup: jest.fn(),
327
+ cleanup: vi.fn(),
324
328
  });
325
329
  // @ts-expect-error - intentional type issue to check the failure state
326
330
  const { result } = renderHook(() => useAssociations(null));
@@ -343,7 +347,7 @@ describe('useAssociations with Pagination', () => {
343
347
  hasMore: false,
344
348
  nextOffset: 0,
345
349
  },
346
- cleanup: jest.fn(),
350
+ cleanup: vi.fn(),
347
351
  });
348
352
  // @ts-expect-error - intentional type issue to check the failure state
349
353
  const { result } = renderHook(() => useAssociations(undefined));
@@ -366,7 +370,7 @@ describe('useAssociations with Pagination', () => {
366
370
  hasMore: false,
367
371
  nextOffset: 0,
368
372
  },
369
- cleanup: jest.fn(),
373
+ cleanup: vi.fn(),
370
374
  });
371
375
  // @ts-expect-error - intentional type issue to check the failure state
372
376
  const { result } = renderHook(() => useAssociations({}));
@@ -389,7 +393,7 @@ describe('useAssociations with Pagination', () => {
389
393
  hasMore: false,
390
394
  nextOffset: 0,
391
395
  },
392
- cleanup: jest.fn(),
396
+ cleanup: vi.fn(),
393
397
  });
394
398
  const { result } = renderHook(() =>
395
399
  // @ts-expect-error - intentional type issue to check the failure state
@@ -415,7 +419,7 @@ describe('useAssociations with Pagination', () => {
415
419
  hasMore: false,
416
420
  nextOffset: 0,
417
421
  },
418
- cleanup: jest.fn(),
422
+ cleanup: vi.fn(),
419
423
  });
420
424
  const { result } = renderHook(() => useAssociations({
421
425
  toObjectType: '0-1',
@@ -441,7 +445,7 @@ describe('useAssociations with Pagination', () => {
441
445
  hasMore: false,
442
446
  nextOffset: 0,
443
447
  },
444
- cleanup: jest.fn(),
448
+ cleanup: vi.fn(),
445
449
  });
446
450
  const config = {
447
451
  toObjectType: '0-1',
@@ -469,7 +473,7 @@ describe('useAssociations with Pagination', () => {
469
473
  hasMore: false,
470
474
  nextOffset: 0,
471
475
  },
472
- cleanup: jest.fn(),
476
+ cleanup: vi.fn(),
473
477
  });
474
478
  const config = {
475
479
  toObjectType: '0-1',
@@ -484,7 +488,7 @@ describe('useAssociations with Pagination', () => {
484
488
  });
485
489
  describe('lifecycle management', () => {
486
490
  it('should call cleanup function on unmount', async () => {
487
- const mockCleanup = jest.fn();
491
+ const mockCleanup = vi.fn();
488
492
  mockFetchAssociations.mockResolvedValue({
489
493
  data: {
490
494
  results: [],
@@ -514,7 +518,7 @@ describe('useAssociations with Pagination', () => {
514
518
  hasMore: false,
515
519
  nextOffset: 0,
516
520
  },
517
- cleanup: jest.fn(),
521
+ cleanup: vi.fn(),
518
522
  });
519
523
  const config = {
520
524
  toObjectType: '0-1',
@@ -1,18 +1,19 @@
1
1
  import { renderHook, waitFor } from '@testing-library/react';
2
- import { useCrmProperties } from '../../../crm/hooks/useCrmProperties';
2
+ import { vi } from 'vitest';
3
+ import { useCrmProperties } from "../../../crm/hooks/useCrmProperties.js";
4
+ import * as fetchCrmPropertiesModule from "../../../crm/utils/fetchCrmProperties.js";
3
5
  // Mock the logger module
4
- jest.mock('../../../logger', () => ({
6
+ vi.mock('../../../logger', () => ({
5
7
  logger: {
6
- debug: jest.fn(),
7
- info: jest.fn(),
8
- warn: jest.fn(),
9
- error: jest.fn(),
8
+ debug: vi.fn(),
9
+ info: vi.fn(),
10
+ warn: vi.fn(),
11
+ error: vi.fn(),
10
12
  },
11
13
  }));
12
14
  // Mock the fetchCrmProperties module
13
- jest.mock('../../../crm/utils/fetchCrmProperties');
14
- const mockFetchCrmProperties = jest.fn();
15
- import * as fetchCrmPropertiesModule from '../../../crm/utils/fetchCrmProperties';
15
+ vi.mock('../../../crm/utils/fetchCrmProperties');
16
+ const mockFetchCrmProperties = vi.fn();
16
17
  fetchCrmPropertiesModule.fetchCrmProperties = mockFetchCrmProperties;
17
18
  describe('useCrmProperties', () => {
18
19
  let originalError;
@@ -46,7 +47,7 @@ describe('useCrmProperties', () => {
46
47
  firstname: 'Test value for firstname',
47
48
  lastname: 'Test value for lastname',
48
49
  },
49
- cleanup: jest.fn(),
50
+ cleanup: vi.fn(),
50
51
  });
51
52
  const propertyNames = ['firstname', 'lastname'];
52
53
  const { result } = renderHook(() => useCrmProperties(propertyNames));
@@ -78,7 +79,7 @@ describe('useCrmProperties', () => {
78
79
  capturedCallback = propertiesUpdatedCallback;
79
80
  return {
80
81
  data: { firstname: 'Initial', lastname: 'Initial' },
81
- cleanup: jest.fn(),
82
+ cleanup: vi.fn(),
82
83
  };
83
84
  });
84
85
  const propertyNames = ['firstname', 'lastname'];
@@ -105,7 +106,7 @@ describe('useCrmProperties', () => {
105
106
  capturedCallback = propertiesUpdatedCallback;
106
107
  return {
107
108
  data: { firstname: 'Initial', lastname: null },
108
- cleanup: jest.fn(),
109
+ cleanup: vi.fn(),
109
110
  };
110
111
  });
111
112
  const propertyNames = ['firstname', 'lastname'];
@@ -132,7 +133,7 @@ describe('useCrmProperties', () => {
132
133
  firstname: 'John',
133
134
  lastname: 'Doe',
134
135
  },
135
- cleanup: jest.fn(),
136
+ cleanup: vi.fn(),
136
137
  });
137
138
  const propertyNames = ['firstname', 'lastname'];
138
139
  const options = {
@@ -148,7 +149,7 @@ describe('useCrmProperties', () => {
148
149
  data: {
149
150
  firstname: 'John',
150
151
  },
151
- cleanup: jest.fn(),
152
+ cleanup: vi.fn(),
152
153
  });
153
154
  const propertyNames = ['firstname'];
154
155
  const defaultOptions = {};
@@ -162,7 +163,7 @@ describe('useCrmProperties', () => {
162
163
  data: {
163
164
  firstname: 'John',
164
165
  },
165
- cleanup: jest.fn(),
166
+ cleanup: vi.fn(),
166
167
  });
167
168
  const propertyNames = ['firstname'];
168
169
  const initialOptions = { propertiesToFormat: ['firstname'] };
@@ -181,7 +182,7 @@ describe('useCrmProperties', () => {
181
182
  data: {
182
183
  firstname: 'John',
183
184
  },
184
- cleanup: jest.fn(),
185
+ cleanup: vi.fn(),
185
186
  });
186
187
  const propertyNames = ['firstname'];
187
188
  const initialOptions = { propertiesToFormat: ['firstname'] };
@@ -201,7 +202,7 @@ describe('useCrmProperties', () => {
201
202
  });
202
203
  });
203
204
  it('should call cleanup function when component unmounts', async () => {
204
- const mockCleanup = jest.fn();
205
+ const mockCleanup = vi.fn();
205
206
  mockFetchCrmProperties.mockResolvedValue({
206
207
  data: {
207
208
  firstname: 'John',
@@ -217,8 +218,8 @@ describe('useCrmProperties', () => {
217
218
  expect(mockCleanup).toHaveBeenCalledTimes(1);
218
219
  });
219
220
  it('should call cleanup function when dependencies change', async () => {
220
- const mockCleanup1 = jest.fn();
221
- const mockCleanup2 = jest.fn();
221
+ const mockCleanup1 = vi.fn();
222
+ const mockCleanup2 = vi.fn();
222
223
  mockFetchCrmProperties
223
224
  .mockResolvedValueOnce({
224
225
  data: { firstname: 'John' },
@@ -1,5 +1,6 @@
1
+ import { vi } from 'vitest';
1
2
  // Set up the mock before importing the module
2
- const mockFetchAssociations = jest.fn();
3
+ const mockFetchAssociations = vi.fn();
3
4
  const mockSelf = {
4
5
  fetchAssociations: mockFetchAssociations,
5
6
  };
@@ -8,18 +9,18 @@ Object.defineProperty(global, 'self', {
8
9
  value: mockSelf,
9
10
  writable: true,
10
11
  });
11
- import { fetchAssociations, calculatePaginationFlags, } from '../../../crm/utils/fetchAssociations';
12
+ import { fetchAssociations, calculatePaginationFlags, } from "../../../crm/utils/fetchAssociations.js";
12
13
  describe('fetchAssociations', () => {
13
14
  // Helper functions
14
15
  const createMockResponse = (data, overrides = {}) => ({
15
16
  ok: true,
16
- json: jest.fn().mockResolvedValue({ data, cleanup: jest.fn() }),
17
+ json: vi.fn().mockResolvedValue({ data, cleanup: vi.fn() }),
17
18
  ...overrides,
18
19
  });
19
20
  const createErrorResponse = (statusText) => ({
20
21
  ok: false,
21
22
  statusText,
22
- json: jest.fn().mockResolvedValue({}),
23
+ json: vi.fn().mockResolvedValue({}),
23
24
  });
24
25
  const expectError = async (request, expectedMessage) => {
25
26
  await expect(fetchAssociations(request)).rejects.toThrow(expectedMessage);
@@ -30,7 +31,7 @@ describe('fetchAssociations', () => {
30
31
  ...overrides,
31
32
  });
32
33
  beforeEach(() => {
33
- jest.clearAllMocks();
34
+ vi.clearAllMocks();
34
35
  // Set up dynamic mock that responds to request parameters
35
36
  mockFetchAssociations.mockImplementation((request) => {
36
37
  const { pageLength = 100, offset = 0, properties = [] } = request;
@@ -61,7 +62,7 @@ describe('fetchAssociations', () => {
61
62
  ];
62
63
  const mockData = {
63
64
  results: mockResults,
64
- hasMore: offset < 200,
65
+ hasMore: offset < 200, // Has more until offset 200
65
66
  nextOffset: offset + pageLength,
66
67
  };
67
68
  return Promise.resolve(createMockResponse(mockData));
@@ -210,7 +211,7 @@ describe('fetchAssociations', () => {
210
211
  });
211
212
  it('should handle different object types', async () => {
212
213
  const request = createBasicRequest({
213
- toObjectType: '0-2',
214
+ toObjectType: '0-2', // Company
214
215
  properties: ['name'],
215
216
  });
216
217
  const result = await fetchAssociations(request);
@@ -250,7 +251,7 @@ describe('fetchAssociations', () => {
250
251
  });
251
252
  it('should throw error for invalid association result structure', async () => {
252
253
  const invalidData = {
253
- results: [{ invalidStructure: true }],
254
+ results: [{ invalidStructure: true }], // missing required fields
254
255
  hasMore: false,
255
256
  nextOffset: 0,
256
257
  };
@@ -263,7 +264,7 @@ describe('fetchAssociations', () => {
263
264
  results: [
264
265
  {
265
266
  toObjectId: 1000,
266
- associationTypes: 'not an array',
267
+ associationTypes: 'not an array', // should be array
267
268
  properties: {},
268
269
  },
269
270
  ],
@@ -296,12 +297,12 @@ describe('fetchAssociations', () => {
296
297
  expect(mockFetchAssociations).toHaveBeenCalledWith(request, undefined);
297
298
  });
298
299
  it('should return cleanup function from API response', async () => {
299
- const mockCleanup = jest.fn();
300
+ const mockCleanup = vi.fn();
300
301
  const emptyData = { results: [], hasMore: false, nextOffset: 0 };
301
302
  const mockApiResponse = { data: emptyData, cleanup: mockCleanup };
302
303
  mockFetchAssociations.mockResolvedValueOnce({
303
304
  ok: true,
304
- json: jest.fn().mockResolvedValue(mockApiResponse),
305
+ json: vi.fn().mockResolvedValue(mockApiResponse),
305
306
  });
306
307
  const result = await fetchAssociations(createBasicRequest());
307
308
  expect(result.cleanup).toBe(mockCleanup);
@@ -313,7 +314,7 @@ describe('fetchAssociations', () => {
313
314
  const mockApiResponse = { data: emptyData }; // no cleanup function provided
314
315
  mockFetchAssociations.mockResolvedValueOnce({
315
316
  ok: true,
316
- json: jest.fn().mockResolvedValue(mockApiResponse),
317
+ json: vi.fn().mockResolvedValue(mockApiResponse),
317
318
  });
318
319
  const result = await fetchAssociations(createBasicRequest());
319
320
  expect(typeof result.cleanup).toBe('function');
@@ -1,5 +1,6 @@
1
+ import { vi } from 'vitest';
1
2
  // Set up the mock before importing the module
2
- const mockFetchCrmProperties = jest.fn();
3
+ const mockFetchCrmProperties = vi.fn();
3
4
  const mockSelf = {
4
5
  fetchCrmProperties: mockFetchCrmProperties,
5
6
  };
@@ -8,11 +9,11 @@ Object.defineProperty(global, 'self', {
8
9
  value: mockSelf,
9
10
  writable: true,
10
11
  });
11
- import { fetchCrmProperties } from '../../../crm/utils/fetchCrmProperties';
12
+ import { fetchCrmProperties } from "../../../crm/utils/fetchCrmProperties.js";
12
13
  const DEFAULT_OPTIONS = {};
13
14
  describe('fetchCrmProperties', () => {
14
15
  beforeEach(() => {
15
- jest.clearAllMocks();
16
+ vi.clearAllMocks();
16
17
  });
17
18
  it('successfully fetches CRM properties', async () => {
18
19
  const mockApiResponse = {
@@ -20,15 +21,15 @@ describe('fetchCrmProperties', () => {
20
21
  firstname: 'Test value for firstname',
21
22
  lastname: 'Test value for lastname',
22
23
  },
23
- cleanup: jest.fn(),
24
+ cleanup: vi.fn(),
24
25
  };
25
26
  const mockResponse = {
26
27
  ok: true,
27
- json: jest.fn().mockResolvedValue(mockApiResponse),
28
+ json: vi.fn().mockResolvedValue(mockApiResponse),
28
29
  };
29
30
  mockFetchCrmProperties.mockResolvedValue(mockResponse);
30
31
  const propertyNames = ['firstname', 'lastname'];
31
- const result = await fetchCrmProperties(propertyNames, jest.fn(), DEFAULT_OPTIONS);
32
+ const result = await fetchCrmProperties(propertyNames, vi.fn(), DEFAULT_OPTIONS);
32
33
  expect(mockFetchCrmProperties).toHaveBeenCalledWith(propertyNames, expect.any(Function), DEFAULT_OPTIONS);
33
34
  expect(result).toEqual({
34
35
  data: {
@@ -46,15 +47,15 @@ describe('fetchCrmProperties', () => {
46
47
  email: 'john@example.com',
47
48
  phone: null,
48
49
  },
49
- cleanup: jest.fn(),
50
+ cleanup: vi.fn(),
50
51
  };
51
52
  const mockResponse = {
52
53
  ok: true,
53
- json: jest.fn().mockResolvedValue(mockApiResponse),
54
+ json: vi.fn().mockResolvedValue(mockApiResponse),
54
55
  };
55
56
  mockFetchCrmProperties.mockResolvedValue(mockResponse);
56
57
  const propertyNames = ['firstname', 'lastname', 'email', 'phone'];
57
- const result = await fetchCrmProperties(propertyNames, jest.fn(), DEFAULT_OPTIONS);
58
+ const result = await fetchCrmProperties(propertyNames, vi.fn(), DEFAULT_OPTIONS);
58
59
  expect(mockFetchCrmProperties).toHaveBeenCalledWith(propertyNames, expect.any(Function), DEFAULT_OPTIONS);
59
60
  expect(result).toEqual({
60
61
  data: {
@@ -70,46 +71,46 @@ describe('fetchCrmProperties', () => {
70
71
  const mockResponse = {
71
72
  ok: false,
72
73
  statusText: 'Not Found',
73
- json: jest.fn().mockResolvedValue({}),
74
+ json: vi.fn().mockResolvedValue({}),
74
75
  };
75
76
  mockFetchCrmProperties.mockResolvedValue(mockResponse);
76
77
  const propertyNames = ['firstname'];
77
- await expect(fetchCrmProperties(propertyNames, jest.fn(), DEFAULT_OPTIONS)).rejects.toThrow('Failed to fetch CRM properties: Not Found');
78
+ await expect(fetchCrmProperties(propertyNames, vi.fn(), DEFAULT_OPTIONS)).rejects.toThrow('Failed to fetch CRM properties: Not Found');
78
79
  });
79
80
  it('throws an error when fetch fails', async () => {
80
81
  mockFetchCrmProperties.mockRejectedValue(new Error('Network error'));
81
82
  const propertyNames = ['firstname'];
82
- await expect(fetchCrmProperties(propertyNames, jest.fn(), DEFAULT_OPTIONS)).rejects.toThrow('Network error');
83
+ await expect(fetchCrmProperties(propertyNames, vi.fn(), DEFAULT_OPTIONS)).rejects.toThrow('Network error');
83
84
  });
84
85
  it('throws an error if the response is not an object', async () => {
85
86
  const mockApiResponse = {
86
- data: 'Invalid response',
87
- cleanup: jest.fn(),
87
+ data: 'Invalid response', // data should be an object
88
+ cleanup: vi.fn(),
88
89
  };
89
90
  const mockResponse = {
90
91
  ok: true,
91
- json: jest.fn().mockResolvedValue(mockApiResponse),
92
+ json: vi.fn().mockResolvedValue(mockApiResponse),
92
93
  };
93
94
  mockFetchCrmProperties.mockResolvedValue(mockResponse);
94
95
  const propertyNames = ['firstname'];
95
- await expect(fetchCrmProperties(propertyNames, jest.fn(), DEFAULT_OPTIONS)).rejects.toThrow('Invalid response format');
96
+ await expect(fetchCrmProperties(propertyNames, vi.fn(), DEFAULT_OPTIONS)).rejects.toThrow('Invalid response format');
96
97
  });
97
98
  it('throws an error if response contains invalid property values', async () => {
98
99
  const mockApiResponse = {
99
100
  data: {
100
101
  firstname: 'John',
101
- lastname: 123,
102
+ lastname: 123, // Invalid: should be string or null
102
103
  email: 'john@example.com',
103
104
  },
104
- cleanup: jest.fn(),
105
+ cleanup: vi.fn(),
105
106
  };
106
107
  const mockResponse = {
107
108
  ok: true,
108
- json: jest.fn().mockResolvedValue(mockApiResponse),
109
+ json: vi.fn().mockResolvedValue(mockApiResponse),
109
110
  };
110
111
  mockFetchCrmProperties.mockResolvedValue(mockResponse);
111
112
  const propertyNames = ['firstname', 'lastname', 'email'];
112
- await expect(fetchCrmProperties(propertyNames, jest.fn(), DEFAULT_OPTIONS)).rejects.toThrow('Invalid response format');
113
+ await expect(fetchCrmProperties(propertyNames, vi.fn(), DEFAULT_OPTIONS)).rejects.toThrow('Invalid response format');
113
114
  });
114
115
  it('passes the propertiesUpdatedCallback and allows it to be called', async () => {
115
116
  let capturedCallback;
@@ -118,18 +119,18 @@ describe('fetchCrmProperties', () => {
118
119
  firstname: 'Initial',
119
120
  lastname: 'Initial',
120
121
  },
121
- cleanup: jest.fn(),
122
+ cleanup: vi.fn(),
122
123
  };
123
124
  const mockResponse = {
124
125
  ok: true,
125
- json: jest.fn().mockResolvedValue(mockApiResponse),
126
+ json: vi.fn().mockResolvedValue(mockApiResponse),
126
127
  };
127
128
  mockFetchCrmProperties.mockImplementation((propertyNames, callback) => {
128
129
  capturedCallback = callback;
129
130
  return Promise.resolve(mockResponse);
130
131
  });
131
132
  const propertyNames = ['firstname', 'lastname'];
132
- const mockCallback = jest.fn();
133
+ const mockCallback = vi.fn();
133
134
  await fetchCrmProperties(propertyNames, mockCallback, DEFAULT_OPTIONS);
134
135
  expect(typeof capturedCallback).toBe('function');
135
136
  // Simulate the callback being called with new properties
@@ -146,18 +147,18 @@ describe('fetchCrmProperties', () => {
146
147
  firstname: 'Initial',
147
148
  lastname: null,
148
149
  },
149
- cleanup: jest.fn(),
150
+ cleanup: vi.fn(),
150
151
  };
151
152
  const mockResponse = {
152
153
  ok: true,
153
- json: jest.fn().mockResolvedValue(mockApiResponse),
154
+ json: vi.fn().mockResolvedValue(mockApiResponse),
154
155
  };
155
156
  mockFetchCrmProperties.mockImplementation((propertyNames, callback) => {
156
157
  capturedCallback = callback;
157
158
  return Promise.resolve(mockResponse);
158
159
  });
159
160
  const propertyNames = ['firstname', 'lastname'];
160
- const mockCallback = jest.fn();
161
+ const mockCallback = vi.fn();
161
162
  await fetchCrmProperties(propertyNames, mockCallback, DEFAULT_OPTIONS);
162
163
  expect(typeof capturedCallback).toBe('function');
163
164
  // Simulate the callback being called with new properties including null values
@@ -173,11 +174,11 @@ describe('fetchCrmProperties', () => {
173
174
  firstname: 'John',
174
175
  lastname: 'Doe',
175
176
  },
176
- cleanup: jest.fn(),
177
+ cleanup: vi.fn(),
177
178
  };
178
179
  const mockResponse = {
179
180
  ok: true,
180
- json: jest.fn().mockResolvedValue(mockApiResponse),
181
+ json: vi.fn().mockResolvedValue(mockApiResponse),
181
182
  };
182
183
  mockFetchCrmProperties.mockResolvedValue(mockResponse);
183
184
  const propertyNames = ['firstname', 'lastname'];
@@ -192,7 +193,7 @@ describe('fetchCrmProperties', () => {
192
193
  },
193
194
  },
194
195
  };
195
- await fetchCrmProperties(propertyNames, jest.fn(), options);
196
+ await fetchCrmProperties(propertyNames, vi.fn(), options);
196
197
  expect(mockFetchCrmProperties).toHaveBeenCalledWith(propertyNames, expect.any(Function), options);
197
198
  });
198
199
  it('preserves error handling with formatting options', async () => {
@@ -206,27 +207,27 @@ describe('fetchCrmProperties', () => {
206
207
  },
207
208
  },
208
209
  };
209
- await expect(fetchCrmProperties(propertyNames, jest.fn(), options)).rejects.toThrow('Network error');
210
+ await expect(fetchCrmProperties(propertyNames, vi.fn(), options)).rejects.toThrow('Network error');
210
211
  expect(mockFetchCrmProperties).toHaveBeenCalledWith(propertyNames, expect.any(Function), options);
211
212
  });
212
213
  it('preserves response validation with formatting options', async () => {
213
214
  const mockApiResponse = {
214
- data: 'Invalid response',
215
- cleanup: jest.fn(),
215
+ data: 'Invalid response', // data should be an object
216
+ cleanup: vi.fn(),
216
217
  };
217
218
  const mockResponse = {
218
219
  ok: true,
219
- json: jest.fn().mockResolvedValue(mockApiResponse),
220
+ json: vi.fn().mockResolvedValue(mockApiResponse),
220
221
  };
221
222
  mockFetchCrmProperties.mockResolvedValue(mockResponse);
222
223
  const propertyNames = ['firstname'];
223
224
  const options = {
224
225
  propertiesToFormat: 'all',
225
226
  };
226
- await expect(fetchCrmProperties(propertyNames, jest.fn(), options)).rejects.toThrow('Invalid response format');
227
+ await expect(fetchCrmProperties(propertyNames, vi.fn(), options)).rejects.toThrow('Invalid response format');
227
228
  });
228
229
  it('returns cleanup function that can be called', async () => {
229
- const mockCleanup = jest.fn();
230
+ const mockCleanup = vi.fn();
230
231
  const mockApiResponse = {
231
232
  data: {
232
233
  firstname: 'John',
@@ -235,11 +236,11 @@ describe('fetchCrmProperties', () => {
235
236
  };
236
237
  const mockResponse = {
237
238
  ok: true,
238
- json: jest.fn().mockResolvedValue(mockApiResponse),
239
+ json: vi.fn().mockResolvedValue(mockApiResponse),
239
240
  };
240
241
  mockFetchCrmProperties.mockResolvedValue(mockResponse);
241
242
  const propertyNames = ['firstname'];
242
- const result = await fetchCrmProperties(propertyNames, jest.fn(), DEFAULT_OPTIONS);
243
+ const result = await fetchCrmProperties(propertyNames, vi.fn(), DEFAULT_OPTIONS);
243
244
  expect(result.cleanup).toBe(mockCleanup);
244
245
  expect(typeof result.cleanup).toBe('function');
245
246
  // Verify cleanup can be called without errors
@@ -38,3 +38,4 @@ declare module '*?inline' {
38
38
  const src: string;
39
39
  export default src;
40
40
  }
41
+ export {};
@@ -1 +1 @@
1
- "use strict";
1
+ export {};