@rebilly/instruments 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/.babelrc +24 -26
  2. package/CHANGELOG.md +7 -0
  3. package/dist/index.js +8 -8
  4. package/dist/index.min.js +8 -8
  5. package/package.json +14 -3
  6. package/project.json +9 -0
  7. package/rollup.config.mjs +21 -26
  8. package/src/data/options-schema/index.js +94 -78
  9. package/src/data/options-schema/schemas/options-schema.js +419 -411
  10. package/src/events/base-event.js +34 -34
  11. package/src/events/events.spec.js +6 -6
  12. package/src/events/index.js +5 -5
  13. package/src/functions/destroy.js +19 -19
  14. package/src/functions/destroy.spec.js +41 -41
  15. package/src/functions/mount/fetch-data.js +200 -193
  16. package/src/functions/mount/fetch-data.spec.js +287 -285
  17. package/src/functions/mount/get-lead-source-data.js +31 -31
  18. package/src/functions/mount/get-lead-source-data.spec.js +19 -19
  19. package/src/functions/mount/index.js +73 -65
  20. package/src/functions/mount/mount.spec.js +77 -66
  21. package/src/functions/mount/setup-element.js +23 -23
  22. package/src/functions/mount/setup-framepay-theme.js +86 -68
  23. package/src/functions/mount/setup-framepay.js +9 -5
  24. package/src/functions/mount/setup-i18n.js +15 -15
  25. package/src/functions/mount/setup-options.js +74 -74
  26. package/src/functions/mount/setup-options.spec.js +323 -287
  27. package/src/functions/mount/setup-storefront.js +15 -20
  28. package/src/functions/mount/setup-styles-vars.js +19 -22
  29. package/src/functions/mount/setup-user-flow.js +51 -47
  30. package/src/functions/on.js +5 -5
  31. package/src/functions/on.spec.js +60 -51
  32. package/src/functions/purchase.js +151 -146
  33. package/src/functions/purchase.spec.js +59 -56
  34. package/src/functions/setup.js +53 -53
  35. package/src/functions/setup.spec.js +88 -75
  36. package/src/functions/show.js +13 -14
  37. package/src/functions/show.spec.js +53 -53
  38. package/src/functions/update.js +30 -28
  39. package/src/functions/update.spec.js +94 -93
  40. package/src/i18n/en.json +32 -32
  41. package/src/i18n/es.json +29 -29
  42. package/src/i18n/i18n.spec.js +18 -18
  43. package/src/i18n/index.js +48 -48
  44. package/src/instance.js +36 -36
  45. package/src/instance.spec.js +29 -27
  46. package/src/loader/index.js +95 -70
  47. package/src/loader/loader.spec.js +63 -63
  48. package/src/state/iframes.js +21 -21
  49. package/src/state/index.js +56 -54
  50. package/src/storefront/account-and-website.js +10 -8
  51. package/src/storefront/account-and-website.spec.js +55 -55
  52. package/src/storefront/deposit-requests.js +6 -6
  53. package/src/storefront/fetch-plans-from-addons-bumpOffer.js +21 -19
  54. package/src/storefront/fetch-products-from-plans.js +52 -51
  55. package/src/storefront/fetch-products-from-plans.spec.js +90 -87
  56. package/src/storefront/index.js +56 -49
  57. package/src/storefront/invoices.js +15 -15
  58. package/src/storefront/invoices.spec.js +69 -65
  59. package/src/storefront/models/account-model.js +29 -32
  60. package/src/storefront/models/base-model.js +6 -9
  61. package/src/storefront/models/deposit-request-model.js +22 -13
  62. package/src/storefront/models/invoice-model.js +16 -16
  63. package/src/storefront/models/payment-metadata.js +4 -4
  64. package/src/storefront/models/plan-model.js +73 -64
  65. package/src/storefront/models/ready-to-pay-model.js +59 -59
  66. package/src/storefront/models/summary-model.js +43 -46
  67. package/src/storefront/models/transaction-model.js +11 -14
  68. package/src/storefront/payment-instruments.js +38 -35
  69. package/src/storefront/payment-instruments.spec.js +81 -62
  70. package/src/storefront/purchase.js +50 -44
  71. package/src/storefront/purchase.spec.js +40 -40
  72. package/src/storefront/ready-to-pay.js +75 -77
  73. package/src/storefront/ready-to-pay.spec.js +59 -54
  74. package/src/storefront/storefront.spec.js +9 -9
  75. package/src/storefront/summary.js +93 -67
  76. package/src/storefront/summary.spec.js +108 -106
  77. package/src/storefront/transactions.js +6 -6
  78. package/src/style/base/default-theme.js +928 -923
  79. package/src/style/base/theme.js +21 -21
  80. package/src/style/base/theme.spec.js +13 -13
  81. package/src/style/index.js +3 -3
  82. package/src/style/utils/border.js +40 -27
  83. package/src/style/utils/color-values.js +18 -18
  84. package/src/style/utils/minifyCss.js +6 -6
  85. package/src/utils/add-dom-element.js +14 -14
  86. package/src/utils/format-currency.js +6 -5
  87. package/src/utils/has-valid-css-selector.js +2 -2
  88. package/src/utils/index.js +6 -6
  89. package/src/utils/is-dom-element.js +1 -1
  90. package/src/utils/process-property-as-dom-element.js +22 -22
  91. package/src/utils/quantity.js +26 -28
  92. package/src/utils/sleep.js +3 -1
  93. package/src/views/amount-selector.js +37 -36
  94. package/src/views/common/iframe/base-iframe.js +53 -52
  95. package/src/views/common/iframe/events/change-iframe-src-handler.js +5 -5
  96. package/src/views/common/iframe/events/dispatch-event-handler.js +4 -4
  97. package/src/views/common/iframe/events/resize-component-handler.js +8 -8
  98. package/src/views/common/iframe/events/show-error-handler.js +2 -2
  99. package/src/views/common/iframe/events/stop-loader-handler.js +8 -8
  100. package/src/views/common/iframe/events/update-addons-handler.js +20 -13
  101. package/src/views/common/iframe/events/update-coupons-handler.js +9 -9
  102. package/src/views/common/iframe/events/update-items-handler.js +26 -22
  103. package/src/views/common/iframe/modal-iframe.js +67 -56
  104. package/src/views/common/iframe/view-iframe.js +11 -11
  105. package/src/views/common/render-utilities.js +2 -2
  106. package/src/views/confirmation.js +33 -30
  107. package/src/views/errors.js +89 -79
  108. package/src/views/form.js +41 -37
  109. package/src/views/method-selector/express-methods.js +46 -46
  110. package/src/views/method-selector/generate-digital-wallet.js +46 -45
  111. package/src/views/method-selector/generate-digital-wallet.spec.js +104 -102
  112. package/src/views/method-selector/generate-framepay-config.js +53 -51
  113. package/src/views/method-selector/generate-framepay-config.spec.js +197 -173
  114. package/src/views/method-selector/get-method-data.js +5 -6
  115. package/src/views/method-selector/get-payment-methods.js +18 -16
  116. package/src/views/method-selector/get-payment-methods.spec.js +29 -27
  117. package/src/views/method-selector/index.js +154 -139
  118. package/src/views/method-selector/method-selector.spec.js +13 -13
  119. package/src/views/method-selector/mount-bump-offer.js +65 -49
  120. package/src/views/method-selector/mount-express-methods.js +89 -85
  121. package/src/views/modal.js +74 -67
  122. package/src/views/result.js +14 -14
  123. package/src/views/summary.js +25 -26
  124. package/tests/async-utilities.js +13 -13
  125. package/tests/mocks/framepay-mock.js +9 -8
  126. package/tests/mocks/rebilly-api-mock.js +5 -3
  127. package/tests/mocks/rebilly-instruments-mock.js +121 -117
  128. package/tests/mocks/storefront-api-mock.js +55 -48
  129. package/tests/mocks/storefront-mock.js +10 -14
  130. package/tests/msw/server.js +6 -6
  131. package/tests/setup-test.js +14 -16
  132. package/vitest.config.js +14 -14
  133. package/.eslintrc.js +0 -34
  134. package/.prettierrc.js +0 -11
@@ -1,103 +1,107 @@
1
1
  import mountExpressMethod from './express-methods';
2
- import {generateFramepayConfig} from './generate-framepay-config'
2
+ import { generateFramepayConfig } from './generate-framepay-config';
3
3
  import { getMethodData } from './get-method-data';
4
4
  import Events from '../../events';
5
5
  import state from '../../state';
6
6
 
7
7
  const browserIsSafari = () => window.ApplePaySession;
8
8
 
9
- export async function mountExpressMethods({
10
- methods,
11
- container
12
- }) {
13
- const methodIds = methods.map((expressMethod) => {
14
- const { METHOD_ID } = getMethodData(expressMethod);
15
- return METHOD_ID
16
- });
17
- const {Rebilly} = window;
18
-
19
- if(!Rebilly?.initialized) {
20
- await Rebilly?.initialize(
21
- generateFramepayConfig({
22
- methodIds
23
- })
24
- );
25
- }
26
-
27
- function generateExpressMethodHeight(method) {
28
- let height;
29
- const optionId = method.optionsPaymentInstrumentsKey;
30
-
31
- // Return the default size of express methods if no id is found
32
- if (!optionId) return '48px';
33
-
34
- const {buttonHeight, displayOptions} = state.options.paymentInstruments?.[optionId];
35
-
36
- if (displayOptions) {
37
- height = displayOptions.buttonHeight;
38
- } else {
39
- height = buttonHeight;
9
+ export async function mountExpressMethods({ methods, container }) {
10
+ const methodIds = methods.map((expressMethod) => {
11
+ const { METHOD_ID } = getMethodData(expressMethod);
12
+ return METHOD_ID;
13
+ });
14
+ const { Rebilly } = window;
15
+
16
+ if (!Rebilly?.initialized) {
17
+ await Rebilly?.initialize(
18
+ generateFramepayConfig({
19
+ methodIds,
20
+ }),
21
+ );
40
22
  }
41
-
42
- if (typeof height === 'number') {
43
- height = `${buttonHeight}px`;
23
+
24
+ function generateExpressMethodHeight(method) {
25
+ let height;
26
+ const optionId = method.optionsPaymentInstrumentsKey;
27
+
28
+ // Return the default size of express methods if no id is found
29
+ if (!optionId) return '48px';
30
+
31
+ const { buttonHeight, displayOptions } =
32
+ state.options?.paymentInstruments?.[optionId] || {};
33
+
34
+ if (displayOptions) {
35
+ height = displayOptions.buttonHeight;
36
+ } else {
37
+ height = buttonHeight;
38
+ }
39
+
40
+ if (typeof height === 'number') {
41
+ height = `${buttonHeight}px`;
42
+ }
43
+
44
+ return height;
44
45
  }
45
-
46
- return height;
47
- }
48
46
 
49
- methods.forEach(method => {
50
- const {METHOD_ID: id} = getMethodData(method);
51
- // filter out apple pay unless in safari
52
- if (id === 'apple-pay' && !browserIsSafari()) return
47
+ methods.forEach((method) => {
48
+ const { METHOD_ID: id } = getMethodData(method);
49
+ // filter out apple pay unless in safari
50
+ if (id === 'apple-pay' && !browserIsSafari()) return;
53
51
 
54
- container.innerHTML += `
55
- <div class="rebilly-instruments-${id}-method" style="height: ${generateExpressMethodHeight(method)}"></div>
52
+ container.innerHTML += `
53
+ <div class="rebilly-instruments-${id}-method" style="height: ${generateExpressMethodHeight(
54
+ method,
55
+ )}"></div>
56
56
  `;
57
- mountExpressMethod({
58
- state,
59
- id,
57
+ mountExpressMethod({
58
+ state,
59
+ id,
60
+ });
60
61
  });
61
- });
62
-
63
- // HOTFIX: Hardcoded, use env variables in the future
64
- const redirectUrl = state.options.apiMode === 'sandbox'
65
- ? 'https://forms-sandbox.secure-payments.app/approval-url?close=true'
66
- : 'https://forms.secure-payments.app/approval-url?close=true';
67
-
68
- Rebilly?.on('token-ready', (token) => {
69
- const instrumentReadyPayload = {
70
- websiteId: state.options.websiteId,
71
- billingAddress: token.billingAddress,
72
- redirectUrl,
73
- _raw: token
74
- };
75
-
76
- if (state.data?.isShippingRequired) {
77
- if (token.shippingAddress) {
78
- instrumentReadyPayload.deliveryAddress = token.shippingAddress;
79
- } else {
80
- instrumentReadyPayload.deliveryAddress = instrumentReadyPayload.billingAddress;
81
- }
82
- }
83
62
 
84
- if (Array.isArray(instrumentReadyPayload.billingAddress?.emails)) {
85
- const email = instrumentReadyPayload.billingAddress.emails
86
- .find(e => e.label === 'main')
63
+ // HOTFIX: Hardcoded, use env variables in the future
64
+ const redirectUrl =
65
+ state.options.apiMode === 'sandbox'
66
+ ? 'https://forms-sandbox.secure-payments.app/approval-url?close=true'
67
+ : 'https://forms.secure-payments.app/approval-url?close=true';
87
68
 
88
- if (email?.value) {
89
- instrumentReadyPayload.billingAddress.email = email.value;
90
- }
91
- }
92
- if (Array.isArray(instrumentReadyPayload.deliveryAddress?.emails)) {
93
- const email = instrumentReadyPayload.deliveryAddress.emails
94
- .find(e => e.label === 'main')
69
+ Rebilly?.on('token-ready', (token) => {
70
+ const instrumentReadyPayload = {
71
+ websiteId: state.options.websiteId,
72
+ billingAddress: token.billingAddress,
73
+ redirectUrl,
74
+ _raw: token,
75
+ };
95
76
 
96
- if (email?.value) {
97
- instrumentReadyPayload.deliveryAddress.email = email.value;
98
- }
99
- }
77
+ if (state.data?.isShippingRequired) {
78
+ if (token.shippingAddress) {
79
+ instrumentReadyPayload.deliveryAddress = token.shippingAddress;
80
+ } else {
81
+ instrumentReadyPayload.deliveryAddress =
82
+ instrumentReadyPayload.billingAddress;
83
+ }
84
+ }
85
+
86
+ if (Array.isArray(instrumentReadyPayload.billingAddress?.emails)) {
87
+ const email = instrumentReadyPayload.billingAddress.emails.find(
88
+ (e) => e.label === 'main',
89
+ );
100
90
 
101
- Events.instrumentReady.dispatch(instrumentReadyPayload);
102
- });
91
+ if (email?.value) {
92
+ instrumentReadyPayload.billingAddress.email = email.value;
93
+ }
94
+ }
95
+ if (Array.isArray(instrumentReadyPayload.deliveryAddress?.emails)) {
96
+ const email = instrumentReadyPayload.deliveryAddress.emails.find(
97
+ (e) => e.label === 'main',
98
+ );
99
+
100
+ if (email?.value) {
101
+ instrumentReadyPayload.deliveryAddress.email = email.value;
102
+ }
103
+ }
104
+
105
+ Events.instrumentReady.dispatch(instrumentReadyPayload);
106
+ });
103
107
  }
@@ -4,93 +4,100 @@ import { ModalIframe } from './common/iframe';
4
4
  const modalTemplate = (isRedirect, method) => `
5
5
  <div class="rebilly-instruments-modal-overlay">
6
6
  <div class="rebilly-instruments-modal-container ${
7
- method ? `rebilly-instruments-${method}` : ''
7
+ method ? `rebilly-instruments-${method}` : ''
8
8
  } ${isRedirect ? 'is-redirect' : ''}">
9
- ${isRedirect ? '' : `
9
+ ${
10
+ isRedirect
11
+ ? ''
12
+ : `
10
13
  <svg class="rebilly-instruments-modal-close" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg">
11
14
  <path d="m15 13.5858 7.2929-7.293c.3905-.3904 1.0237-.3904 1.4142 0 .3905.3906.3905 1.0238 0 1.4143L16.4142 15l7.293 7.2929c.3904.3905.3904 1.0237 0 1.4142-.3906.3905-1.0238.3905-1.4143 0L15 16.4142l-7.2929 7.293c-.3905.3904-1.0237.3904-1.4142 0-.3905-.3906-.3905-1.0238 0-1.4143L13.5858 15l-7.293-7.2929c-.3904-.3905-.3904-1.0237 0-1.4142.3906-.3905 1.0238-.3905 1.4143 0L15 13.5858Z" fill-rule="nonzero"/>
12
15
  </svg>
13
- `}
16
+ `
17
+ }
14
18
  <div class="rebilly-instruments-modal-content"></div>
15
19
  </div>
16
20
  </div>
17
21
  `;
18
22
 
19
23
  export async function mountModal({
20
- name = '',
21
- url = '',
22
- model = {},
23
- classListArray = [],
24
- close = () => {},
24
+ name = '',
25
+ url = '',
26
+ model = {},
27
+ classListArray = [],
28
+ close = () => {},
25
29
  } = {}) {
26
- const method = model?.method?.method;
27
- const isRedirect = name === 'rebilly-instruments-approval-url';
28
- state.form.insertAdjacentHTML('beforeend', modalTemplate(isRedirect, method));
30
+ const method = model?.method?.method;
31
+ const isRedirect = name === 'rebilly-instruments-approval-url';
32
+ state.form.insertAdjacentHTML(
33
+ 'beforeend',
34
+ modalTemplate(isRedirect, method),
35
+ );
29
36
 
30
- const modalOverlay = document.querySelector(
31
- '.rebilly-instruments-modal-overlay'
32
- );
33
- const modalContainer = document.querySelector(
34
- '.rebilly-instruments-modal-container'
35
- );
36
- const closeButton = document.querySelector(
37
- '.rebilly-instruments-modal-close'
38
- );
39
- const modalContent = document.querySelector(
40
- '.rebilly-instruments-modal-content'
41
- );
37
+ const modalOverlay = document.querySelector(
38
+ '.rebilly-instruments-modal-overlay',
39
+ );
40
+ const modalContainer = document.querySelector(
41
+ '.rebilly-instruments-modal-container',
42
+ );
43
+ const closeButton = document.querySelector(
44
+ '.rebilly-instruments-modal-close',
45
+ );
46
+ const modalContent = document.querySelector(
47
+ '.rebilly-instruments-modal-content',
48
+ );
42
49
 
43
- document.body.style.overflow = 'hidden';
44
- setTimeout(() => {
45
- modalOverlay.classList.add('is-visible');
46
- modalContainer.classList.add('is-visible');
47
- }, 240);
48
- state.loader.addDOMElement({ section: 'modal', el: modalContent });
49
- state.loader.startLoading({ section: 'modal', id: name });
50
+ document.body.style.overflow = 'hidden';
51
+ setTimeout(() => {
52
+ modalOverlay.classList.add('is-visible');
53
+ modalContainer.classList.add('is-visible');
54
+ }, 240);
55
+ state.loader.addDOMElement({ section: 'modal', el: modalContent });
56
+ state.loader.startLoading({ section: 'modal', id: name });
50
57
 
51
- const modelSafeState = state.toModel();
52
- const injectedModel = {
53
- options: modelSafeState.options,
54
- ...model
55
- };
58
+ const modelSafeState = state.toModel();
59
+ const injectedModel = {
60
+ options: modelSafeState.options,
61
+ ...model,
62
+ };
56
63
 
57
- const iframe = await new ModalIframe({
58
- name,
59
- url,
60
- model: injectedModel,
61
- classListArray,
62
- container: modalContent
63
- });
64
+ const iframe = await new ModalIframe({
65
+ name,
66
+ url,
67
+ model: injectedModel,
68
+ classListArray,
69
+ container: modalContent,
70
+ });
64
71
 
65
- const closeModal = (...args) => {
66
- modalContainer.classList.remove('is-visible');
67
- modalOverlay.classList.remove('is-visible');
68
- setTimeout(() => {
69
- document.body.style.overflow = 'auto';
72
+ const closeModal = (...args) => {
73
+ modalContainer.classList.remove('is-visible');
74
+ modalOverlay.classList.remove('is-visible');
75
+ setTimeout(() => {
76
+ document.body.style.overflow = 'auto';
70
77
 
71
- const list = modalOverlay.children;
72
- for (let i = 0; i < list.length; i += 1) {
73
- list[i].remove();
74
- }
78
+ const list = modalOverlay.children;
79
+ for (let i = 0; i < list.length; i += 1) {
80
+ list[i].remove();
81
+ }
75
82
 
76
- modalOverlay.remove();
77
- close(...args);
78
- iframe.destroy();
79
- }, 300);
80
- };
83
+ modalOverlay.remove();
84
+ close(...args);
85
+ iframe.destroy();
86
+ }, 300);
87
+ };
81
88
 
82
- iframe.bindEventListeners({
83
- close: closeModal,
84
- loader: state.loader
85
- });
89
+ iframe.bindEventListeners({
90
+ close: closeModal,
91
+ loader: state.loader,
92
+ });
86
93
 
87
- if (!isRedirect) {
88
- closeButton.addEventListener('click', closeModal);
89
- }
94
+ if (!isRedirect) {
95
+ closeButton.addEventListener('click', closeModal);
96
+ }
90
97
 
91
- iframe.component?.call('route', {
92
- name: 'approval-url'
93
- });
98
+ iframe.component?.call('route', {
99
+ name: 'approval-url',
100
+ });
94
101
 
95
- return iframe;
102
+ return iframe;
96
103
  }
@@ -3,22 +3,22 @@ import iframes from '../state/iframes';
3
3
  import { mountForm } from './form';
4
4
 
5
5
  export async function mountResult({ payload }) {
6
- const iframe = iframes.form;
6
+ const iframe = iframes.form;
7
7
 
8
- if(!iframe) {
9
- await mountForm();
10
- }
8
+ if (!iframe) {
9
+ await mountForm();
10
+ }
11
11
 
12
- const modelSafeState = state.toModel();
13
- const model = {
14
- options: modelSafeState.options,
15
- mainStyleVars: modelSafeState.mainStyleVars,
16
- [state.options.transactionType]: payload
17
- };
12
+ const modelSafeState = state.toModel();
13
+ const model = {
14
+ options: modelSafeState.options,
15
+ mainStyleVars: modelSafeState.mainStyleVars,
16
+ [state.options.transactionType]: payload,
17
+ };
18
18
 
19
- iframe?.component?.call('route', {
20
- name: 'result'
21
- });
19
+ iframe?.component?.call('route', {
20
+ name: 'result',
21
+ });
22
22
 
23
- iframe?.component?.call('update', model);
23
+ iframe?.component?.call('update', model);
24
24
  }
@@ -5,35 +5,34 @@ import { itemsUpdatedHandler } from './common/iframe/events/update-items-handler
5
5
  import { fetchSummary } from '../storefront/summary';
6
6
 
7
7
  export async function mountSummary() {
8
- const modelSafeState = state.toModel();
9
- const model = {
10
- options: modelSafeState.options,
11
- data: modelSafeState.data,
12
- mainStyleVars: modelSafeState.mainStyleVars,
13
- };
14
- const { paymentMethodsUrl } = state.options?._computed;
8
+ const modelSafeState = state.toModel();
9
+ const model = {
10
+ options: modelSafeState.options,
11
+ data: modelSafeState.data,
12
+ mainStyleVars: modelSafeState.mainStyleVars,
13
+ };
14
+ const paymentMethodsUrl = state.options?._computed?.paymentMethodsUrl;
15
15
 
16
- const name = 'rebilly-instruments-summary'
17
- const iframe = await new ViewIframe({
18
- name,
19
- url: `${paymentMethodsUrl}?name=${name}`,
20
- container: state.summary,
21
- model,
22
- route: {
23
- name: 'summary'
24
- }
25
- });
26
- iframe.bindEventListeners({ loader: state.loader });
27
- iframes.summary = iframe;
28
- itemsUpdatedHandler(iframe);
16
+ const name = 'rebilly-instruments-summary';
17
+ const iframe = await new ViewIframe({
18
+ name,
19
+ url: `${paymentMethodsUrl}?name=${name}`,
20
+ container: state.summary,
21
+ model,
22
+ route: {
23
+ name: 'summary',
24
+ },
25
+ });
26
+ iframe.bindEventListeners({ loader: state.loader });
27
+ iframes.summary = iframe;
28
+ itemsUpdatedHandler(iframe);
29
29
 
30
- return {
31
- then: (callback) => callback()
32
- }
30
+ return {
31
+ then: (callback) => callback(),
32
+ };
33
33
  }
34
34
 
35
35
  export async function updateSummary({ instrument } = {}) {
36
- await fetchSummary({ data: instrument });
37
- state.updateModel();
36
+ await fetchSummary({ data: instrument });
37
+ state.updateModel();
38
38
  }
39
-
@@ -1,22 +1,22 @@
1
- import { sleep } from '@/utils'
1
+ import { sleep } from '@/utils';
2
2
 
3
3
  export async function avoidUnhandledPromises() {
4
- // We need this sleep to avoid unhandled promises.
5
- // This hack will be removed if we refactor the current design.
6
- await sleep(100)
4
+ // We need this sleep to avoid unhandled promises.
5
+ // This hack will be removed if we refactor the current design.
6
+ await sleep(100);
7
7
  }
8
8
 
9
9
  /**
10
10
  * @param {Promise} promise
11
11
  */
12
12
  export async function expectConfigurationError(promise) {
13
- const NoConfigOrOptionsError =
14
- 'Could not use Rebilly Instruments mount options to fetch Rebilly data'
15
- let error = null
16
- try {
17
- await promise
18
- } catch (e) {
19
- error = e
20
- }
21
- expect(error.message).toBe(NoConfigOrOptionsError)
13
+ const NoConfigOrOptionsError =
14
+ 'Could not use Rebilly Instruments mount options to fetch Rebilly data';
15
+ let error = null;
16
+ try {
17
+ await promise;
18
+ } catch (e) {
19
+ error = e;
20
+ }
21
+ expect(error.message).toBe(NoConfigOrOptionsError);
22
22
  }
@@ -1,14 +1,15 @@
1
1
  import Emitter from 'component-emitter';
2
2
 
3
3
  export const createFramepayMock = () => {
4
- const framepayBus = new Emitter();
4
+ const framepayBus = new Emitter();
5
5
  const framepayMock = {
6
- initialize: vi.fn(),
7
- digitalWallet: {
8
- mount: vi.fn()
9
- },
10
- on: (eventType, delegate = null) => framepayBus.on(eventType, delegate),
11
- simulateEvent: (eventType, payload) => framepayBus.emit(eventType, payload)
6
+ initialize: vi.fn(),
7
+ digitalWallet: {
8
+ mount: vi.fn(),
9
+ },
10
+ on: (eventType, delegate = null) => framepayBus.on(eventType, delegate),
11
+ simulateEvent: (eventType, payload) =>
12
+ framepayBus.emit(eventType, payload),
12
13
  };
13
14
  return framepayMock;
14
- }
15
+ };
@@ -3,7 +3,9 @@ import { ok, get } from 'msw-when-then';
3
3
  export const rebillyURL = '*';
4
4
 
5
5
  export const initRebillyApiMocks = (when) => {
6
- when(get(`${rebillyURL}/payment-methods`)).thenReturn((() => {
7
- return ok([])
8
- })());
6
+ when(get(`${rebillyURL}/payment-methods`)).thenReturn(
7
+ (() => {
8
+ return ok([]);
9
+ })(),
10
+ );
9
11
  };