Skip to content

Commit

Permalink
Restrict updateLinks to spectrum css
Browse files Browse the repository at this point in the history
  • Loading branch information
yesil committed Dec 23, 2024
1 parent 04abfa8 commit dd6b228
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion libs/deps/mas/mas.js

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions libs/deps/mas/merch-card.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/features/mas/dist/mas.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions libs/features/mas/src/hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ export function processAnalytics(fields, merchCard) {
});
}

export function updateLinks(merchCard) {
export function updateLinksCSS(merchCard) {
if (merchCard.spectrum !== 'css') return;
[
['primary-link', 'primary'],
['secondary-link', 'secondary'],
Expand Down Expand Up @@ -309,5 +310,5 @@ export async function hydrate(fragment, merchCard) {
processDescription(fields, merchCard, aemFragmentMapping.description);
processCTAs(fields, merchCard, aemFragmentMapping, variant);
processAnalytics(fields, merchCard);
updateLinks(merchCard);
updateLinksCSS(merchCard);
}
7 changes: 4 additions & 3 deletions libs/features/mas/test/hydrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ANALYTICS_LINK_ATTR,
ANALYTICS_SECTION_ATTR,
processDescription,
updateLinks,
updateLinksCSS,
} from '../src/hydrate.js';
import { AEM_FRAGMENT_MAPPING } from '../src/variants/ccd-slice.js';

Expand All @@ -25,6 +25,7 @@ import { withWcs } from './mocks/wcs.js';

const mockMerchCard = () => {
const merchCard = document.createElement('div');
merchCard.spectrum = 'css';
document.body.appendChild(merchCard);
const originalAppend = merchCard.append;
merchCard.append = sinon.spy(function () {
Expand Down Expand Up @@ -127,7 +128,7 @@ describe('processCTAs', async () => {
expect(merchCard.append.called).to.be.false;
});

it('should create spectrum css buttons by default', async () => {
it('should create spectrum buttons by default', async () => {
const fields = {
ctas: '<a is="checkout-link" data-wcs-osi="abm" class="accent">Click me</a>',
};
Expand Down Expand Up @@ -514,7 +515,7 @@ describe('processDescription', async () => {
};

processDescription(fields, merchCard, aemFragmentMapping.description);
updateLinks(merchCard);
updateLinksCSS(merchCard);
expect(merchCard.innerHTML).to.equal(
'<div slot="body-xs">Buy <a is="checkout-link" data-wcs-osi="abm" class="spectrum-Link spectrum-Link--primary">Link Style</a><a is="checkout-link" data-wcs-osi="abm" class="spectrum-Link spectrum-Link--secondary">Link Style</a></div>',
);
Expand Down

0 comments on commit dd6b228

Please sign in to comment.