@rebilly/instruments 3.12.3-beta.0 → 3.13.2-beta.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 (84) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +43 -66
  3. package/dist/index.min.js +43 -66
  4. package/package.json +3 -6
  5. package/src/functions/destroy.js +8 -2
  6. package/src/functions/mount/fetch-data.js +9 -2
  7. package/src/functions/mount/index.js +15 -10
  8. package/src/functions/mount/mount.spec.js +10 -11
  9. package/src/functions/mount/setup-framepay-theme.js +30 -72
  10. package/src/functions/mount/setup-options.js +2 -2
  11. package/src/functions/mount/{setup-styles.js → setup-styles-vars.js} +9 -7
  12. package/src/functions/purchase.js +2 -5
  13. package/src/functions/setup.js +3 -6
  14. package/src/functions/show.js +2 -2
  15. package/src/functions/show.spec.js +4 -4
  16. package/src/functions/update.spec.js +4 -3
  17. package/src/instance.js +4 -1
  18. package/src/loader/index.js +57 -33
  19. package/src/storefront/index.js +2 -5
  20. package/src/storefront/payment-instruments.js +7 -0
  21. package/src/style/base/__snapshots__/theme.spec.js.snap +136 -220
  22. package/src/style/base/default-theme.js +187 -14
  23. package/src/style/base/index.js +487 -79
  24. package/src/style/base/theme.js +3 -4
  25. package/src/style/base/theme.spec.js +2 -3
  26. package/src/style/index.js +4 -24
  27. package/src/style/utils/color-values.js +1 -1
  28. package/src/style/utils/minifyCss.js +14 -0
  29. package/src/views/common/iframe/base-iframe.js +3 -2
  30. package/src/views/common/iframe/event-listeners.js +12 -9
  31. package/src/views/common/iframe/method-iframe.js +3 -1
  32. package/src/views/common/iframe/modal-iframe.js +4 -2
  33. package/src/views/common/iframe/view-iframe.js +3 -1
  34. package/src/views/confirmation.js +12 -7
  35. package/src/views/errors.js +95 -0
  36. package/src/views/method-selector/express-methods.js +51 -0
  37. package/src/views/method-selector/generate-framepay-config.js +54 -0
  38. package/src/views/method-selector/generate-framepay-config.spec.js +195 -0
  39. package/src/views/method-selector/get-payment-methods.js +0 -1
  40. package/src/views/method-selector/index.js +45 -58
  41. package/src/views/method-selector/method-selector.spec.js +1 -1
  42. package/src/views/method-selector/mount-express-methods.js +66 -26
  43. package/src/views/modal.js +1 -1
  44. package/src/views/result.js +3 -3
  45. package/src/views/summary.js +24 -190
  46. package/tests/mocks/storefront-api-mock.js +48 -27
  47. package/src/style/browserslist.js +0 -1
  48. package/src/style/components/accordion.js +0 -140
  49. package/src/style/components/address.js +0 -55
  50. package/src/style/components/button.js +0 -117
  51. package/src/style/components/divider.js +0 -39
  52. package/src/style/components/forms/checkbox.js +0 -75
  53. package/src/style/components/forms/field.js +0 -56
  54. package/src/style/components/forms/form.js +0 -18
  55. package/src/style/components/forms/input.js +0 -77
  56. package/src/style/components/forms/label.js +0 -55
  57. package/src/style/components/forms/radio.js +0 -80
  58. package/src/style/components/forms/select.js +0 -86
  59. package/src/style/components/forms/validation.js +0 -72
  60. package/src/style/components/icons.js +0 -13
  61. package/src/style/components/index.js +0 -39
  62. package/src/style/components/loader.js +0 -41
  63. package/src/style/components/methods.js +0 -97
  64. package/src/style/components/overlay.js +0 -24
  65. package/src/style/helpers/index.js +0 -54
  66. package/src/style/payment-instruments/content.js +0 -8
  67. package/src/style/payment-instruments/index.js +0 -14
  68. package/src/style/payment-instruments/payment-card.js +0 -27
  69. package/src/style/payment-instruments/payment-instrument-list.js +0 -44
  70. package/src/style/payment-instruments/payment-instrument.js +0 -55
  71. package/src/style/utils/remove-empty-null.js +0 -10
  72. package/src/style/vendor/framepay.js +0 -28
  73. package/src/style/vendor/postmate.js +0 -18
  74. package/src/style/views/confirmation.js +0 -26
  75. package/src/style/views/index.js +0 -16
  76. package/src/style/views/method-selector.js +0 -11
  77. package/src/style/views/modal.js +0 -91
  78. package/src/style/views/result.js +0 -52
  79. package/src/style/views/summary.js +0 -118
  80. package/src/views/__snapshots__/summary.spec.js.snap +0 -246
  81. package/src/views/method-selector/express-methods/apple-pay.js +0 -92
  82. package/src/views/method-selector/express-methods/index.js +0 -25
  83. package/src/views/method-selector/mount-methods.js +0 -178
  84. package/src/views/summary.spec.js +0 -145
@@ -1,145 +0,0 @@
1
- import SummaryModel from '@/storefront/models/summary-model';
2
- import PlanModel from '@/storefront/models/plan-model';
3
- import ProductModel from '@/storefront/models/product-model';
4
- import { Loader } from '../loader';
5
- import { Translate } from '../i18n';
6
- import { mountSummary } from './summary';
7
- import { DataInstance } from '../functions/mount/fetch-data';
8
-
9
- describe('Summary component', () => {
10
- let summaryElement;
11
- beforeEach(() => {
12
- document.body.innerHTML = '';
13
- summaryElement = document.createElement('div');
14
- document.body.append(summaryElement);
15
- });
16
-
17
- class TestMountSummaryInstance {
18
- constructor({
19
- options = {},
20
- summary = summaryElement,
21
- loader = new Loader(),
22
- translate = new Translate(),
23
- data = {},
24
- } = {}) {
25
- this.options = options;
26
- this.summary = summary;
27
- this.loader = loader;
28
- this.translate = translate;
29
- this.data = new DataInstance({
30
- state: {options},
31
- previewPurchase: new SummaryModel({
32
- currency: 'USD',
33
- lineItems: [
34
- {
35
- type: 'debit',
36
- description: 'My Awesome Product',
37
- unitPrice: 30,
38
- quantity: 1,
39
- price: 30,
40
- productId: 'test-product-1',
41
- planId: 'my-awesome-product'
42
- },
43
- {
44
- type: 'debit',
45
- description: 'Awesome T-Shirt',
46
- unitPrice: 20,
47
- quantity: 2,
48
- price: 40,
49
- productId: 'test-product-2',
50
- planId: 'awesome-t-shirt'
51
- }
52
- ],
53
- subtotalAmount: 70,
54
- taxAmount: 0,
55
- shippingAmount: 0,
56
- discountsAmount: 0,
57
- total: 70
58
- }),
59
- plans: [
60
- new PlanModel({
61
- name: 'My Awesome Product',
62
- id: 'my-awesome-product',
63
- productId: 'test-product-1'
64
- }),
65
- new PlanModel({
66
- name: 'My Awesome T-Shirt',
67
- id: 'awesome-t-shirt',
68
- productId: 'test-product-2'
69
- })
70
- ],
71
- products: [
72
- new ProductModel({
73
- name: 'My Awesome Product',
74
- id: 'test-product-1'
75
- }),
76
- new ProductModel({
77
- name: 'My Awesome T-Shirt',
78
- id: 'test-product-2'
79
- })
80
- ],
81
- ...data
82
- });
83
- }
84
- }
85
-
86
- const options = {
87
- websiteId: 'test-website-id',
88
- countryCode: 'US',
89
- items: [
90
- {
91
- planId: 'my-awesome-product',
92
- quantity: 1,
93
- thumbnail: ''
94
- },
95
- {
96
- planId: 'awesome-t-shirt',
97
- quantity: 2,
98
- thumbnail: ''
99
- }
100
- ]
101
- };
102
-
103
- it('should render the summary correctly', () => {
104
- const mountSummaryInstance = new TestMountSummaryInstance({
105
- options
106
- });
107
-
108
- //TODO: improve design to avoid this manual change
109
- mountSummaryInstance.loader.DOM.summary = mountSummaryInstance.summary;
110
-
111
- mountSummary({ state: mountSummaryInstance });
112
-
113
- // Number of line items
114
- const itemsContainer = document.querySelector(
115
- '.rebilly-instruments-summary-line-items'
116
- );
117
- expect(itemsContainer).toMatchSnapshot();
118
-
119
- // Breakdown
120
- const summaryBreakdown = document.querySelector(
121
- '.rebilly-instruments-summary-breakdown'
122
- );
123
- expect(summaryBreakdown).toMatchSnapshot();
124
- });
125
-
126
- it('should not render the plan description if its falsy', () => {
127
- const mountSummaryInstance = new TestMountSummaryInstance({
128
- options
129
- });
130
-
131
- // Making one product description falsy
132
- mountSummaryInstance.data.previewPurchase.lineItems[0].description = null;
133
-
134
- //TODO: improve design to avoid this manual change
135
- mountSummaryInstance.loader.DOM.summary = mountSummaryInstance.summary;
136
-
137
- mountSummary({ state: mountSummaryInstance });
138
-
139
- // Check that only one description is render
140
- const itemsSynopsysDescription = document.querySelectorAll(
141
- '.rebilly-instruments-summary-line-item-synopsis-description'
142
- );
143
- expect(itemsSynopsysDescription.length).toEqual(1);
144
- });
145
- });