Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dylandepass committed Nov 1, 2024
1 parent e280e44 commit 91a48ff
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/utils/product.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand All @@ -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');
});

Expand All @@ -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');
});

Expand All @@ -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');
});

Expand All @@ -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');
});
});

0 comments on commit 91a48ff

Please sign in to comment.