-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lite anchor transform only WS services (#12059)
* Lite anchor transform only WS services * Update transformAnchorTags.ts * Update index.test.ts
- Loading branch information
Showing
2 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ describe('litePageTransforms', () => { | |
it('should append .lite suffix to valid hrefs', () => { | ||
const html = ` | ||
<a href="https://www.bbc.com/news">News</a> | ||
<a href="https://www.bbc.com/serbian/lat">News</a> | ||
<a href="https://www.bbc.com/mundo">News</a> | ||
<a href="https://www.bbcrussian.com/news">News</a> | ||
<a href="/news">News</a> | ||
`; | ||
|
@@ -13,31 +15,45 @@ describe('litePageTransforms', () => { | |
|
||
expect(modifiedHtml).toEqual(` | ||
<a href="https://www.bbc.com/news.lite">News</a> | ||
<a href="https://www.bbc.com/serbian/lat.lite">News</a> | ||
<a href="https://www.bbc.com/mundo.lite">News</a> | ||
<a href="https://www.bbcrussian.com/news.lite">News</a> | ||
<a href="/news.lite">News</a> | ||
`); | ||
}); | ||
|
||
it('should not append .lite suffix to invalid hrefs', () => { | ||
const html = ` | ||
const originalHtml = ` | ||
<a href="https://www.bbc.co.uk/news">News</a> | ||
<a href="https://www.bbc.com/news.lite">News</a> | ||
<a href="https://www.bbc.com/news.amp">News</a> | ||
<a href="#news">News</a> | ||
<a href="mailto:[email protected]">News</a> | ||
`; | ||
|
||
const modifiedHtml = litePageTransforms(html); | ||
const modifiedHtml = litePageTransforms(originalHtml); | ||
|
||
expect(modifiedHtml).toEqual(originalHtml); | ||
}); | ||
|
||
expect(modifiedHtml).toEqual(html); | ||
it('should not append .lite suffix to an invalid "service"', () => { | ||
const originalHtml = ` | ||
<a href="https://www.bbc.co.uk/future">Future</a> | ||
<a href="https://www.bbc.com/food">Food</a> | ||
<a href="https://www.bbc.com/weather">Weather</a> | ||
`; | ||
|
||
const modifiedHtml = litePageTransforms(originalHtml); | ||
|
||
expect(modifiedHtml).toEqual(originalHtml); | ||
}); | ||
|
||
it('should not append .lite suffix when no anchor tags are present', () => { | ||
const html = '<p>I am a paragraph</p>'; | ||
const originalHtml = '<p>I am a paragraph</p>'; | ||
|
||
const modifiedHtml = litePageTransforms(html); | ||
const modifiedHtml = litePageTransforms(originalHtml); | ||
|
||
expect(modifiedHtml).toEqual(html); | ||
expect(modifiedHtml).toEqual(originalHtml); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters