@nuskin/ns-product-lib 1.3.5 → 1.4.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ # [1.4.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.3.7...v1.4.0) (2022-03-31)
2
+
3
+
4
+ ### Update
5
+
6
+ * adding locallyProduced flag (#CX16-5842) ([9213365](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/92133654db85e4af7f46a2223a5d999f75dbc9a5)), closes [#CX16-5842](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX16-5842)
7
+ * adding locallyProduced flag (#CX16-5842) ([7e303af](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/7e303af1f14fd870ef571376e1960eb40fb7bd12)), closes [#CX16-5842](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX16-5842)
8
+
9
+ ## [1.3.7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.3.6...v1.3.7) (2021-09-17)
10
+
11
+
12
+ ### Fix
13
+
14
+ * fixed issue of new order types coming in as true when set to [secure] (#CX12-4252) ([ab1d15e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ab1d15ec9591ad98b113bb0ce8817c1c1c2c03f0)), closes [#CX12-4252](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX12-4252)
15
+
16
+ ## [1.3.6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.3.5...v1.3.6) (2021-05-18)
17
+
18
+
19
+ ### Fix
20
+
21
+ * Steel Curtain publish change (#CCPO1-275) ([720b16a](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/720b16a52bbb72be858cb056559f7ce3ca2bb0b5)), closes [#CCPO1-275](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CCPO1-275)
22
+
1
23
  ## [1.3.5](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.3.4...v1.3.5) (2021-05-10)
2
24
 
3
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "1.3.5",
3
+ "version": "1.4.0",
4
4
  "description": "This project contains shared Product models and code between the backend and frontend.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -30,5 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@nuskin/ns-common-lib": "1.3.0"
33
- }
33
+ },
34
+ "files": [
35
+ "src/"
36
+ ]
34
37
  }
package/src/product.js CHANGED
@@ -17,6 +17,7 @@ const Product = function(productData) {
17
17
  this.custTypes = [];
18
18
  this.addOns = [];
19
19
  this.productCarouselImages = [];
20
+ this.locallyProduced = false;
20
21
 
21
22
  //class variables to be used instead of getters/setters
22
23
  this.globalProductID = "";
@@ -349,7 +350,7 @@ const Product = function(productData) {
349
350
  }
350
351
  return retVal;
351
352
  };
352
-
353
+
353
354
  this.getEventPriceTypes = () => {
354
355
  const eventPriceTypes = [];
355
356
 
@@ -490,6 +491,7 @@ const Product = function(productData) {
490
491
  retData.custTypes = this.custTypes;
491
492
  retData.division = this.division;
492
493
  retData.backOrderDate = this.backOrderDate;
494
+ retData.locallyProduced = this.locallyProduced;
493
495
  retData.agelocme = this.agelocme ? this.agelocme.toJSON() : null;
494
496
  retData.count = this.count;
495
497
  retData.flavor = this.flavor;
@@ -597,6 +599,7 @@ const Product = function(productData) {
597
599
  if (data.priceType) {
598
600
  this.priceType = data.priceType;
599
601
  }
602
+ this.locallyProduced = data.locallyProduced;
600
603
  this.count = productData.count;
601
604
  this.flavor = productData.flavor;
602
605
  this.size = productData.size;
@@ -44,8 +44,8 @@ const ProductUtils = {
44
44
  },
45
45
 
46
46
  mergeOrderTypes: function(previousOrderTypes, newOrderTypes) {
47
- // untrust previous order types
48
- const previousOrderTypesMapping = this.getOrderTypesMapping(previousOrderTypes, false);
47
+ // untrust previous order types, override them to false
48
+ const previousOrderTypesMapping = this.getOrderTypesMapping(previousOrderTypes, true);
49
49
 
50
50
  // trust new order types
51
51
  const newOrderTypesMapping = this.getOrderTypesMapping(newOrderTypes);
@@ -56,18 +56,24 @@ const ProductUtils = {
56
56
  };
57
57
  },
58
58
 
59
- getOrderTypesMapping: function(orderTypes, active = true) {
59
+ /**
60
+ * Gets the order types as a dictionary/mapping of order type to value
61
+ * @param {string[] | object[]} orderTypes - ex. ["adr", "order"] or { adr: false, order: true }
62
+ * @param {boolean} override - used to force the value of each orderType to false
63
+ * @returns {object} order types dictionary/mapping
64
+ */
65
+ getOrderTypesMapping: function(orderTypes, override = false) {
60
66
  if (isNullOrEmpty(orderTypes)) {
61
67
  return {};
62
68
  }
63
69
  const orderTypesMapping = {};
64
70
  if (Array.isArray(orderTypes)) {
65
71
  for (const orderType of orderTypes) {
66
- orderTypesMapping[orderType.toLowerCase()] = active;
72
+ orderTypesMapping[orderType.toLowerCase()] = !override;
67
73
  }
68
74
  } else {
69
75
  for (const orderType in orderTypes) {
70
- orderTypesMapping[orderType.toLowerCase()] = active;
76
+ orderTypesMapping[orderType.toLowerCase()] = !override && !!orderTypes[orderType];
71
77
  }
72
78
  }
73
79
  return orderTypesMapping;
package/.eslintrc.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "commonjs": true,
5
- "node": true,
6
- "jest": true
7
- },
8
- "globals": {
9
- "Atomics": "readonly",
10
- "SharedArrayBuffer": "readonly"
11
- },
12
- "parserOptions": {
13
- "ecmaVersion": 2018,
14
- "sourceType": "module"
15
- },
16
- "extends": [
17
- "eslint:recommended",
18
- "plugin:json/recommended"
19
- ],
20
- "rules": {
21
- "indent": ["error", 2, {"SwitchCase": 1}],
22
- "space-in-parens": ["warn", "never"],
23
- "max-len": ["warn", 120],
24
- "no-var": "warn",
25
- "no-console": "off",
26
- "no-invalid-this": "warn",
27
- "comma-dangle": ["error", "never"]
28
- }
29
- }
package/.gitlab-ci.yml DELETED
@@ -1,8 +0,0 @@
1
- include:
2
- # include common pipeline
3
- - project: 'ns-am/platform/ns-gitlab-ci'
4
- ref: master
5
- file: 'npm-module-ci.yml'
6
-
7
- variables:
8
- APP_NAME: $CI_PROJECT_NAME
package/.releaserc DELETED
@@ -1,40 +0,0 @@
1
- {
2
- "branches": [
3
- "master"
4
- ],
5
- "plugins": [
6
- "@semantic-release/npm",
7
- [
8
- "@semantic-release/gitlab",
9
- {
10
- "gitlabUrl": "https://code.tls.nuskin.io"
11
- }
12
- ],
13
- [
14
- "@semantic-release/commit-analyzer",
15
- {
16
- "preset": "eslint"
17
- }
18
- ],
19
- [
20
- "@semantic-release/release-notes-generator",
21
- {
22
- "preset": "eslint"
23
- }
24
- ],
25
- [
26
- "@semantic-release/changelog",
27
- {
28
- "preset": "eslint",
29
- "changelogFile": "CHANGELOG.md"
30
- }
31
- ],
32
- [
33
- "@semantic-release/git",
34
- {
35
- "assets": ["CHANGELOG.md"],
36
- "message": "Release: Automated changes by GitLab pipeline [skip ci]"
37
- }
38
- ]
39
- ]
40
- }
@@ -1,50 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Run All Tests",
11
- "program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
12
- "args": [
13
- "--verbose",
14
- "-i",
15
- "--no-cache"
16
- ],
17
- "console": "integratedTerminal",
18
- "internalConsoleOptions": "neverOpen"
19
- },
20
- {
21
- "type": "node",
22
- "request": "launch",
23
- "name": "Watch Tests",
24
- "program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
25
- "args": [
26
- "--verbose",
27
- "-i",
28
- "--no-cache",
29
- "--watch"
30
- ],
31
- "console": "integratedTerminal",
32
- "internalConsoleOptions": "neverOpen"
33
- },
34
- {
35
- "type": "node",
36
- "request": "launch",
37
- "name": "Watch All Tests",
38
- "program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
39
- "args": [
40
- "--verbose",
41
- "-i",
42
- "--no-cache",
43
- "--watchAll"
44
- ],
45
- "console": "integratedTerminal",
46
- "internalConsoleOptions": "neverOpen"
47
- }
48
- ]
49
- }
50
-
@@ -1,656 +0,0 @@
1
- /* eslint-disable max-len */
2
-
3
- const { Product, ProductContentMapper } = require("../src/index.js");
4
-
5
- function compareProductToContentData(product, productContent) {
6
- expect(product).toBeInstanceOf(Product);
7
- expect(product.sku).toBe(productContent.sku);
8
-
9
- // check language data
10
- const languageData = productContent.contents.language[0];
11
- expect(product.lang).toBe(languageData.languageCode || "");
12
- expect(product.title).toBe(languageData.name || "");
13
- expect(product.shortDescr).toBe(languageData.shortDescription || "");
14
- expect(product.longDescr).toBe(languageData.longDescription || "");
15
- expect(product.ingredients).toStrictEqual(languageData.ingredients || "");
16
- expect(product.usage).toStrictEqual(languageData.usage || "");
17
- expect(product.resources).toStrictEqual(languageData.resources || "");
18
- expect(product.videos).toStrictEqual(languageData.videos || "");
19
- expect(product.contentSection).toStrictEqual(languageData.contentSection || "");
20
- expect(product.benefits).toStrictEqual(languageData.benefits || "");
21
- expect(product.sizeWeight).toBe(languageData.size_weight || "");
22
- expect(product.nettoWeight).toBe(languageData.netto_weight || "");
23
- expect(product.movie).toStrictEqual(languageData.movie || "");
24
- expect(product.youtube).toStrictEqual(languageData.youtube || "");
25
- expect(product.salesEventText).toBe(languageData.tdc_salesEventText || "");
26
- expect(product.salesLabel).toBe(languageData.salesLabel || "");
27
- }
28
-
29
- describe("Product", () => {
30
- test("Can have empty Product", () => {
31
- const product = new Product();
32
- expect(product.isEmpty()).toBeTruthy();
33
- });
34
-
35
- test("Can initialize a new Product using constructor", () => {
36
- const productData = { sku: "1234" };
37
- const product = new Product(productData);
38
-
39
- expect(product).toBeInstanceOf(Product);
40
- expect(product.sku).toBe("1234");
41
- });
42
-
43
- test("Can initialize a new Product using setProductData", () => {
44
- const product = new Product();
45
-
46
- const productData = { sku: "2345" };
47
- product.setProductData(productData);
48
-
49
- expect(product.sku).toBe("2345");
50
- });
51
-
52
- test("Can initialize a new Product from US using AEM Product Content", () => {
53
- const product = getTestProduct();
54
- compareProductToContentData(product, productContent_01550008);
55
- });
56
-
57
- test("Can initialize a new Product from Japan using AEM Product Content", () => {
58
- const product = getJapanTestProduct();
59
- compareProductToContentData(product, productContent_03101351);
60
- });
61
-
62
- test("Returns expected values for various Product functions", () => {
63
- const product = getTestProduct();
64
-
65
- const variant = product.getVariant("01160862");
66
-
67
- expect(product.getHighlightedSku()).toBe("01550008");
68
- expect(product.getProductSearchTitle()).toBe("Advanced Liquid Finish");
69
- expect(product.getProductSearchSku()).toBe("01550008");
70
- expect(product.getDescription()).toBe(
71
- `<div class="longDescription parsys"><div class="text parbase section">\nUpon application, this advanced product helps lessen the appearance of fine lines, wrinkles, and enlarged pores. Use Nu Colour Advanced Liquid Finish daily following your anti-aging skin care regimen for bright, flawless matte coverage and younger looking skin.\n</div>\n\r\n</div>\n`
72
- );
73
-
74
- expect(product.getFullImage()).toBe(
75
- "/content/products/01/55/00/01550008/jcr:content/fullImage.img.240.240.png/1564522583724-cache.png"
76
- );
77
- expect(product.getThumbnail()).toBe(
78
- "/content/products/01/55/00/01550008/jcr:content/fullImage.img.160.160.png/1564522583724-cache.png"
79
- );
80
- expect(variant.getFullImage()).toBe(
81
- "/content/products/01/16/08/01160862/jcr:content/fullImage.img.240.240.png/1528387855303-cache.png"
82
- );
83
- expect(variant.getThumbnail()).toBe(
84
- "/content/products/01/16/08/01160862/jcr:content/fullImage.img.160.160.png/1528387855303-cache.png"
85
- );
86
-
87
- expect(product.getProductCarouselImages()).toStrictEqual(
88
- productCarouselImages
89
- );
90
-
91
- expect(product.getImageAltText()).toBe("Advanced Liquid Finish");
92
- product.setImageAltText("");
93
- expect(product.getImageAltText()).toBe("Advanced Liquid Finish");
94
- product.setImageAltText("Testing Alt Text");
95
- expect(product.getImageAltText()).toBe("Testing Alt Text");
96
-
97
- product.setBaseUrl("https://test.nuskin.com");
98
- expect(product.getFullImage()).toBe(
99
- "https://test.nuskin.com/content/products/01/55/00/01550008/jcr:content/fullImage.img.240.240.png/1564522583724-cache.png"
100
- );
101
- expect(product.getThumbnail()).toBe(
102
- "https://test.nuskin.com/content/products/01/55/00/01550008/jcr:content/fullImage.img.160.160.png/1564522583724-cache.png"
103
- );
104
- expect(variant.getFullImage()).toBe(
105
- "https://test.nuskin.com/content/products/01/16/08/01160862/jcr:content/fullImage.img.240.240.png/1528387855303-cache.png"
106
- );
107
- expect(variant.getThumbnail()).toBe(
108
- "https://test.nuskin.com/content/products/01/16/08/01160862/jcr:content/fullImage.img.160.160.png/1528387855303-cache.png"
109
- );
110
- });
111
- });
112
-
113
- function getTestProduct() {
114
- const product = ProductContentMapper.createProduct(productContent_01550008);
115
- return product;
116
- }
117
-
118
- function getJapanTestProduct() {
119
- const product = ProductContentMapper.createProduct(productContent_03101351);
120
- return product;
121
- }
122
-
123
- const productCarouselImages = [
124
- {
125
- alt: "",
126
- contentType: "img",
127
- src:
128
- "/content/products/01/55/00/01550008/jcr:content/fullImage.imgw.1280.1280.png"
129
- }
130
- ];
131
-
132
- // based off a real Product Content response in Test for en_US
133
- const productContent_01550008 = {
134
- sku: "01550008",
135
- isExclusive: false,
136
- isAlwaysViewable: false,
137
- isCartSearchable: true,
138
- isProductAvailableForDistributors: true,
139
- isPurchaseable: true,
140
- isSiteSearchable: true,
141
- description: "",
142
- division: "",
143
- componentProduct: [],
144
- variantConfig: {
145
- variantType: "Shade",
146
- variantsSkus: ["01160862", "01160861"],
147
- variants: [
148
- {
149
- sku: "01160862",
150
- isExclusive: false,
151
- isAlwaysViewable: false,
152
- isCartSearchable: true,
153
- isProductAvailableForDistributors: true,
154
- isPurchaseable: true,
155
- isSiteSearchable: true,
156
- description: "Advanced Liquid Finish Beige (US)",
157
- division: "",
158
- componentProduct: [],
159
- variantConfig: {
160
- baseSku: "01550008",
161
- swatchColor: "#d6b278",
162
- variantsSkus: []
163
- },
164
- contents: {
165
- fullImage:
166
- "/content/products/01/16/08/01160862/jcr:content/fullImage.img.240.240.png/1528387855303-cache.png",
167
- imageCarousel: [
168
- {
169
- contentType: "img",
170
- src:
171
- "/content/products/01/16/08/01160862/jcr:content/fullImage.imgw.1280.1280.png",
172
- alt: ""
173
- }
174
- ],
175
- altText: "Advanced Liquid Finish Beige",
176
- language: [
177
- {
178
- languageCode: "en",
179
- name: "Advanced Liquid Finish Beige",
180
- size_weight: "1.0 fl. oz.",
181
- longDescription:
182
- `<div class="longDescription parsys"><div class="text parbase section">\n<p>Upon application, this advanced product helps lessen the appearance of fine lines, wrinkles, and enlarged pores. Use Nu Colour Advanced Liquid Finish daily following your anti-aging skin care regimen for bright, flawless matte coverage and younger looking skin.</p>\n\n</div>\n\r\n</div>\n`,
183
- text: "SB484 Warning for Consumers in California",
184
- linkTo: "/content/nuskin/en_US/products/sb484.html",
185
- variantInfo: {
186
- tdc_dropdownLabel: "Beige"
187
- },
188
- resources: {
189
- resourcesHTML:
190
- `<p><a adhocenable="false" href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_pip.pdf">Product Information Page</a></p>\n<p><a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_product_card.pdf">Product Card</a></p>\n<p><a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_faq.pdf">FAQ</a></p>\n`,
191
- resourceLinks: []
192
- },
193
- contentSection: [
194
- {
195
- sectionContent:
196
- `<div class="contentSections"><div class="contentSection section"><div>\n<h3>Resources</h3>\n<div>\n<div class="sectionContent parsys"><div class="text parbase section">\n<p><a adhocenable="false" href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_pip.pdf" target="_blank">Product Information Page</a><br>\n<a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_product_card.pdf" target="_blank" adhocenable="false">Product Card</a><br>\n<a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_faq.pdf" target="_blank" adhocenable="false">FAQ</a><br>\n<a href="/content/dam/global/library/pdf/SB484-Warning-Consumers-California.pdf" target="_blank" adhocenable="false">SB484 Warning for Consumers in California</a></p>\n\n</div>\n\r\n</div>\n\n</div>\n</div>\n</div>\n</div>\n`
197
- }
198
- ]
199
- }
200
- ]
201
- },
202
- market: {
203
- countryCode: "US",
204
- statusCode: "10",
205
- statusMessage: "Fully Releasd 4 Sale",
206
- webEnabled: "true",
207
- scanQualified: 0,
208
- seashoppe: "",
209
- orderType: ["adr", "order", "ZPFC"],
210
- addOns: [],
211
- custType: ["10", "20"],
212
- CSV: "25.12",
213
- PSV: "23.50",
214
- WebAutomaticDeliveryWholesaleCv: "25.12",
215
- WebWholesaleCv: "25.12",
216
- WebAutomaticDeliveryWholesalePv: "23.5",
217
- WebWholesalePv: "23.5",
218
- WebAutomaticDeliveryRetail: "36.2",
219
- WebAutomaticDeliveryWholesale: "28.96",
220
- AutomaticDeliveryRetail: "36.2",
221
- AutomaticDeliveryWholesale: "28.96",
222
- WebRetail: "36.2",
223
- WebWholesale: "28.96",
224
- Retail: "36.2",
225
- Wholesale: "28.96",
226
- Points: "23.5"
227
- },
228
- populateRetailPricing: {
229
- retailPrice: "Price",
230
- retailPriceValue: "$36.20",
231
- adrPrice: "ADR Price",
232
- adrPriceValue: "$36.20",
233
- save: "Save",
234
- saveValue: "$0.00",
235
- webPrice: "Web Price",
236
- webRetailPriceValue: "$36.20",
237
- retailSave: "Save",
238
- retailSavingsValue: "$0.00",
239
- webPoints: "Points",
240
- webPointsValue: "23.50"
241
- },
242
- populateWholesalePricing: {
243
- wholeSalePrice: "Wholesale Price",
244
- wholeSalePriceValue: "$28.96",
245
- adrPrice: "ADR Price",
246
- adrPriceValue: "$28.96",
247
- save: "Save",
248
- saveValue: "$0.00",
249
- webPrice: "Web Price",
250
- webWholesalePriceValue: "$28.96",
251
- wholesaleSave: "Save",
252
- wholesaleSavingsValue: "$0.00",
253
- psv: "SV",
254
- psvValue: "23.50",
255
- csv: "CSV",
256
- csvValue: "25.12",
257
- webPoints: "Points",
258
- webPointsValue: "23.50",
259
- productUnavailableToUser: "You are not able to purchase this product."
260
- },
261
- populateProductLabels: {
262
- sizeLabelSelection: "??sizeLabelSelection??",
263
- nettoWeightLabel: "Netto Weight",
264
- quantity: "Quantity",
265
- itemno: "Item No.",
266
- addtocart: "Add to Cart",
267
- addtoadrcart: "Add to ADR Cart",
268
- enterCouponCode: "Enter Coupon Code",
269
- itemAddedToCart: "Your item has been added.",
270
- continueShopping: "Continue Shopping",
271
- checkout: "Checkout",
272
- productUnavailableOnWeb:
273
- "This product is currently not available on the web.",
274
- productUnavailableInMarket:
275
- "This product is currently not available in this market.",
276
- learnMore: "Learn More"
277
- }
278
- },
279
- {
280
- sku: "01160861",
281
- isExclusive: false,
282
- isAlwaysViewable: false,
283
- isCartSearchable: true,
284
- isProductAvailableForDistributors: true,
285
- isPurchaseable: true,
286
- isSiteSearchable: true,
287
- description: "Advanced Liquid Finish Honey Beige US",
288
- division: "",
289
- componentProduct: [],
290
- variantConfig: {
291
- baseSku: "01550008",
292
- swatchColor: "#c39971",
293
- variantsSkus: []
294
- },
295
- contents: {
296
- fullImage:
297
- "/content/products/01/16/08/01160861/jcr:content/fullImage.img.240.240.png/1528388029330-cache.png",
298
- imageCarousel: [
299
- {
300
- contentType: "img",
301
- src:
302
- "/content/products/01/16/08/01160861/jcr:content/fullImage.imgw.1280.1280.png",
303
- alt: ""
304
- }
305
- ],
306
- altText: "Advanced Liquid Finish Honey Beige",
307
- language: [
308
- {
309
- languageCode: "en",
310
- name: "Advanced Liquid Finish Honey Beige",
311
- size_weight: "1.0 fl. oz.",
312
- longDescription:
313
- `<div class="longDescription parsys"><div class="text parbase section">\n<p>Upon application, this advanced product helps lessen the appearance of fine lines, wrinkles, and enlarged pores. Use Nu Colour Advanced Liquid Finish daily following your anti-aging skin care regimen for bright, flawless matte coverage and younger looking skin.</p>\n\n</div>\n\r\n</div>\n`,
314
- text: "SB484 Warning for Consumers in California",
315
- linkTo: "/content/nuskin/en_US/products/sb484.html",
316
- variantInfo: {
317
- tdc_dropdownLabel: "Honey Beige"
318
- },
319
- resources: {
320
- resourcesHTML:
321
- `<p><a adhocenable="false" href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_pip.pdf">Product Information Page</a></p>\n<p><a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_product_card.pdf">Product Card</a></p>\n<p><a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_faq.pdf">FAQ</a></p>\n`,
322
- resourceLinks: []
323
- },
324
- contentSection: [
325
- {
326
- sectionContent:
327
- `<div class="contentSections"><div class="contentSection section"><div>\n<h3>Resources</h3>\n<div>\n<div class="sectionContent parsys"><div class="text parbase section">\n<p><a adhocenable="false" href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_pip.pdf" target="_blank">Product Information Page</a><br>\n<a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_product_card.pdf" target="_blank" adhocenable="false">Product Card</a><br>\n<a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_faq.pdf" target="_blank" adhocenable="false">FAQ</a><br>\n<a href="/content/dam/global/library/pdf/SB484-Warning-Consumers-California.pdf" target="_blank" adhocenable="false">SB484 Warning for Consumers in California</a></p>\n\n</div>\n\r\n</div>\n\n</div>\n</div>\n</div>\n</div>\n`
328
- }
329
- ]
330
- }
331
- ]
332
- },
333
- market: {
334
- countryCode: "US",
335
- statusCode: "10",
336
- statusMessage: "Fully Releasd 4 Sale",
337
- webEnabled: "true",
338
- scanQualified: 0,
339
- seashoppe: "",
340
- orderType: ["adr", "order", "ZPFC"],
341
- addOns: [],
342
- custType: ["10", "20"],
343
- CSV: "25.12",
344
- PSV: "23.50",
345
- WebAutomaticDeliveryWholesaleCv: "25.12",
346
- WebWholesaleCv: "25.12",
347
- WebAutomaticDeliveryWholesalePv: "23.5",
348
- WebWholesalePv: "23.5",
349
- WebAutomaticDeliveryRetail: "36.2",
350
- WebAutomaticDeliveryWholesale: "28.96",
351
- AutomaticDeliveryRetail: "36.2",
352
- AutomaticDeliveryWholesale: "28.96",
353
- WebRetail: "36.2",
354
- WebWholesale: "28.96",
355
- Retail: "36.2",
356
- Wholesale: "28.96",
357
- Points: "23.5"
358
- },
359
- populateRetailPricing: {
360
- retailPrice: "Price",
361
- retailPriceValue: "$36.20",
362
- adrPrice: "ADR Price",
363
- adrPriceValue: "$36.20",
364
- save: "Save",
365
- saveValue: "$0.00",
366
- webPrice: "Web Price",
367
- webRetailPriceValue: "$36.20",
368
- retailSave: "Save",
369
- retailSavingsValue: "$0.00",
370
- webPoints: "Points",
371
- webPointsValue: "23.50"
372
- },
373
- populateWholesalePricing: {
374
- wholeSalePrice: "Wholesale Price",
375
- wholeSalePriceValue: "$28.96",
376
- adrPrice: "ADR Price",
377
- adrPriceValue: "$28.96",
378
- save: "Save",
379
- saveValue: "$0.00",
380
- webPrice: "Web Price",
381
- webWholesalePriceValue: "$28.96",
382
- wholesaleSave: "Save",
383
- wholesaleSavingsValue: "$0.00",
384
- psv: "SV",
385
- psvValue: "23.50",
386
- csv: "CSV",
387
- csvValue: "25.12",
388
- webPoints: "Points",
389
- webPointsValue: "23.50",
390
- productUnavailableToUser: "You are not able to purchase this product."
391
- },
392
- populateProductLabels: {
393
- sizeLabelSelection: "??sizeLabelSelection??",
394
- nettoWeightLabel: "Netto Weight",
395
- quantity: "Quantity",
396
- itemno: "Item No.",
397
- addtocart: "Add to Cart",
398
- addtoadrcart: "Add to ADR Cart",
399
- enterCouponCode: "Enter Coupon Code",
400
- itemAddedToCart: "Your item has been added.",
401
- continueShopping: "Continue Shopping",
402
- checkout: "Checkout",
403
- productUnavailableOnWeb:
404
- "This product is currently not available on the web.",
405
- productUnavailableInMarket:
406
- "This product is currently not available in this market.",
407
- learnMore: "Learn More"
408
- }
409
- }
410
- ]
411
- },
412
- contents: {
413
- fullImage:
414
- "/content/products/01/55/00/01550008/jcr:content/fullImage.img.240.240.png/1564522583724-cache.png",
415
- imageCarousel: productCarouselImages,
416
- altText: "Advanced Liquid Finish",
417
- language: [
418
- {
419
- languageCode: "en",
420
- name: "Advanced Liquid Finish",
421
- longDescription:
422
- `<div class="longDescription parsys"><div class="text parbase section">\nUpon application, this advanced product helps lessen the appearance of fine lines, wrinkles, and enlarged pores. Use Nu Colour Advanced Liquid Finish daily following your anti-aging skin care regimen for bright, flawless matte coverage and younger looking skin.\n</div>\n\r\n</div>\n`,
423
- variantInfo: {
424
- tdc_variantsLabel: "Shade",
425
- tdc_dropdownPlaceholder: "Select Shade"
426
- },
427
- benefits: {
428
- benefitsHTML:
429
- "<ul>\n<li>Promotes a youthful appearance upon application.\n<ul>\n<li>It helps sagging skin look tighter.\n<li>Diminishes the appearance of fine lines, wrinkles, and enlarged pores.\n<li>Diminishes skin imperfections by reflecting light from all directions.\n</ul>\n<li>Gives the complexion a healthy, radiant glow.\n<li>Provides a matte, flawless finish.\n<li>Provides broad-spectrum protection with SPF 15.\n<li>Perfectly complements your Nu Skin anti-aging skin care regimen.\n</ul>",
430
- benefitsText: "Benefits",
431
- benefitItems: []
432
- },
433
- usage: {
434
- usageHTML:
435
- "Smooth over the face and neck area, blending at the jawline. Seal with a light dusting of powder.",
436
- usageText: "Usage/Application"
437
- },
438
- ingredients: {
439
- ingredientsHTML:
440
- `<p>Water (Aqua), Ethylhexyl Methoxycinnamate, Butylene Glycol, C12-15 Alkyl Benzoate, Glycerin, Octocrylene, Isostearic Acid, Ethylhexyl Salicylate, Glyceryl Stearate, Stearic Acid, Cetyl Alcohol, Aloe Barbadensis Leaf Juice, Sodium Hyaluronate, Sodium PCA, Panthenol, Bisabolol, Morus Alba Root Extract, Squalane, Tocopheryl Acetate, Jojoba Esters, Tocopherol, Glycine Soja (Soybean) Oil, Nylon-12 Fluorescent Brightener 230 Salt, Dipalmitoyl Hydroxyproline, Niacinamide, Dimethicone, Magnesium Aluminum Silicate, Sodium C14-16 Olefin Sulfonate, Xanthan Gum, Polyvinylalcohol Crosspolymer, Sodium Dehydroacetate, Aminomethyl Propanol, Caprylyl Glycol, Phenoxyethanol.</p>\n<p>May Contain: Titanium Dioxide (CI 77891), Iron Oxides (CI 77491, CI 77492, CI 77499)</p>\n`,
441
- ingredientsText: "Ingredients",
442
- ingredients: []
443
- },
444
- resources: {
445
- resourcesHTML:
446
- `<p><a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_pip.pdf" target="_blank">Product Information Page</a><br>\n<a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_product_card.pdf" target="_blank">Product Card</a><br>\n<a href="/content/dam/office/n_america/shared/en/nuskin_products/nc_liquid_finish_faq.pdf" target="_blank">FAQ</a><br>\n<a href="/content/dam/global/library/pdf/SB484-Warning-Consumers-California.pdf" target="_blank">SB484 Warning for Consumers in California</a></p>\n`,
447
- resourcesText: "Resources",
448
- resourceLinks: []
449
- },
450
- contentSection: [
451
- {
452
- sectionContent: `<div class="contentSections"></div>\n`
453
- }
454
- ]
455
- }
456
- ]
457
- },
458
- market: {
459
- countryCode: "US",
460
- statusCode: "10",
461
- statusMessage: "Fully Releasd 4 Sale",
462
- webEnabled: "true",
463
- scanQualified: 1,
464
- seashoppe: "",
465
- orderType: ["order"],
466
- addOns: [],
467
- custType: ["10"],
468
- CSV: "---",
469
- PSV: "---"
470
- },
471
- populateRetailPricing: {
472
- retailPrice: "Price",
473
- retailPriceValue: "---",
474
- adrPrice: "ADR Price",
475
- adrPriceValue: "---",
476
- save: "Save",
477
- saveValue: "$0.00",
478
- webPrice: "Web Price",
479
- webRetailPriceValue: "---",
480
- retailSave: "Save",
481
- retailSavingsValue: "$0.00",
482
- webPoints: "Points",
483
- webPointsValue: "---"
484
- },
485
- populateWholesalePricing: {
486
- wholeSalePrice: "Wholesale Price",
487
- wholeSalePriceValue: "---",
488
- adrPrice: "ADR Price",
489
- adrPriceValue: "---",
490
- save: "Save",
491
- saveValue: "$0.00",
492
- webPrice: "Web Price",
493
- webWholesalePriceValue: "---",
494
- wholesaleSave: "Save",
495
- wholesaleSavingsValue: "$0.00",
496
- psv: "SV",
497
- psvValue: "---",
498
- csv: "CSV",
499
- csvValue: "---",
500
- webPoints: "Points",
501
- webPointsValue: "---",
502
- productUnavailableToUser: "You are not able to purchase this product."
503
- },
504
- populateProductLabels: {
505
- sizeLabelSelection: "??sizeLabelSelection??",
506
- nettoWeightLabel: "Netto Weight",
507
- quantity: "Quantity",
508
- itemno: "Item No.",
509
- addtocart: "Add to Cart",
510
- addtoadrcart: "Add to ADR Cart",
511
- enterCouponCode: "Enter Coupon Code",
512
- itemAddedToCart: "Your item has been added.",
513
- continueShopping: "Continue Shopping",
514
- checkout: "Checkout",
515
- productUnavailableOnWeb:
516
- "This product is currently not available on the web.",
517
- productUnavailableInMarket:
518
- "This product is currently not available in this market.",
519
- learnMore: "Learn More"
520
- }
521
- };
522
-
523
- // based off a real Product Content response in Test for ja_JP
524
- const productContent_03101351 = {
525
- sku: "03101351",
526
- isExclusive: false,
527
- isAlwaysViewable: false,
528
- isCartSearchable: true,
529
- isProductAvailableForDistributors: true,
530
- isPurchaseable: true,
531
- isSiteSearchable: true,
532
- description: "バランシング シャンプー 250g",
533
- division: "",
534
- componentProduct: [
535
- ],
536
- variantConfig: {
537
- baseSku: "03550026",
538
- variantsSkus: [
539
- ]
540
- },
541
- contents: {
542
- fullImage: "/content/products/03/10/13/03101351/jcr:content/fullImage.img.240.240.png/1570419237952-cache.png",
543
- imageCarousel: [
544
- {
545
- contentType: "img",
546
- src: "/content/products/03/10/13/03101351/jcr:content/fullImage.imgw.1280.1280.png",
547
- alt: ""
548
- }
549
- ],
550
- altText: "バランシング シャンプー ~さらさら~ 250g",
551
- language: [
552
- {
553
- languageCode: "ja",
554
- name: "バランシング シャンプー 250g",
555
- shortDescription: "03101351,バランシング シャンプー 〜さらさら〜 250g,Balancing Shampoo 250g,ばらんしんぐ しゃんぷー 〜さらさら〜 250g,バランシング シャンプー 〜さらさら〜 250g",
556
- size_weight: "250g",
557
- longDescription: "<div class=\"longDescription parsys\"><div class=\"text parbase section\">\n<p><b>製品名(英語)</b> Balancing Shampoo 250g<br>\n<br>\n</p>\n\n</div>\n<div class=\"text parbase section\">\n<p><b><span class=\"emphasis\">さらさらでツヤのある髪に洗い上げる、デイリー ケア用シャンプー</span></b><br>\n<br>\n</p>\n\n</div>\n<div class=\"text parbase section\">\n<p>シロバナワタエキス配合。潤いを保ちながら髪の汚れを落とします。髪の毛皮質(コルテックス)をサポートして、いきいきと輝くツヤのある髪に導きます。<br>\n<br>\n<b>コンディショニング成分</b></p>\n<p>シロバナワタエキス</p>\n\n</div>\n\r\n</div>\n",
558
- variantInfo: {
559
- tdc_dropdownLabel: "250g"
560
- },
561
- contentSection: [
562
- {
563
- sectionContent: "<div class=\"contentSections\"><div class=\"contentSection section\"><div>\n<h3>セールスポイント</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<p>さらさらでツヤのある髪に洗い上げる、デイリー ケア用シャンプーです。</p>\n\n</div>\n\r\n</div>\n\n</div>\n</div>\n</div>\n<div class=\"contentSection section\"><div>\n<h3>使い方</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<p>髪と地肌をぬらしたあと、適量を手に取り、泡立てながら指先でやさしくマッサージするように洗います。その後、よくすすぎ、お好みのニュースキン コンディショナーで仕上げます。髪の汚れがひどい場合は、2度洗いをしてください。</p>\n\n</div>\n\r\n</div>\n\n</div>\n</div>\n</div>\n<div class=\"contentSection section\"><div>\n<h3>成分</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<p>(全成分)</p>\n\n</div>\n<div class=\"text parbase section\">\n<p>\n水<br>\nラウレス硫酸アンモニウム<br>\nラウリル硫酸アンモニウム<br>\nコカミドMEA<br>\nココジモニウムヒドロキシプロピル加水分解コムギタンパク<br>\nパンテノール<br>\nBG<br>\nシロバナワタエキス<br>\nPCA−Na<br>\nグアーヒドロキシプロピルトリモニウムクロリド<br>\n塩化Na<br>\nラウレス−23<br>\nポリクオタニウム−10<br>\nジメチコン<br>\nアクリレーツコポリマー<br>\nポリソルベート80<br>\n(C12−15)パレス−3<br>\nPEG/PPG−18/18ジメチコン<br>\nステアリン酸グリコール<br>\nクエン酸<br>\nフィチン酸Na<br>\nメチルクロロイソチアゾリノン<br>\nメチルイソチアゾリノン<br>\n香料<br>\n</p>\n\n</div>\n\r\n</div>\n\n</div>\n</div>\n</div>\n<div class=\"contentSection section\"><div>\n<h3>ADPについて</h3>\n<div>\n<div class=\"sectionContent parsys\"><div class=\"text parbase section\">\n<p>オートマティック デリバリー プログラム(ADP) 割引対象製品です。\n</p>\n\n</div>\n\r\n</div>\n\n</div>\n</div>\n</div>\n</div>\n"
564
- }
565
- ]
566
- }
567
- ]
568
- },
569
- market: {
570
- countryCode: "JP",
571
- statusCode: "10",
572
- statusMessage: "Fully Releasd 4 Sale",
573
- webEnabled: "true",
574
- scanQualified: 0,
575
- seashoppe: "",
576
- orderType: [
577
- "adr",
578
- "order",
579
- "ZPFC"
580
- ],
581
- addOns: [
582
- ],
583
- custType: [
584
- "10",
585
- "20"
586
- ],
587
- CSV: "1167.00",
588
- PSV: "9.70",
589
- WebAutomaticDeliveryWholesaleCv: "1108.0",
590
- WebAutomaticDeliveryWholesaleDelayedCv: "1050.0",
591
- WebWholesaleCv: "1167.0",
592
- WebAutomaticDeliveryWholesalePv: "9.25",
593
- WebAutomaticDeliveryWholesaleDelayedPv: "8.75",
594
- WebWholesalePv: "9.7",
595
- WebAutomaticDeliveryRetail: "1442.0",
596
- WebAutomaticDeliveryWholesale: "1442.0",
597
- WebAutomaticDeliveryWholesaleDelayed: "1366.0",
598
- WebRetail: "2170.0",
599
- WebWholesale: "1518.0",
600
- Retail: "2170.0",
601
- Wholesale: "1518.0"
602
- },
603
- populateRetailPricing: {
604
- retailPrice: "価格",
605
- retailPriceValue: "¥2,170",
606
- adrPrice: "ADP価格",
607
- adrPriceValue: "---",
608
- save: "保存",
609
- saveValue: "¥2,170",
610
- webPrice: "インターネット価格",
611
- webRetailPriceValue: "¥2,170",
612
- retailSave: "保存",
613
- retailSavingsValue: "¥0",
614
- webPoints: "Points",
615
- webPointsValue: "---"
616
- },
617
- populateWholesalePricing: {
618
- wholeSalePrice: "卸売価格",
619
- wholeSalePriceValue: "¥1,518",
620
- adrPrice: "ADP価格",
621
- adrPriceValue: "---",
622
- save: "保存",
623
- saveValue: "¥1,518",
624
- webPrice: "インターネット価格",
625
- webWholesalePriceValue: "¥1,518",
626
- wholesaleSave: "保存",
627
- wholesaleSavingsValue: "¥0",
628
- psv: "PSV",
629
- psvValue: "9.70",
630
- csv: "CSV",
631
- csvValue: "1167.00",
632
- webPoints: "Points",
633
- webPointsValue: "---",
634
- productUnavailableToUser: "あなたは、この製品を購入することはできません。"
635
- },
636
- populateProductLabels: {
637
- sizeLabelSelection: "??sizeLabelSelection??",
638
- nettoWeightLabel: "Netto Weight",
639
- quantity: "数量",
640
- itemno: "アイテム番号",
641
- addtocart: "買い物かごに追加",
642
- addtoadrcart: "ADP買い物かごに追加",
643
- enterCouponCode: "クーポン コード入力",
644
- itemAddedToCart: "アイテムが追加されました。",
645
- continueShopping: "ショッピングを続ける",
646
- checkout: "会計",
647
- productUnavailableOnWeb: "現在、この製品はオンラインで購入できません。",
648
- productUnavailableInMarket: "現在、この製品は当該マーケットでは購入できません。",
649
- learnMore: "詳しくはこちら"
650
- }
651
- }
652
-
653
- module.exports = {
654
- getTestProduct,
655
- getJapanTestProduct
656
- };
@@ -1,324 +0,0 @@
1
- const {
2
- Product,
3
- PriceType,
4
- ProductStatusMapper
5
- } = require("../src/index.js");
6
- const { getTestProduct } = require("./product.spec.js");
7
-
8
- describe("ProductStatus", () => {
9
- test("Can set Product Status to product", () => {
10
- const product = getTestProduct();
11
-
12
- product.addPricingFromStatus(productStatus_01160862);
13
- product.addPricingFromStatus(productStatus_01160861);
14
-
15
- expect(product.price).toBeFalsy(); // base sku won't have pricing
16
-
17
- const variant = product.getVariant("01160862");
18
-
19
- expect(variant).toBeInstanceOf(Product);
20
- expect(variant.price).toBeFalsy(); // prices shouldn't be set yet
21
- });
22
-
23
- test("Returns expected values for various Product functions", () => {
24
- const product = getTestProduct();
25
-
26
- product.addPricingFromStatus(productStatus_01160862);
27
- product.addPricingFromStatus(productStatus_01160861);
28
-
29
- const variant = product.getVariant("01160862");
30
-
31
- product.setPriceAndPvFromType(PriceType.WRTL); // sets price
32
-
33
- expect(variant.price).toBe(36.2);
34
- expect(variant.getPrice()).toBe(36.2);
35
- expect(product.getPrice()).toBeFalsy(); // base sku still won't have pricing
36
- expect(product.getMinPrice()).toBe(36.2); // get min range price from variants
37
- expect(product.getMaxPrice()).toBe(42.1); // get max range price from variants
38
-
39
- expect(product.hasAvailableQuantity()).toBeFalsy(); // base sku won't have available qty
40
- expect(variant.hasAvailableQuantity()).toBeTruthy();
41
-
42
- expect(variant.getPointsFixed()).toBe("23.50");
43
- variant.setPoints("24.12");
44
- expect(variant.getPointsFixed()).toBe("24.12");
45
-
46
- expect(variant.getCvFixed()).toBe("25.12");
47
- variant.setCv("26.13");
48
- expect(variant.getCvFixed()).toBe("26.13");
49
-
50
- expect(variant.getPvFixed()).toBe("23.50");
51
- variant.setPv("23.11");
52
- expect(variant.getPvFixed()).toBe("23.11");
53
-
54
- variant.setPrice(37.123);
55
- expect(variant.getPrice()).toBe(37.123);
56
- expect(variant.getPriceFixed()).toBe(37.12);
57
-
58
- variant.setFormattedPrice("42.12");
59
- expect(variant.formattedPrice).toBe("42.12");
60
-
61
- expect(variant.getOriginalPrice()).toBe(36.2);
62
-
63
- variant.addPricing("Test", 42.0);
64
- expect(variant.priceMap["Test"]).toBe(42.0);
65
- });
66
-
67
- test("Can map Product Status V2 response", () => {
68
- const product = getTestProduct();
69
-
70
- const productStatuses = ProductStatusMapper.createProductStatusesFromV2(productStatusV2Response);
71
- expect(productStatuses).toStrictEqual(expectedProductStatusesV1Mapped);
72
-
73
- for (const productStatus of productStatuses) {
74
- product.addPricingFromStatus(productStatus);
75
- }
76
-
77
- product.setPriceAndPvFromType(PriceType.WRTL); // sets price
78
-
79
- const variant = product.getVariant("01160862");
80
- expect(variant.price).toBe(36.2);
81
- });
82
- });
83
-
84
- // real Product Status response in Test for en_US
85
- const productStatus_01160862 = {
86
- SKU: "01160862",
87
- backordered: false,
88
- availableQuantity: 200,
89
- webEnabled: true,
90
- status: "RELEASED_FOR_SALE",
91
- orderType: [
92
- "zadp",
93
- "ars",
94
- "kiosk",
95
- "mobile",
96
- "preferred customer",
97
- "retail",
98
- "web",
99
- "web display",
100
- "adr",
101
- "order"
102
- ],
103
- price: {
104
- WRTL: 36.2,
105
- WADR: 36.2,
106
- RTL: 36.2,
107
- WWHL: 28.96,
108
- WADW: 28.96,
109
- PTS: 23.5,
110
- WHL: 28.96
111
- },
112
- psv: { WWHL: 23.5, WADW: 23.5, WHL: 23.5 },
113
- csv: { WWHL: 25.12, WADW: 25.12, WHL: 25.12 },
114
- maxQuantity: 200
115
- };
116
-
117
- const now = new Date();
118
- const tomorrow = now.setDate(now.getDate() + 1);
119
-
120
- // an altered response for testing
121
- const productStatus_01160861 = {
122
- SKU: "01160861",
123
- backordered: true,
124
- backorderedAvailableDate: tomorrow.valueOf(),
125
- availableQuantity: 3,
126
- webEnabled: true,
127
- status: "RELEASED_FOR_SALE",
128
- orderType: ["order"],
129
- price: {
130
- WRTL: 42.1,
131
- WADR: 42.1,
132
- RTL: 42.1,
133
- WWHL: 40.9,
134
- WADW: 40.9,
135
- PTS: 38.7,
136
- WHL: 40.9
137
- },
138
- psv: { WWHL: 38.7, WADW: 38.7, WHL: 38.7 },
139
- csv: { WWHL: 39.5, WADW: 39.5, WHL: 39.5 },
140
- maxQuantity: 10
141
- };
142
-
143
- // real Product Status V2 response in Test for en_US
144
- const productStatusV2Response = {
145
- status: 200,
146
- items: {
147
- "01160862": {
148
- availableQuantity: 999,
149
- backordered: false,
150
- webEnabled: true,
151
- childSkus: [],
152
- status: {
153
- retail: "RELEASED_FOR_SALE",
154
- wholesale: "RELEASED_FOR_SALE"
155
- },
156
- orderType: [
157
- "zadp",
158
- "ars",
159
- "kiosk",
160
- "mobile",
161
- "preferred customer",
162
- "retail",
163
- "web",
164
- "web display",
165
- "adr",
166
- "order"
167
- ],
168
- pricing: {
169
- retail: {
170
- webOrder: {
171
- price: 36.2
172
- },
173
- webAdr: {
174
- price: 36.2
175
- },
176
- order: {
177
- price: 36.2
178
- }
179
- },
180
- wholesale: {
181
- webOrder: {
182
- price: 28.96,
183
- pv: 23.5,
184
- cv: 25.12
185
- },
186
- webAdr: {
187
- price: 28.96,
188
- pv: 23.5,
189
- cv: 25.12
190
- },
191
- order: {
192
- Points: 23.5,
193
- cv: 25.12,
194
- price: 28.96,
195
- pv: 23.5
196
- }
197
- }
198
- }
199
- },
200
- "01160861": {
201
- availableQuantity: 999,
202
- backordered: false,
203
- webEnabled: true,
204
- status: {
205
- retail: "RELEASED_FOR_SALE",
206
- wholesale: "RELEASED_FOR_SALE"
207
- },
208
- orderType: [
209
- "zadp",
210
- "ars",
211
- "kiosk",
212
- "mobile",
213
- "preferred customer",
214
- "retail",
215
- "web",
216
- "web display",
217
- "adr",
218
- "order"
219
- ],
220
- pricing: {
221
- retail: {
222
- webOrder: {
223
- price: 36.2
224
- },
225
- webAdr: {
226
- price: 36.2
227
- },
228
- order: {
229
- price: 36.2
230
- }
231
- },
232
- wholesale: {
233
- webOrder: {
234
- price: 28.96,
235
- pv: 23.5,
236
- cv: 25.12
237
- },
238
- webAdr: {
239
- price: 28.96,
240
- pv: 23.5,
241
- cv: 25.12
242
- },
243
- order: {
244
- Points: 23.5,
245
- cv: 25.12,
246
- price: 28.96,
247
- pv: 23.5
248
- }
249
- }
250
- }
251
- }
252
- }
253
- };
254
-
255
- const expectedProductStatusesV1Mapped = [
256
- {
257
- availableQuantity: 999,
258
- backordered: false,
259
- backorderedAvailableDate: undefined,
260
- childSkus: [],
261
- csv: { WADW: 25.12, WHL: 25.12, WWHL: 25.12 },
262
- marketAttributes: undefined,
263
- orderType: [
264
- "zadp",
265
- "ars",
266
- "kiosk",
267
- "mobile",
268
- "preferred customer",
269
- "retail",
270
- "web",
271
- "web display",
272
- "adr",
273
- "order"
274
- ],
275
- price: {
276
- PTS: 23.5,
277
- RTL: 36.2,
278
- WADR: 36.2,
279
- WADW: 28.96,
280
- WHL: 28.96,
281
- WRTL: 36.2,
282
- WWHL: 28.96
283
- },
284
- psv: { WADW: 23.5, WHL: 23.5, WWHL: 23.5 },
285
- sku: "01160862",
286
- globalProductID: undefined,
287
- status: "RELEASED_FOR_SALE",
288
- webEnabled: true
289
- },
290
- {
291
- availableQuantity: 999,
292
- backordered: false,
293
- backorderedAvailableDate: undefined,
294
- childSkus: [],
295
- csv: { WADW: 25.12, WHL: 25.12, WWHL: 25.12 },
296
- marketAttributes: undefined,
297
- orderType: [
298
- "zadp",
299
- "ars",
300
- "kiosk",
301
- "mobile",
302
- "preferred customer",
303
- "retail",
304
- "web",
305
- "web display",
306
- "adr",
307
- "order"
308
- ],
309
- price: {
310
- PTS: 23.5,
311
- RTL: 36.2,
312
- WADR: 36.2,
313
- WADW: 28.96,
314
- WHL: 28.96,
315
- WRTL: 36.2,
316
- WWHL: 28.96
317
- },
318
- psv: { WADW: 23.5, WHL: 23.5, WWHL: 23.5 },
319
- sku: "01160861",
320
- globalProductID: undefined,
321
- status: "RELEASED_FOR_SALE",
322
- webEnabled: true
323
- }
324
- ];
@@ -1,45 +0,0 @@
1
- /* eslint-disable max-len */
2
-
3
- const { ProductUtils } = require("../src/index.js");
4
-
5
- const testSku = "01160862";
6
- const expectedTokenizedSkuResult = "01/16/08/01160862";
7
- const expectedTokenizedSkuPartsResult = {
8
- part1: "01",
9
- part2: "16",
10
- part3: "08"
11
- };
12
-
13
- describe("ProductUtils", () => {
14
- test("Returns expected result from getTokenizedSku", () => {
15
- const result = ProductUtils.getTokenizedSku(testSku);
16
-
17
- expect(result).toStrictEqual(expectedTokenizedSkuResult);
18
- });
19
-
20
- test("Returns expected result from getTokenizedSkuParts", () => {
21
- const result = ProductUtils.getTokenizedSkuParts(testSku);
22
-
23
- expect(result).toStrictEqual(expectedTokenizedSkuPartsResult);
24
- });
25
-
26
- test("Returns expected result from applyBaseUrl", () => {
27
- const baseUrl = "https://test.nuskin.com/";
28
-
29
- let url =
30
- "/content/dam/marketsites/Global/Homepage/BrandStory/lifestyle_003.jpg";
31
- let result = ProductUtils.applyBaseUrl(url, baseUrl);
32
-
33
- expect(result).toBe(
34
- "https://test.nuskin.com/content/dam/marketsites/Global/Homepage/BrandStory/lifestyle_003.jpg"
35
- );
36
-
37
- url =
38
- "http://test.nuskin.com/content/products/01/00/37/01003763/jcr:content/fullImage.img.png/1600703980201-cache.png?format=pjpg";
39
- result = ProductUtils.applyBaseUrl(url, baseUrl);
40
-
41
- expect(result).toBe(
42
- "https://test.nuskin.com/content/products/01/00/37/01003763/jcr:content/fullImage.img.png/1600703980201-cache.png?format=pjpg"
43
- );
44
- });
45
- });
package/jest.config.js DELETED
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- transform: {
3
- "^.+\\.(js|jsx)?$": "babel-jest"
4
- },
5
- testURL: "http://localhost/",
6
- collectCoverage: true,
7
- collectCoverageFrom: ["src/*.js"],
8
- coveragePathIgnorePatterns: [
9
- "/node_modules/",
10
- "package.json",
11
- "package-lock.json",
12
- "index.js"
13
- ],
14
- testResultsProcessor: "jest-sonar-reporter",
15
- coverageReporters: ["html", "lcov", "text-summary"]
16
- };