@softwear/latestcollectioncore 1.0.173 → 1.0.175
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/dist/buildPropertyMappingFn.js +15 -8
- package/dist/imageBinder.js +18 -12
- package/package.json +1 -1
- package/src/buildPropertyMappingFn.ts +13 -6
- package/src/imageBinder.ts +18 -16
- package/test/applyPropertyMapping.spec.js +22 -0
- package/test/imageBinder.spec.js +8 -8
- package/test/imageBinderTestData/brandDataMatched/dreamstar.json +6 -709
- package/test/imageBinderTestData/brandDataMatched/lowa.json +6 -1456
- package/test/imageBinderTestData/brandDataMatched/miraclesuit.json +838 -1721
- package/test/imageBinderTestData/brandDataMatched/vacanzeitaliane.json +1215 -2185
- package/test/imageBinderTestData/brandSkus/dreamstar.json +68 -34
- package/test/imageBinderTestData/brandSkus/lowa.json +168 -84
- package/test/imageBinderTestData/brandSkus/miraclesuit.json +78 -39
- package/test/imageBinderTestData/brandSkus/vacanzeitaliane.json +106 -53
|
@@ -28,16 +28,23 @@ const evaluateFromExpr = function (sku, from) {
|
|
|
28
28
|
return sku[from];
|
|
29
29
|
return from.map((field) => sku[field] || '').join('.');
|
|
30
30
|
};
|
|
31
|
+
const indexBrandMappings = function (index, key, propertyMapping) {
|
|
32
|
+
if (!key)
|
|
33
|
+
return;
|
|
34
|
+
if (!index[key])
|
|
35
|
+
index[key] = {};
|
|
36
|
+
propertyMapping === null || propertyMapping === void 0 ? void 0 : propertyMapping.forEach((mapping) => {
|
|
37
|
+
if (!index[key][mapping.category])
|
|
38
|
+
index[key][mapping.category] = {};
|
|
39
|
+
index[key][mapping.category][mapping.from] = mapping.to;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
31
42
|
function default_1(brands, strategy) {
|
|
32
43
|
const indexedByBrandPropertyMapping = {};
|
|
33
|
-
brands.forEach(({ id, propertyMapping }) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!indexedByBrandPropertyMapping[id][mapping.category])
|
|
38
|
-
indexedByBrandPropertyMapping[id][mapping.category] = {};
|
|
39
|
-
indexedByBrandPropertyMapping[id][mapping.category][mapping.from] = mapping.to;
|
|
40
|
-
});
|
|
44
|
+
brands.forEach(({ id, collection, aliases, propertyMapping }) => {
|
|
45
|
+
indexBrandMappings(indexedByBrandPropertyMapping, id, propertyMapping);
|
|
46
|
+
// Alias-aware indexing prevents missing mappings when SKU brandhash resolves to an alias hash.
|
|
47
|
+
aliases === null || aliases === void 0 ? void 0 : aliases.forEach((alias) => indexBrandMappings(indexedByBrandPropertyMapping, alias, propertyMapping));
|
|
41
48
|
});
|
|
42
49
|
if (strategy == 'clean')
|
|
43
50
|
return function (sku) {
|
package/dist/imageBinder.js
CHANGED
|
@@ -66,19 +66,20 @@ function prepFilterSkusImages(filteredSkus, merge = true, fileNames) {
|
|
|
66
66
|
const skusCopy = (0, deepCopy_1.default)(filteredSkus);
|
|
67
67
|
const preppedSkus = [];
|
|
68
68
|
const fileNames2skip = [];
|
|
69
|
-
|
|
70
|
-
skusCopy.forEach((sku) => {
|
|
71
|
-
const fieldsToBeMerged = {};
|
|
69
|
+
skusCopy.forEach((sku, idx) => {
|
|
72
70
|
if (sku.images && sku.images.length > 0) {
|
|
73
71
|
// If a fileName is already matched, we skip it
|
|
74
72
|
fileNames.forEach((fileName) => {
|
|
75
73
|
var _a;
|
|
76
|
-
if (((_a = sku.images) === null || _a === void 0 ? void 0 : _a.includes(fileName)) &&
|
|
74
|
+
if (((_a = sku.images) === null || _a === void 0 ? void 0 : _a.includes(fileName)) && fileNames2skip.indexOf(fileName) == -1)
|
|
77
75
|
fileNames2skip.push(fileName);
|
|
78
76
|
});
|
|
79
77
|
// If a sku has images, we skip it
|
|
78
|
+
sku['skip'] = true;
|
|
79
|
+
preppedSkus.push(sku);
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
+
const fieldsToBeMerged = {};
|
|
82
83
|
for (const fieldName in sku) {
|
|
83
84
|
if (fieldName == '__created' || fieldName == '__modified' || fieldName == 'images' || fieldName == 'brandhash' || (merge == true && fieldName == 'colorFamily'))
|
|
84
85
|
continue;
|
|
@@ -107,7 +108,6 @@ function prepFilterSkusImages(filteredSkus, merge = true, fileNames) {
|
|
|
107
108
|
else {
|
|
108
109
|
const newSku = {};
|
|
109
110
|
newSku['originalSku'] = filteredSkus[idx];
|
|
110
|
-
idx++;
|
|
111
111
|
for (const fieldVal in fieldsToBeMerged) {
|
|
112
112
|
const fieldNameArray = fieldsToBeMerged[fieldVal].sort();
|
|
113
113
|
if (fieldNameArray.length > 1) {
|
|
@@ -121,7 +121,7 @@ function prepFilterSkusImages(filteredSkus, merge = true, fileNames) {
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
const fileNames2Match = fileNames.filter((fileName) => {
|
|
124
|
-
return fileNames2skip.
|
|
124
|
+
return fileNames2skip.indexOf(fileName) == -1;
|
|
125
125
|
});
|
|
126
126
|
return { preppedSkus: preppedSkus, fileNames2Match: fileNames2Match };
|
|
127
127
|
}
|
|
@@ -150,7 +150,7 @@ function checkWithoutLast(fileName) {
|
|
|
150
150
|
.toLowerCase()
|
|
151
151
|
.split(/[_\-.\s()]+|%[0-9A-Fa-f]{2}/)
|
|
152
152
|
.slice(0, -1);
|
|
153
|
-
const lastToken = tokens.
|
|
153
|
+
const lastToken = tokens[tokens.length - 1];
|
|
154
154
|
let returnWithoutLast = false;
|
|
155
155
|
if (lastToken) {
|
|
156
156
|
if (lastToken.includes('front') || lastToken.includes('back') || lastToken.includes('side') || lastToken.includes('sole'))
|
|
@@ -201,7 +201,7 @@ function testQuickSearch(cleanedFileName, fileName, fileNameWithoutLast, quickSe
|
|
|
201
201
|
indicesToReturn.push(idx);
|
|
202
202
|
patternStringFound = quickSearchPattern;
|
|
203
203
|
}
|
|
204
|
-
else if (indicesToReturn.length == 0 && pair[0] == fileNameWithoutLast &&
|
|
204
|
+
else if (indicesToReturn.length == 0 && pair[0] == fileNameWithoutLast && indicesWithoutLast.indexOf(idx) == -1) {
|
|
205
205
|
indicesWithoutLast.push(idx);
|
|
206
206
|
patternStringFound = quickSearchPattern;
|
|
207
207
|
}
|
|
@@ -224,6 +224,8 @@ function prepQuickSearch(preppedSkus) {
|
|
|
224
224
|
patternStrings.push(pattern.join('-'));
|
|
225
225
|
});
|
|
226
226
|
preppedSkus.forEach((sku, idx) => {
|
|
227
|
+
if (sku['skip'])
|
|
228
|
+
return;
|
|
227
229
|
GLOBAL_PATTERNS.forEach((pattern, patternIndex) => {
|
|
228
230
|
const proposedFilename = pattern.reduce((out, field) => out + (field in sku ? sku[field] : ''), '');
|
|
229
231
|
if (proposedFilename) {
|
|
@@ -240,12 +242,12 @@ function prepQuickSearch(preppedSkus) {
|
|
|
240
242
|
}
|
|
241
243
|
function addNewPatternToQuickSearch(preppedSkus, pattern, quickSearch) {
|
|
242
244
|
const newQuickSearchArray = [];
|
|
243
|
-
|
|
244
|
-
|
|
245
|
+
preppedSkus.forEach((sku, idx) => {
|
|
246
|
+
if (sku['skip'])
|
|
247
|
+
return;
|
|
245
248
|
const proposedFilename = pattern.reduce((out, field) => out + (field in sku ? sku[field] : ''), '');
|
|
246
249
|
if (proposedFilename)
|
|
247
250
|
newQuickSearchArray.push([proposedFilename, idx]);
|
|
248
|
-
idx++;
|
|
249
251
|
});
|
|
250
252
|
quickSearch[pattern.join('-')] = newQuickSearchArray;
|
|
251
253
|
return quickSearch;
|
|
@@ -258,6 +260,8 @@ function fallbackSearch(cleanedFileName, fileNameWithoutLast, preppedSkus) {
|
|
|
258
260
|
let currentBestSubstringPatterns = {};
|
|
259
261
|
let maxPatternlength = 0;
|
|
260
262
|
preppedSkus.forEach((sku, idx) => {
|
|
263
|
+
if (sku['skip'])
|
|
264
|
+
return;
|
|
261
265
|
if (pattern_found.length > 0) {
|
|
262
266
|
// In case a new pattern has been found in one sku, test that on the remaining skus. If they don't match the pattern, skip them.
|
|
263
267
|
const proposedFilename = pattern_found.reduce((out, field) => out + (field in sku ? sku[field] : ''), '');
|
|
@@ -359,7 +363,7 @@ function fallbackSearch(cleanedFileName, fileNameWithoutLast, preppedSkus) {
|
|
|
359
363
|
const sku = preppedSkus[idx];
|
|
360
364
|
pattern.forEach((fieldName) => {
|
|
361
365
|
const fieldVal = sku[fieldName];
|
|
362
|
-
if (fieldVal &&
|
|
366
|
+
if (fieldVal && uniqueFieldVals.indexOf(fieldVal) == -1)
|
|
363
367
|
uniqueFieldVals.push(fieldVal);
|
|
364
368
|
});
|
|
365
369
|
});
|
|
@@ -407,6 +411,8 @@ function imageBinder(fileNames, filteredSkus, brand, specifiedPattern, test = fa
|
|
|
407
411
|
const fileNameWithoutLast = checkWithoutLast(fileName);
|
|
408
412
|
fileNameIndexMatch[fileName] = [];
|
|
409
413
|
preppedSkus.forEach((sku, idx) => {
|
|
414
|
+
if (sku['skip'])
|
|
415
|
+
return;
|
|
410
416
|
let skuStillMatches = true;
|
|
411
417
|
specifiedPattern.every((fieldName) => {
|
|
412
418
|
if (!(fieldName in sku))
|
package/package.json
CHANGED
|
@@ -36,14 +36,21 @@ interface propertyMappingI {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
const indexBrandMappings = function (index: propertyMappingI, key: string | undefined, propertyMapping: BrandSettingI['propertyMapping']) {
|
|
40
|
+
if (!key) return
|
|
41
|
+
if (!index[key]) index[key] = {}
|
|
42
|
+
propertyMapping?.forEach((mapping) => {
|
|
43
|
+
if (!index[key][mapping.category]) index[key][mapping.category] = {}
|
|
44
|
+
index[key][mapping.category][mapping.from] = mapping.to
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
export default function (brands: Array<BrandSettingI>, strategy: mappingStrategyE): (sku: SkuI) => SkuI {
|
|
40
49
|
const indexedByBrandPropertyMapping = {} as propertyMappingI
|
|
41
|
-
brands.forEach(({ id, propertyMapping }) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
indexedByBrandPropertyMapping[id][mapping.category][mapping.from] = mapping.to
|
|
46
|
-
})
|
|
50
|
+
brands.forEach(({ id, collection, aliases, propertyMapping }) => {
|
|
51
|
+
indexBrandMappings(indexedByBrandPropertyMapping, id, propertyMapping)
|
|
52
|
+
// Alias-aware indexing prevents missing mappings when SKU brandhash resolves to an alias hash.
|
|
53
|
+
aliases?.forEach((alias) => indexBrandMappings(indexedByBrandPropertyMapping, alias, propertyMapping))
|
|
47
54
|
})
|
|
48
55
|
if (strategy == 'clean')
|
|
49
56
|
return function (sku: SkuI): SkuI {
|
package/src/imageBinder.ts
CHANGED
|
@@ -32,18 +32,19 @@ function prepFilterSkusImages(filteredSkus: SkuI[], merge = true, fileNames: Arr
|
|
|
32
32
|
const skusCopy = deepCopy(filteredSkus)
|
|
33
33
|
const preppedSkus: Array<Record<string, any>> = []
|
|
34
34
|
const fileNames2skip: Array<string> = []
|
|
35
|
-
|
|
36
|
-
skusCopy.forEach((sku) => {
|
|
37
|
-
const fieldsToBeMerged = {}
|
|
35
|
+
skusCopy.forEach((sku, idx) => {
|
|
38
36
|
if (sku.images && sku.images.length > 0) {
|
|
39
37
|
// If a fileName is already matched, we skip it
|
|
40
38
|
fileNames.forEach((fileName) => {
|
|
41
|
-
if (sku.images?.includes(fileName) &&
|
|
39
|
+
if (sku.images?.includes(fileName) && fileNames2skip.indexOf(fileName) == -1) fileNames2skip.push(fileName)
|
|
42
40
|
})
|
|
43
41
|
// If a sku has images, we skip it
|
|
42
|
+
sku['skip'] = true
|
|
43
|
+
preppedSkus.push(sku)
|
|
44
44
|
return
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
const fieldsToBeMerged = {}
|
|
47
48
|
for (const fieldName in sku) {
|
|
48
49
|
if (fieldName == '__created' || fieldName == '__modified' || fieldName == 'images' || fieldName == 'brandhash' || (merge == true && fieldName == 'colorFamily')) continue
|
|
49
50
|
let fieldVal = sku[fieldName]
|
|
@@ -70,7 +71,6 @@ function prepFilterSkusImages(filteredSkus: SkuI[], merge = true, fileNames: Arr
|
|
|
70
71
|
} else {
|
|
71
72
|
const newSku = {}
|
|
72
73
|
newSku['originalSku'] = filteredSkus[idx]
|
|
73
|
-
idx++
|
|
74
74
|
for (const fieldVal in fieldsToBeMerged) {
|
|
75
75
|
const fieldNameArray = fieldsToBeMerged[fieldVal].sort()
|
|
76
76
|
if (fieldNameArray.length > 1) {
|
|
@@ -83,7 +83,7 @@ function prepFilterSkusImages(filteredSkus: SkuI[], merge = true, fileNames: Arr
|
|
|
83
83
|
}
|
|
84
84
|
})
|
|
85
85
|
const fileNames2Match = fileNames.filter((fileName) => {
|
|
86
|
-
return fileNames2skip.
|
|
86
|
+
return fileNames2skip.indexOf(fileName) == -1
|
|
87
87
|
})
|
|
88
88
|
return { preppedSkus: preppedSkus, fileNames2Match: fileNames2Match }
|
|
89
89
|
}
|
|
@@ -116,7 +116,7 @@ function checkWithoutLast(fileName: string) {
|
|
|
116
116
|
.toLowerCase()
|
|
117
117
|
.split(/[_\-.\s()]+|%[0-9A-Fa-f]{2}/)
|
|
118
118
|
.slice(0, -1)
|
|
119
|
-
const lastToken = tokens.
|
|
119
|
+
const lastToken = tokens[tokens.length - 1]
|
|
120
120
|
let returnWithoutLast = false
|
|
121
121
|
if (lastToken) {
|
|
122
122
|
if (lastToken.includes('front') || lastToken.includes('back') || lastToken.includes('side') || lastToken.includes('sole')) returnWithoutLast = true
|
|
@@ -167,7 +167,7 @@ function testQuickSearch(
|
|
|
167
167
|
if (pair[0] == cleanedFileName) {
|
|
168
168
|
indicesToReturn.push(idx)
|
|
169
169
|
patternStringFound = quickSearchPattern
|
|
170
|
-
} else if (indicesToReturn.length == 0 && pair[0] == fileNameWithoutLast &&
|
|
170
|
+
} else if (indicesToReturn.length == 0 && pair[0] == fileNameWithoutLast && indicesWithoutLast.indexOf(idx) == -1) {
|
|
171
171
|
indicesWithoutLast.push(idx)
|
|
172
172
|
patternStringFound = quickSearchPattern
|
|
173
173
|
}
|
|
@@ -188,6 +188,7 @@ function prepQuickSearch(preppedSkus: any): Record<string, Array<any>> {
|
|
|
188
188
|
patternStrings.push(pattern.join('-'))
|
|
189
189
|
})
|
|
190
190
|
preppedSkus.forEach((sku, idx) => {
|
|
191
|
+
if (sku['skip']) return
|
|
191
192
|
GLOBAL_PATTERNS.forEach((pattern, patternIndex) => {
|
|
192
193
|
const proposedFilename = pattern.reduce((out, field) => out + (field in sku ? sku[field] : ''), '')
|
|
193
194
|
if (proposedFilename) {
|
|
@@ -204,11 +205,10 @@ function prepQuickSearch(preppedSkus: any): Record<string, Array<any>> {
|
|
|
204
205
|
|
|
205
206
|
function addNewPatternToQuickSearch(preppedSkus: any, pattern: Array<string>, quickSearch: Record<string, Array<Array<any>>>): Record<string, Array<any>> {
|
|
206
207
|
const newQuickSearchArray: Array<Array<any>> = []
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
preppedSkus.forEach((sku, idx) => {
|
|
209
|
+
if (sku['skip']) return
|
|
209
210
|
const proposedFilename = pattern.reduce((out, field) => out + (field in sku ? sku[field] : ''), '')
|
|
210
211
|
if (proposedFilename) newQuickSearchArray.push([proposedFilename, idx])
|
|
211
|
-
idx++
|
|
212
212
|
})
|
|
213
213
|
quickSearch[pattern.join('-')] = newQuickSearchArray
|
|
214
214
|
return quickSearch
|
|
@@ -223,6 +223,7 @@ function fallbackSearch(cleanedFileName: string, fileNameWithoutLast: string, pr
|
|
|
223
223
|
let currentBestSubstringPatterns: Record<string, Array<number>> = {}
|
|
224
224
|
let maxPatternlength = 0
|
|
225
225
|
preppedSkus.forEach((sku, idx) => {
|
|
226
|
+
if (sku['skip']) return
|
|
226
227
|
if (pattern_found.length > 0) {
|
|
227
228
|
// In case a new pattern has been found in one sku, test that on the remaining skus. If they don't match the pattern, skip them.
|
|
228
229
|
const proposedFilename = pattern_found.reduce((out, field) => out + (field in sku ? sku[field] : ''), '')
|
|
@@ -282,15 +283,15 @@ function fallbackSearch(cleanedFileName: string, fileNameWithoutLast: string, pr
|
|
|
282
283
|
substringPattern.splice(idx, 1)
|
|
283
284
|
}
|
|
284
285
|
})
|
|
285
|
-
const proposedFilename = Object.values(substringObject).join('')
|
|
286
|
+
const proposedFilename = (<any>Object).values(substringObject).join('')
|
|
286
287
|
if (proposedFilename == cleanedFileName || (fileNameWithoutLast && proposedFilename == fileNameWithoutLast)) {
|
|
287
288
|
// We've discovered a new pattern
|
|
288
|
-
pattern_found = Object.values(patternObject)
|
|
289
|
+
pattern_found = (<any>Object).values(patternObject)
|
|
289
290
|
exactMatches.push(idx)
|
|
290
291
|
return
|
|
291
292
|
}
|
|
292
|
-
patternString = Object.values(patternObject).join('-')
|
|
293
|
-
const revisedPatternLength = Object.values(patternObject).length
|
|
293
|
+
patternString = (<any>Object).values(patternObject).join('-')
|
|
294
|
+
const revisedPatternLength = (<any>Object).values(patternObject).length
|
|
294
295
|
if (revisedPatternLength == maxPatternlength) {
|
|
295
296
|
// We've found a new pattern of the same length, so we keep this one too
|
|
296
297
|
if (patternString in currentBestSubstringPatterns) {
|
|
@@ -317,7 +318,7 @@ function fallbackSearch(cleanedFileName: string, fileNameWithoutLast: string, pr
|
|
|
317
318
|
const sku = preppedSkus[idx]
|
|
318
319
|
pattern.forEach((fieldName) => {
|
|
319
320
|
const fieldVal = sku[fieldName]
|
|
320
|
-
if (fieldVal &&
|
|
321
|
+
if (fieldVal && uniqueFieldVals.indexOf(fieldVal) == -1) uniqueFieldVals.push(fieldVal)
|
|
321
322
|
})
|
|
322
323
|
})
|
|
323
324
|
uniqueFieldVals.sort((a, b) => {
|
|
@@ -364,6 +365,7 @@ function imageBinder(fileNames: Array<string>, filteredSkus: SkuI[], brand: stri
|
|
|
364
365
|
const fileNameWithoutLast = checkWithoutLast(fileName)
|
|
365
366
|
fileNameIndexMatch[fileName] = []
|
|
366
367
|
preppedSkus.forEach((sku, idx) => {
|
|
368
|
+
if (sku['skip']) return
|
|
367
369
|
let skuStillMatches = true
|
|
368
370
|
specifiedPattern.every((fieldName) => {
|
|
369
371
|
if (!(fieldName in sku)) skuStillMatches = false
|
|
@@ -451,4 +451,26 @@ describe('applyPropertyMapping', () => {
|
|
|
451
451
|
const mappedSkus = applyPropertyMapping(deepCopy(skus), dtbMapping)
|
|
452
452
|
expect(mappedSkus[11].DTBGROUP).toBe('77777')
|
|
453
453
|
})
|
|
454
|
+
|
|
455
|
+
it('applies mapping when sku.brandhash matches an alias', function () {
|
|
456
|
+
const aliasSkus = [
|
|
457
|
+
{
|
|
458
|
+
id: 'alias-1',
|
|
459
|
+
brand: 'SummumWomen',
|
|
460
|
+
brandhash: 'summumwomen',
|
|
461
|
+
colorCodeSupplier: '100',
|
|
462
|
+
colorSupplier: 'Black',
|
|
463
|
+
},
|
|
464
|
+
]
|
|
465
|
+
const aliasMapping = [
|
|
466
|
+
{
|
|
467
|
+
id: 'summum',
|
|
468
|
+
collection: 'summum',
|
|
469
|
+
aliases: ['summumwomen'],
|
|
470
|
+
propertyMapping: [{ category: 'ColorCode', from: '100', to: 'AliasColor' }],
|
|
471
|
+
},
|
|
472
|
+
]
|
|
473
|
+
const mappedSkus = applyPropertyMapping(deepCopy(aliasSkus), aliasMapping)
|
|
474
|
+
expect(mappedSkus[0].colorFamily).toBe('AliasColor')
|
|
475
|
+
})
|
|
454
476
|
})
|
package/test/imageBinder.spec.js
CHANGED
|
@@ -7,7 +7,7 @@ describe('imageBinder function', function () {
|
|
|
7
7
|
// Tests on 1061 images, 1058 of which are fallback searches that return no results
|
|
8
8
|
const result = await testBatch('miraclesuit')
|
|
9
9
|
expect(Object.keys(result).length).toBe(8)
|
|
10
|
-
expect(result.Mismatches).toBe(
|
|
10
|
+
expect(result.Mismatches).toBe(1052)
|
|
11
11
|
expect(result.QuickSearch).toBe(3)
|
|
12
12
|
expect(result.Patterns['articleCode|articleCodeSupplier-articleDescription-colorCodeSupplier|colorSupplier']).toBe(3)
|
|
13
13
|
// Time can vary, so we use a loose check (within 5 seconds)
|
|
@@ -19,8 +19,8 @@ describe('imageBinder function', function () {
|
|
|
19
19
|
const result = await testBatch('lowa')
|
|
20
20
|
expect(Object.keys(result).length).toBe(8)
|
|
21
21
|
expect(result.Mismatches).toBe(0)
|
|
22
|
-
expect(result.QuickSearch).toBe(
|
|
23
|
-
expect(result.Patterns['articleCode|articleCodeSupplier-colorCodeSupplier|colorSupplier']).toBe(
|
|
22
|
+
expect(result.QuickSearch).toBe(1587)
|
|
23
|
+
expect(result.Patterns['articleCode|articleCodeSupplier-colorCodeSupplier|colorSupplier']).toBe(1586)
|
|
24
24
|
// Time can vary, so we use a loose check (within 5 seconds)
|
|
25
25
|
expect(result.Time).toBeGreaterThan(0)
|
|
26
26
|
expect(result.Time).toBeLessThan(5)
|
|
@@ -30,9 +30,9 @@ describe('imageBinder function', function () {
|
|
|
30
30
|
const result = await testBatch('vacanzeitaliane')
|
|
31
31
|
expect(Object.keys(result).length).toBe(8)
|
|
32
32
|
expect(result.Brand).toBe('vacanzeitaliane')
|
|
33
|
-
expect(result.Mismatches).toBe(
|
|
34
|
-
expect(result.QuickSearch).toBe(
|
|
35
|
-
expect(result.Patterns['articleCode|articleCodeSupplier']).toBe(
|
|
33
|
+
expect(result.Mismatches).toBe(214)
|
|
34
|
+
expect(result.QuickSearch).toBe(496)
|
|
35
|
+
expect(result.Patterns['articleCode|articleCodeSupplier']).toBe(506)
|
|
36
36
|
// Time can vary, so we use a loose check (within 5 seconds)
|
|
37
37
|
expect(result.Time).toBeGreaterThan(0)
|
|
38
38
|
expect(result.Time).toBeLessThan(5)
|
|
@@ -42,8 +42,8 @@ describe('imageBinder function', function () {
|
|
|
42
42
|
expect(Object.keys(result).length).toBe(8)
|
|
43
43
|
expect(result.Brand).toBe('dreamstar')
|
|
44
44
|
expect(result.Mismatches).toBe(0)
|
|
45
|
-
expect(result.QuickSearch).toBe(
|
|
46
|
-
expect(result.Patterns['articleCode|articleCodeSupplier-colorCodeSupplier|colorSupplier']).toBe(
|
|
45
|
+
expect(result.QuickSearch).toBe(786)
|
|
46
|
+
expect(result.Patterns['articleCode|articleCodeSupplier-colorCodeSupplier|colorSupplier']).toBe(631)
|
|
47
47
|
// Time can vary, so we use a loose check (within 5 seconds)
|
|
48
48
|
expect(result.Time).toBeGreaterThan(0)
|
|
49
49
|
expect(result.Time).toBeLessThan(5)
|