Skip to content

Commit

Permalink
refactor: return new links in link-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Feb 28, 2020
1 parent ecaf2c5 commit 0ae596f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions src/app/core/directives/server-html.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Server Html Directive', () => {
it('should transform the given links to routing links', () => {
expect(element).toMatchInlineSnapshot(`
<div>
<div><a href="/product/8182790134362">Produkt</a></div>
<div><a href="/sku8182790134362">Produkt</a></div>
<div><a href="http://google.de">Google</a></div>
<div><a href="/basket">Basket</a></div>
</div>
Expand Down Expand Up @@ -80,16 +80,16 @@ describe('Server Html Directive', () => {

it('should transform the given media object source to the correct source', () => {
expect(element).toMatchInlineSnapshot(`
<div>
<img
src="http://example.org/INTERSHOP/static/WFS/inSPIRED-Site/inTRONICS-b2c-responsive/inSPIRED-inTRONICS-b2c-responsive/en_US/logo%402x.png"
alt=""
width="92"
height="92"
style="width: unset;"
/>
</div>
`);
<div>
<img
src="http://example.org/INTERSHOP/static/WFS/inSPIRED-Site/inTRONICS-b2c-responsive/inSPIRED-inTRONICS-b2c-responsive/en_US/logo%402x.png"
alt=""
width="92"
height="92"
style="width: unset;"
/>
</div>
`);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Content View Helper', () => {
[
{ input: 'route://category/Computers', expected: '/category/Computers' },
{ input: 'route://category/Home-Entertainment.SmartHome', expected: '/category/Home-Entertainment.SmartHome' },
{ input: 'product://201807195@inSPIRED-inTRONICS', expected: '/product/201807195' },
{ input: 'product://201807195@inSPIRED-inTRONICS', expected: '/sku201807195' },
],
({ input, expected }) => {
it(`should transform ${input} to ${expected}`, () => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/utils/link-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ describe('Link Parser', () => {
input: 'route://category/Home-Entertainment.SmartHome',
output: '/category/Home-Entertainment.SmartHome',
},
{ input: 'product://201807195@inSPIRED-inTRONICS', output: '/product/201807195' },
{ input: 'product://201807195@inSPIRED-inTRONICS', output: '/sku201807195' },
{ input: 'http://google.de', output: 'http://google.de' },
{ input: 'https://google.de', output: 'https://google.de' },
{ input: 'page://mypage', output: '/page/mypage' },
{ input: 'category://Computers@inSPIRED-Computers', output: '/category/Computers' },
{ input: 'category://Computers@inSPIRED-Computers', output: '/catComputers' },
{ input: '/product/ABC', output: '/product/ABC' },
{ input: undefined, output: undefined },
],
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/utils/link-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export class LinkParser {
case 'product':
// TODO: for consistent product links it should have the default category in the route
// TODO: use ProductRoutePipe
return `/product/${value}`;
return `/sku${value}`;
case 'category':
// TODO: the configuration parameter currently only works for first level categories
// TODO: use CategoryRoutePipe
return `/category/${value}`;
return `/cat${value}`;
case 'page':
// CMS managed pages link
return `/page/${value}`;
Expand Down

0 comments on commit 0ae596f

Please sign in to comment.