@rebilly/instruments 2.0.0-beta → 3.0.1-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 (197) hide show
  1. package/dist/events/index.js +2 -1
  2. package/dist/functions/mount/fetch-data.js +187 -0
  3. package/dist/functions/mount/fetch-data.spec.js +189 -0
  4. package/dist/functions/mount/index.js +132 -164
  5. package/dist/functions/mount/mount.spec.js +2 -4
  6. package/dist/functions/mount/setup-element.js +40 -0
  7. package/dist/functions/mount/setup-framepay-theme.js +95 -0
  8. package/dist/functions/mount/setup-framepay.js +5 -1
  9. package/dist/functions/mount/setup-i18n.js +33 -0
  10. package/dist/functions/mount/setup-options.js +68 -47
  11. package/dist/functions/mount/setup-options.spec.js +66 -0
  12. package/dist/functions/mount/setup-storefront.js +6 -4
  13. package/dist/functions/mount/setup-styles.js +4 -2
  14. package/dist/functions/purchase.js +129 -24
  15. package/dist/functions/purchase.spec.js +13 -10
  16. package/dist/functions/setup.js +85 -0
  17. package/dist/functions/setup.spec.js +87 -0
  18. package/dist/functions/show.js +8 -4
  19. package/dist/functions/show.spec.js +9 -5
  20. package/dist/functions/update.js +39 -24
  21. package/dist/functions/update.spec.js +0 -4
  22. package/dist/i18n/en.json +5 -2
  23. package/dist/i18n/es.json +4 -1
  24. package/dist/index.js +17 -3
  25. package/dist/index.spec.js +3 -16
  26. package/dist/loader/index.js +4 -3
  27. package/dist/storefront/index.js +33 -0
  28. package/dist/storefront/invoices.js +27 -0
  29. package/dist/storefront/models/base-model.js +18 -0
  30. package/dist/storefront/models/invoice-model.js +14 -0
  31. package/dist/storefront/models/plan-model.js +4 -35
  32. package/dist/storefront/models/product-model.js +4 -23
  33. package/dist/storefront/models/summary-model.js +12 -25
  34. package/dist/storefront/models/transaction-model.js +31 -0
  35. package/dist/storefront/payment-instruments.js +47 -0
  36. package/dist/storefront/payment-instruments.spec.js +55 -0
  37. package/dist/storefront/plans.js +10 -18
  38. package/dist/storefront/plans.spec.js +3 -13
  39. package/dist/storefront/products.js +10 -13
  40. package/dist/storefront/products.spec.js +12 -19
  41. package/dist/storefront/purchase.js +23 -12
  42. package/dist/storefront/purchase.spec.js +1 -20
  43. package/dist/storefront/ready-to-pay.js +18 -15
  44. package/dist/storefront/ready-to-pay.spec.js +2 -12
  45. package/dist/storefront/summary.js +21 -17
  46. package/dist/storefront/summary.spec.js +4 -15
  47. package/dist/storefront/transactions.js +27 -0
  48. package/dist/style/base/__snapshots__/theme.spec.js.snap +188 -45
  49. package/dist/style/base/default-theme.js +699 -0
  50. package/dist/style/base/index.js +48 -16
  51. package/dist/style/base/theme.js +16 -48
  52. package/dist/style/base/theme.spec.js +4 -15
  53. package/dist/style/components/address.js +3 -3
  54. package/dist/style/components/button.js +32 -22
  55. package/dist/style/components/divider.js +9 -9
  56. package/dist/style/components/forms/checkbox.js +12 -9
  57. package/dist/style/components/forms/field.js +18 -6
  58. package/dist/style/components/forms/form.js +2 -2
  59. package/dist/style/components/forms/input.js +54 -13
  60. package/dist/style/components/forms/label.js +39 -18
  61. package/dist/style/components/forms/select.js +54 -22
  62. package/dist/style/components/forms/validation.js +53 -6
  63. package/dist/style/components/icons.js +4 -4
  64. package/dist/style/components/loader.js +5 -3
  65. package/dist/style/components/methods.js +18 -15
  66. package/dist/style/components/overlay.js +5 -5
  67. package/dist/style/helpers/index.js +46 -46
  68. package/dist/style/index.js +3 -1
  69. package/dist/style/payment-instruments/payment-card.js +4 -4
  70. package/dist/style/utils/border.js +47 -0
  71. package/dist/style/utils/color-values.js +39 -3
  72. package/dist/style/utils/remove-empty-null.js +20 -0
  73. package/dist/style/vendor/framepay.js +11 -8
  74. package/dist/style/vendor/postmate.js +2 -2
  75. package/dist/style/views/confirmation.js +13 -13
  76. package/dist/style/views/method-selector.js +2 -2
  77. package/dist/style/views/modal.js +6 -6
  78. package/dist/style/views/result.js +4 -4
  79. package/dist/style/views/summary.js +26 -22
  80. package/dist/views/__snapshots__/summary.spec.js.snap +77 -119
  81. package/dist/views/common/iframe/base-iframe.js +2 -0
  82. package/dist/views/common/iframe/modal-iframe.js +50 -4
  83. package/dist/views/confirmation.js +19 -8
  84. package/dist/views/method-selector/generate-digital-wallet.js +12 -3
  85. package/dist/views/method-selector/generate-digital-wallet.spec.js +11 -0
  86. package/dist/views/method-selector/get-payment-methods.js +13 -2
  87. package/dist/views/method-selector/get-payment-methods.spec.js +21 -19
  88. package/dist/views/method-selector/index.js +23 -34
  89. package/dist/views/method-selector/method-selector.spec.js +50 -55
  90. package/dist/views/method-selector/mount-methods.js +5 -8
  91. package/dist/views/modal.js +8 -2
  92. package/dist/views/result.js +3 -4
  93. package/dist/views/summary.js +156 -97
  94. package/dist/views/summary.spec.js +53 -58
  95. package/package.json +4 -2
  96. package/src/events/index.js +2 -1
  97. package/src/functions/mount/fetch-data.js +152 -0
  98. package/src/functions/mount/fetch-data.spec.js +238 -0
  99. package/src/functions/mount/index.js +101 -158
  100. package/src/functions/mount/mount.spec.js +3 -5
  101. package/src/functions/mount/setup-element.js +26 -0
  102. package/src/functions/mount/setup-framepay-theme.js +82 -0
  103. package/src/functions/mount/setup-framepay.js +5 -1
  104. package/src/functions/mount/setup-i18n.js +19 -0
  105. package/src/functions/mount/setup-options.js +78 -48
  106. package/src/functions/mount/setup-options.spec.js +60 -0
  107. package/src/functions/mount/setup-storefront.js +6 -4
  108. package/src/functions/mount/setup-styles.js +4 -2
  109. package/src/functions/on.spec.js +1 -1
  110. package/src/functions/purchase.js +99 -23
  111. package/src/functions/purchase.spec.js +10 -10
  112. package/src/functions/setup.js +48 -0
  113. package/src/functions/setup.spec.js +98 -0
  114. package/src/functions/show.js +2 -4
  115. package/src/functions/show.spec.js +3 -4
  116. package/src/functions/update.js +40 -25
  117. package/src/functions/update.spec.js +0 -4
  118. package/src/i18n/en.json +5 -2
  119. package/src/i18n/es.json +4 -1
  120. package/src/index.js +9 -3
  121. package/src/index.spec.js +3 -21
  122. package/src/loader/index.js +3 -3
  123. package/src/storefront/index.js +28 -0
  124. package/src/storefront/invoices.js +11 -0
  125. package/src/storefront/models/base-model.js +10 -0
  126. package/src/storefront/models/invoice-model.js +3 -0
  127. package/src/storefront/models/plan-model.js +3 -35
  128. package/src/storefront/models/product-model.js +3 -23
  129. package/src/storefront/models/summary-model.js +12 -19
  130. package/src/storefront/models/transaction-model.js +19 -0
  131. package/src/storefront/payment-instruments.js +30 -0
  132. package/src/storefront/payment-instruments.spec.js +69 -0
  133. package/src/storefront/plans.js +6 -17
  134. package/src/storefront/plans.spec.js +4 -11
  135. package/src/storefront/products.js +8 -16
  136. package/src/storefront/products.spec.js +16 -22
  137. package/src/storefront/purchase.js +14 -16
  138. package/src/storefront/purchase.spec.js +2 -14
  139. package/src/storefront/ready-to-pay.js +13 -16
  140. package/src/storefront/ready-to-pay.spec.js +3 -10
  141. package/src/storefront/summary.js +19 -17
  142. package/src/storefront/summary.spec.js +5 -12
  143. package/src/storefront/transactions.js +11 -0
  144. package/src/style/base/__snapshots__/theme.spec.js.snap +188 -45
  145. package/src/style/base/default-theme.js +674 -0
  146. package/src/style/base/index.js +48 -16
  147. package/src/style/base/theme.js +17 -47
  148. package/src/style/base/theme.spec.js +4 -16
  149. package/src/style/components/address.js +3 -3
  150. package/src/style/components/button.js +32 -24
  151. package/src/style/components/divider.js +9 -9
  152. package/src/style/components/forms/checkbox.js +11 -11
  153. package/src/style/components/forms/field.js +18 -6
  154. package/src/style/components/forms/form.js +2 -2
  155. package/src/style/components/forms/input.js +54 -13
  156. package/src/style/components/forms/label.js +39 -18
  157. package/src/style/components/forms/select.js +54 -22
  158. package/src/style/components/forms/validation.js +53 -6
  159. package/src/style/components/icons.js +4 -4
  160. package/src/style/components/loader.js +4 -5
  161. package/src/style/components/methods.js +18 -15
  162. package/src/style/components/overlay.js +5 -5
  163. package/src/style/helpers/index.js +46 -46
  164. package/src/style/index.js +2 -1
  165. package/src/style/payment-instruments/payment-card.js +4 -4
  166. package/src/style/utils/border.js +34 -0
  167. package/src/style/utils/color-values.js +27 -1
  168. package/src/style/utils/remove-empty-null.js +10 -0
  169. package/src/style/vendor/framepay.js +11 -8
  170. package/src/style/vendor/postmate.js +2 -2
  171. package/src/style/views/confirmation.js +13 -13
  172. package/src/style/views/method-selector.js +2 -2
  173. package/src/style/views/modal.js +6 -6
  174. package/src/style/views/result.js +4 -4
  175. package/src/style/views/summary.js +26 -22
  176. package/src/views/__snapshots__/summary.spec.js.snap +77 -119
  177. package/src/views/common/iframe/base-iframe.js +2 -0
  178. package/src/views/common/iframe/modal-iframe.js +45 -3
  179. package/src/views/confirmation.js +15 -5
  180. package/src/views/method-selector/generate-digital-wallet.js +10 -3
  181. package/src/views/method-selector/generate-digital-wallet.spec.js +10 -0
  182. package/src/views/method-selector/get-payment-methods.js +7 -2
  183. package/src/views/method-selector/get-payment-methods.spec.js +26 -23
  184. package/src/views/method-selector/index.js +21 -28
  185. package/src/views/method-selector/method-selector.spec.js +49 -64
  186. package/src/views/method-selector/mount-methods.js +5 -8
  187. package/src/views/modal.js +6 -2
  188. package/src/views/result.js +4 -3
  189. package/src/views/summary.js +161 -117
  190. package/src/views/summary.spec.js +60 -75
  191. package/tests/mocks/rebilly-instruments-mock.js +37 -7
  192. package/tests/mocks/storefront-api-mock.js +8 -0
  193. package/tests/mocks/storefront-mock.js +17 -0
  194. package/dist/functions/mount/fetch-summary-data.js +0 -46
  195. package/dist/functions/mount/fetch-summary-data.spec.js +0 -43
  196. package/src/functions/mount/fetch-summary-data.js +0 -29
  197. package/src/functions/mount/fetch-summary-data.spec.js +0 -40
@@ -13,7 +13,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
13
13
 
14
14
  const events = {
15
15
  instrumentReady: new _baseEvent.default('instrument-ready'),
16
- purchaseCompleted: new _baseEvent.default('purchase-completed')
16
+ purchaseCompleted: new _baseEvent.default('purchase-completed'),
17
+ setupCompleted: new _baseEvent.default('setup-completed')
17
18
  };
18
19
  var _default = events;
19
20
  exports.default = _default;
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchData = fetchData;
7
+ exports.DataInstance = void 0;
8
+
9
+ var _riskDataCollector = require("@rebilly/risk-data-collector");
10
+
11
+ var _plans = require("../../storefront/plans");
12
+
13
+ var _products = require("../../storefront/products");
14
+
15
+ var _readyToPay = require("../../storefront/ready-to-pay");
16
+
17
+ var _summary = require("../../storefront/summary");
18
+
19
+ var _invoices = require("../../storefront/invoices");
20
+
21
+ var _transactions = require("../../storefront/transactions");
22
+
23
+ class DataInstance {
24
+ constructor({
25
+ state = {},
26
+ ...fields
27
+ } = {}) {
28
+ var _state$options;
29
+
30
+ Object.entries({ ...(state.data || {}),
31
+ ...fields
32
+ }).forEach(([key, value]) => {
33
+ this[key] = value;
34
+ });
35
+ this.money = ((_state$options = state.options) === null || _state$options === void 0 ? void 0 : _state$options.money) || null;
36
+ }
37
+
38
+ get amountAndCurrency() {
39
+ let currency;
40
+ let amount;
41
+
42
+ if (this.previewPurchase) {
43
+ currency = this.previewPurchase.currency;
44
+ amount = this.previewPurchase.total;
45
+ } else if (this.invoice) {
46
+ currency = this.invoice.currency;
47
+ amount = this.invoice.amount;
48
+ } else if (this.transaction) {
49
+ currency = this.transaction.currency;
50
+ amount = this.transaction.amount;
51
+ } else if (this.money) {
52
+ currency = this.money.currency;
53
+ amount = this.money.amount;
54
+ }
55
+
56
+ return {
57
+ amount,
58
+ currency
59
+ };
60
+ }
61
+
62
+ get isPayment() {
63
+ return this.invoice || this.transaction || this.money;
64
+ }
65
+
66
+ get isPurchase() {
67
+ return this.previewPurchase;
68
+ }
69
+
70
+ get summaryItems() {
71
+ const {
72
+ discountsAmount = null,
73
+ shippingAmount = null,
74
+ subtotalAmount = null,
75
+ taxAmount = null
76
+ } = this.previewPurchase || this.invoice || {};
77
+ return {
78
+ discountsAmount,
79
+ shippingAmount,
80
+ subtotalAmount,
81
+ taxAmount
82
+ };
83
+ }
84
+
85
+ get summaryLineItems() {
86
+ let lineItems = [];
87
+
88
+ if (this.invoice) {
89
+ ({
90
+ items: lineItems = []
91
+ } = this.invoice);
92
+ } else {
93
+ ({
94
+ lineItems = []
95
+ } = this.previewPurchase || {});
96
+ }
97
+
98
+ return lineItems;
99
+ }
100
+
101
+ get isShippingRequired() {
102
+ return this.products.some(product => product.requiresShipping);
103
+ }
104
+
105
+ }
106
+
107
+ exports.DataInstance = DataInstance;
108
+
109
+ async function fetchData({
110
+ state = null,
111
+ riskMetadata = null,
112
+ summaryPayload = null,
113
+ // Dependancy injectable functions
114
+ fetchInvoice = _invoices.fetchInvoice,
115
+ fetchTransaction = _transactions.fetchTransaction
116
+ }) {
117
+ try {
118
+ var _state$options2, _state$options3, _state$data, _state$data$transacti, _state$data3;
119
+
120
+ let transaction = null;
121
+
122
+ if ((_state$options2 = state.options) !== null && _state$options2 !== void 0 && _state$options2.transactionId) {
123
+ transaction = await fetchTransaction({
124
+ data: {
125
+ id: state.options.transactionId
126
+ },
127
+ state
128
+ });
129
+ state.data.transaction = transaction;
130
+ }
131
+
132
+ let invoice = null;
133
+
134
+ if ((_state$options3 = state.options) !== null && _state$options3 !== void 0 && _state$options3.invoiceId || (_state$data = state.data) !== null && _state$data !== void 0 && (_state$data$transacti = _state$data.transaction) !== null && _state$data$transacti !== void 0 && _state$data$transacti.hasInvoice) {
135
+ var _state$options4, _state$data2, _state$data2$transact;
136
+
137
+ invoice = await fetchInvoice({
138
+ data: {
139
+ id: ((_state$options4 = state.options) === null || _state$options4 === void 0 ? void 0 : _state$options4.invoiceId) || ((_state$data2 = state.data) === null || _state$data2 === void 0 ? void 0 : (_state$data2$transact = _state$data2.transaction) === null || _state$data2$transact === void 0 ? void 0 : _state$data2$transact.invoiceId)
140
+ },
141
+ state
142
+ });
143
+ state.data.invoice = invoice;
144
+ }
145
+
146
+ if (!riskMetadata) {
147
+ const {
148
+ riskMetadata: data
149
+ } = await (0, _riskDataCollector.collectData)();
150
+ riskMetadata = data;
151
+ }
152
+
153
+ state.data = new DataInstance({
154
+ state,
155
+ invoice,
156
+ transaction,
157
+ riskMetadata
158
+ });
159
+ const [readyToPay, previewPurchase] = await Promise.all([((_state$data3 = state.data) === null || _state$data3 === void 0 ? void 0 : _state$data3.readyToPay) || (0, _readyToPay.fetchReadyToPay)({
160
+ riskMetadata,
161
+ state
162
+ }), state.options.items ? (0, _summary.fetchSummary)({
163
+ data: summaryPayload,
164
+ state
165
+ }) : null]);
166
+ const plans = await (0, _plans.fetchPlans)({
167
+ state
168
+ });
169
+ state.data.plans = plans;
170
+ const products = await (0, _products.fetchProducts)({
171
+ state
172
+ });
173
+ return new DataInstance({
174
+ state,
175
+ readyToPay,
176
+ previewPurchase,
177
+ plans,
178
+ products,
179
+ invoice,
180
+ transaction,
181
+ riskMetadata
182
+ });
183
+ } catch (error) {// console.log(error);
184
+ }
185
+
186
+ return new DataInstance({});
187
+ }
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ var _fetchData = require("./fetch-data");
4
+
5
+ var _transactionModel = _interopRequireDefault(require("../../storefront/models/transaction-model"));
6
+
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+
9
+ describe('fetchData function', () => {
10
+ it('Should use correct invoice id for invoiceId', async () => {
11
+ const mockFetchInvoice = jest.fn();
12
+ const invoiceId = 'test-invoice-id';
13
+ const invoiceState = {
14
+ options: {
15
+ invoiceId
16
+ }
17
+ };
18
+ (0, _fetchData.fetchData)({
19
+ state: invoiceState,
20
+ fetchInvoice: mockFetchInvoice
21
+ });
22
+ expect(mockFetchInvoice).toBeCalledTimes(1);
23
+ expect(mockFetchInvoice).toBeCalledWith(expect.objectContaining({
24
+ data: {
25
+ id: invoiceId
26
+ }
27
+ }));
28
+ });
29
+ it('Should use correct invoice id for transaction with invoiceIds', async () => {
30
+ const mockFetchInvoice = jest.fn();
31
+ const invoiceId = 'test-invoice-id';
32
+ const invoiceState = {
33
+ options: {},
34
+ data: {
35
+ transaction: new _transactionModel.default({
36
+ invoiceIds: [invoiceId]
37
+ })
38
+ }
39
+ };
40
+ (0, _fetchData.fetchData)({
41
+ state: invoiceState,
42
+ fetchInvoice: mockFetchInvoice
43
+ });
44
+ expect(mockFetchInvoice).toBeCalledTimes(1);
45
+ expect(mockFetchInvoice).toBeCalledWith(expect.objectContaining({
46
+ data: {
47
+ id: invoiceId
48
+ }
49
+ }));
50
+ });
51
+ it('Should not fetch invoice for transaction with no invoice Ids', async () => {
52
+ const mockFetchInvoice = jest.fn();
53
+ const invoiceState = {
54
+ options: {},
55
+ data: {
56
+ transaction: new _transactionModel.default({
57
+ invoiceIds: []
58
+ })
59
+ }
60
+ };
61
+ (0, _fetchData.fetchData)({
62
+ state: invoiceState,
63
+ fetchInvoice: mockFetchInvoice
64
+ });
65
+ expect(mockFetchInvoice).toBeCalledTimes(0);
66
+ });
67
+ });
68
+ describe('DataInstance', () => {
69
+ it('Should correctly determine amountAndCurrency', () => {
70
+ const expectedAmountAndCurrency = {
71
+ amount: 10,
72
+ currency: 'USD'
73
+ };
74
+ let fetchedData = new _fetchData.DataInstance({
75
+ state: {
76
+ options: {
77
+ money: { ...expectedAmountAndCurrency
78
+ }
79
+ }
80
+ }
81
+ });
82
+ expect(fetchedData.amountAndCurrency).toEqual(expect.objectContaining(expectedAmountAndCurrency));
83
+ fetchedData = new _fetchData.DataInstance({
84
+ previewPurchase: {
85
+ total: expectedAmountAndCurrency.amount,
86
+ currency: expectedAmountAndCurrency.currency
87
+ }
88
+ });
89
+ expect(fetchedData.amountAndCurrency).toEqual(expect.objectContaining(expectedAmountAndCurrency));
90
+ fetchedData = new _fetchData.DataInstance({
91
+ invoice: { ...expectedAmountAndCurrency
92
+ }
93
+ });
94
+ expect(fetchedData.amountAndCurrency).toEqual(expect.objectContaining(expectedAmountAndCurrency));
95
+ fetchedData = new _fetchData.DataInstance({
96
+ transaction: { ...expectedAmountAndCurrency
97
+ }
98
+ });
99
+ expect(fetchedData.amountAndCurrency).toEqual(expect.objectContaining(expectedAmountAndCurrency));
100
+ fetchedData = new _fetchData.DataInstance();
101
+ expect(fetchedData.amountAndCurrency).toEqual(expect.objectContaining({
102
+ amount: undefined,
103
+ currency: undefined
104
+ }));
105
+ });
106
+ it('Should correctly determine isPayment', () => {
107
+ let fetchedData = new _fetchData.DataInstance({
108
+ state: {
109
+ options: {
110
+ money: true
111
+ }
112
+ }
113
+ });
114
+ expect(fetchedData.isPayment).toBeTruthy();
115
+ fetchedData = new _fetchData.DataInstance({
116
+ invoice: true
117
+ });
118
+ expect(fetchedData.isPayment).toBeTruthy();
119
+ fetchedData = new _fetchData.DataInstance({
120
+ transaction: true
121
+ });
122
+ expect(fetchedData.isPayment).toBeTruthy();
123
+ fetchedData = new _fetchData.DataInstance({
124
+ previewPurchase: true
125
+ });
126
+ expect(fetchedData.isPayment).toBeFalsy();
127
+ fetchedData = new _fetchData.DataInstance({});
128
+ expect(fetchedData.isPayment).toBeFalsy();
129
+ });
130
+ it('Should correctly determine isPurchase', () => {
131
+ let fetchedData = new _fetchData.DataInstance({
132
+ previewPurchase: true
133
+ });
134
+ expect(fetchedData.isPurchase).toBeTruthy();
135
+ fetchedData = new _fetchData.DataInstance({
136
+ state: {
137
+ options: {
138
+ money: true
139
+ }
140
+ }
141
+ });
142
+ expect(fetchedData.isPurchase).toBeFalsy();
143
+ fetchedData = new _fetchData.DataInstance({
144
+ invoice: true
145
+ });
146
+ expect(fetchedData.isPurchase).toBeFalsy();
147
+ fetchedData = new _fetchData.DataInstance({
148
+ transaction: true
149
+ });
150
+ expect(fetchedData.isPurchase).toBeFalsy();
151
+ fetchedData = new _fetchData.DataInstance({});
152
+ expect(fetchedData.isPurchase).toBeFalsy();
153
+ });
154
+ it('Should get summaryItems', () => {
155
+ const expectedSummaryItems = {
156
+ discountsAmount: 1,
157
+ shippingAmount: 2,
158
+ subtotalAmount: 3,
159
+ taxAmount: 4
160
+ };
161
+ let fetchedData = new _fetchData.DataInstance({
162
+ previewPurchase: { ...expectedSummaryItems
163
+ }
164
+ });
165
+ expect(fetchedData.summaryItems).toEqual(expect.objectContaining(expectedSummaryItems));
166
+ fetchedData = new _fetchData.DataInstance({
167
+ invoice: { ...expectedSummaryItems
168
+ }
169
+ });
170
+ expect(fetchedData.summaryItems).toEqual(expect.objectContaining(expectedSummaryItems));
171
+ });
172
+ it('Should get summaryLineItems', () => {
173
+ const expectedSummaryLineItems = [{
174
+ line: 'item'
175
+ }];
176
+ let fetchedData = new _fetchData.DataInstance({
177
+ previewPurchase: {
178
+ lineItems: expectedSummaryLineItems
179
+ }
180
+ });
181
+ expect(fetchedData.summaryLineItems).toEqual(expectedSummaryLineItems);
182
+ fetchedData = new _fetchData.DataInstance({
183
+ invoice: {
184
+ items: expectedSummaryLineItems
185
+ }
186
+ });
187
+ expect(fetchedData.summaryLineItems).toEqual(expectedSummaryLineItems);
188
+ });
189
+ });