generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
109 additions
and
16 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
88 changes: 88 additions & 0 deletions
88
test/features/personalization/modifyNonFragmentSelector.test.js
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { modifyNonFragmentSelector } from '../../../libs/features/personalization/personalization.js'; | ||
|
||
const values = [ | ||
{ | ||
b: 'main section1 marquee action-area', | ||
a: 'main > div:nth-child(1) .marquee p:has(em a, strong a)', | ||
}, | ||
{ | ||
b: 'main > section1 .marquee h2', | ||
a: 'main > div:nth-child(1) .marquee h2', | ||
}, | ||
{ | ||
b: '#some-random-id, section1 marquee row2 col1 p:nth-of-type(2)', | ||
a: '#some-random-id , main > div:nth-child(1) .marquee > div:nth-child(2) > div:nth-child(1) p:nth-of-type(2)', | ||
}, | ||
{ | ||
b: 'marquee.light:nth-child(2) h2', | ||
a: '.marquee.light:nth-child(2) h2', | ||
}, | ||
{ | ||
b: 'section2 text3', | ||
a: 'main > div:nth-child(2) .text:nth-child(3 of .text)', | ||
}, | ||
{ | ||
b: 'section2 .text.light strong', | ||
a: 'main > div:nth-child(2) .text.light strong', | ||
}, | ||
{ | ||
b: 'section3 table row2 col2 primary-cta', | ||
a: 'main > div:nth-child(3) .table > div:nth-child(2) > div:nth-child(2) p strong a', | ||
}, | ||
{ | ||
b: 'section3 table row5 col2', | ||
a: 'main > div:nth-child(3) .table > div:nth-child(5) > div:nth-child(2)', | ||
}, | ||
{ | ||
b: 'section3 table row2 col4 secondary-cta', | ||
a: 'main > div:nth-child(3) .table > div:nth-child(2) > div:nth-child(4) p em a', | ||
}, | ||
{ | ||
b: 'section4 merch-card', | ||
a: 'main > div:nth-child(4) .merch-card', | ||
}, | ||
{ | ||
b: 'section5 tabs col2 row2', | ||
a: 'main > div:nth-child(5) .tabs > div:nth-child(2) > div:nth-child(2)', | ||
}, | ||
{ | ||
b: 'section8 table row4 col2', | ||
a: 'main > div:nth-child(8) .table > div:nth-child(4) > div:nth-child(2)', | ||
}, | ||
{ | ||
b: 'section5', | ||
a: 'main > div:nth-child(5)', | ||
}, | ||
{ | ||
b: '.text:has(#im-a-unique-text-block) secondary-cta', | ||
a: '.text:has(#im-a-unique-text-block) p em a', | ||
}, | ||
{ | ||
b: 'section1 .random-block2', | ||
a: 'main > div:nth-child(1) .random-block:nth-child(2 of .random-block)', | ||
}, | ||
{ | ||
b: 'main > section30', | ||
a: 'main > div:nth-child(30)', | ||
}, | ||
{ | ||
b: 'main>section30', | ||
a: 'main > div:nth-child(30)', | ||
}, | ||
{ | ||
b: 'main>div:nth-child(30)', | ||
a: 'main > div:nth-child(30)', | ||
}, | ||
{ | ||
b: 'custom-block3', | ||
a: '.custom-block:nth-child(3 of .custom-block)', | ||
}, | ||
]; | ||
describe('test different values', () => { | ||
values.forEach((value) => { | ||
it(`should return the expected value for ${value.b}`, () => { | ||
expect(modifyNonFragmentSelector(value.b).trim()).to.equal(value.a.trim()); | ||
}); | ||
}); | ||
}); |