diff --git a/test/utils/product.test.js b/test/utils/product.test.js index 465bb8f..5b532fc 100644 --- a/test/utils/product.test.js +++ b/test/utils/product.test.js @@ -52,7 +52,7 @@ describe('constructProductUrl', () => { it('should construct the correct product URL without variant', () => { const url = constructProductUrl(configWithoutOfferVariantURLTemplate, product1); - const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/KW5531'; + const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531'; assert.strictEqual(url, expectedUrl, 'Product URL without variant does not match expected URL'); }); @@ -65,20 +65,20 @@ describe('constructProductUrl', () => { it('should construct the correct variant URL without offerVariantURLTemplate', () => { const url = constructProductUrl(configWithoutOfferVariantURLTemplate, product1, variant1); - const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/KW5531/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ=='; + const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ%3D%3D'; assert.strictEqual(url, expectedUrl, 'Variant URL without offerVariantURLTemplate does not match expected URL'); }); // Test Case 4: Encode special characters in sku and urlKey it('should correctly encode special characters in sku and urlKey', () => { const url = constructProductUrl(configWithoutOfferVariantURLTemplate, productWithSpecialCharacters); - const expectedUrl = 'https://www.example.com/products/summer-sun/KW%2055%2F31'; + const expectedUrl = 'https://www.example.com/products/summer-sun/kw%2055%2F31'; assert.strictEqual(url, expectedUrl, 'URL with special characters does not match expected URL'); }); it('should correctly encode special characters in variant sku and selections', () => { const url = constructProductUrl(configWithoutOfferVariantURLTemplate, productWithSpecialCharacters, variantWithSpecialSelections); - const expectedUrl = 'https://www.example.com/products/summer-sun/KW%2055%2F31/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ==%3D%2CY29uZmlndXJhYmxlLzI0NjEvMzYzNDE='; + const expectedUrl = 'https://www.example.com/products/summer-sun/kw%2055%2F31/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ%3D%3D%2CY29uZmlndXJhYmxlLzI0NjEvMzYzNDE%3D'; assert.strictEqual(url, expectedUrl, 'Variant URL with special characters does not match expected URL'); }); @@ -88,19 +88,19 @@ describe('constructProductUrl', () => { selections: [], }; const url = constructProductUrl(configWithoutOfferVariantURLTemplate, product1, variantEmptySelections); - const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/KW5531/?optionsUIDs='; + const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531/?optionsUIDs='; assert.strictEqual(url, expectedUrl, 'URL with empty variant selections does not match expected URL'); }); it('should handle missing matchedPathConfig when variant is present', () => { const url = constructProductUrl(configWithoutOfferVariantURLTemplate, product1, variant1); - const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/KW5531/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ=='; + const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ%3D%3D'; assert.strictEqual(url, expectedUrl, 'URL without offerVariantURLTemplate but with variant does not match expected URL'); }); it('should construct the correct URL when variant is undefined', () => { const url = constructProductUrl(configWithOfferVariantURLTemplate, product1); - const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/KW5531'; + const expectedUrl = 'https://www.example.com/products/utopia-small-pendant/kw5531'; assert.strictEqual(url, expectedUrl, 'Product URL with undefined variant does not match expected URL'); }); @@ -114,7 +114,7 @@ describe('constructProductUrl', () => { sku: 'ML-2023', }; const url = constructProductUrl(configMultiplePlaceholders, product); - const expectedUrl = 'https://www.example.com/shop/modern-lamp/ML-2023/details'; + const expectedUrl = 'https://www.example.com/shop/modern-lamp/ml-2023/details'; assert.strictEqual(url, expectedUrl, 'URL with multiple placeholders does not match expected URL'); }); @@ -127,7 +127,7 @@ describe('constructProductUrl', () => { }, }; const url = constructProductUrl(configEmptyOfferVariantURLTemplate, product1, variant1); - const expectedUrl = 'https://www.example.com/products/utopia-small-pendant-KW5531/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ=='; + const expectedUrl = 'https://www.example.com/products/utopia-small-pendant-kw5531/?optionsUIDs=Y29uZmlndXJhYmxlLzE2NTEvODI3MQ%3D%3D'; assert.strictEqual(url, expectedUrl, 'URL with empty offerVariantURLTemplate does not match expected URL'); }); });