Skip to content

Commit

Permalink
LNP-1070: 🏴󠁧󠁢󠁷󠁬󠁳󠁿 ✅ write unit tests for mapping breadcrumb hrefs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli-TW committed Jan 21, 2025
1 parent 7363a9b commit 7a7d446
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server/utils/__tests__/jsonApi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
isNew,
cropTextWithEllipsis,
isUnpublished,
mapBreadcrumbHref,
} = require('../jsonApi');

const LARGE_TILE = 'enormous.jpg';
Expand Down Expand Up @@ -697,3 +698,19 @@ describe('cropTextWithEllipsis', () => {
);
});
});

describe('Remap breadcrumbs', () => {
it('should remap two letter language prefixes to root', () => {
expect(mapBreadcrumbHref('/en')).toEqual('/');
expect(mapBreadcrumbHref('/cy')).toEqual('/');
expect(mapBreadcrumbHref('/cyx')).toEqual('/cyx');
});
it('should strip the language prefix from aliased terms', () => {
expect(mapBreadcrumbHref('/en/tags/2034')).toEqual('/tags/2034');
expect(mapBreadcrumbHref('/cy/tags/99')).toEqual('/tags/99');
});
it('should strip the language prefix from unaliased terms, and map them to their aliased equivalent', () => {
expect(mapBreadcrumbHref('/en/taxonomy/term/2034')).toEqual('/tags/2034');
expect(mapBreadcrumbHref('/cy/taxonomy/term/99')).toEqual('/tags/99');
});
});

0 comments on commit 7a7d446

Please sign in to comment.