generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MWPW-158142 [MEP] check for MEP placeholders as fragmentless content …
…is inserted (#2919) * Initial checkin. Working state. * Code refactor. * Unit test initial checkin. * Refactor into reusable function. * Removed old code. * Linting. * update unit test to call create content --------- Co-authored-by: vgoodric <[email protected]>
- Loading branch information
1 parent
71416c8
commit 130b5e0
Showing
2 changed files
with
40 additions
and
23 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
32 changes: 22 additions & 10 deletions
32
test/features/personalization/parseNestedPlaceholders.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 |
---|---|---|
@@ -1,19 +1,31 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { parseNestedPlaceholders } from '../../../libs/features/personalization/personalization.js'; | ||
import { parseNestedPlaceholders, createContent } from '../../../libs/features/personalization/personalization.js'; | ||
import { getConfig } from '../../../libs/utils/utils.js'; | ||
|
||
const config = { | ||
placeholders: { | ||
'promo-product-name': 'CC All Apps', | ||
'promo-header': 'Buy now and save {{promo-discount}}% off {{promo-product-name}}.', | ||
'promo-discount': '50', | ||
'promo-description': 'For just {{promo-price}}, get 20+...', | ||
'promo-price': 'US$49.99', | ||
}, | ||
const config = getConfig(); | ||
config.placeholders = { | ||
'promo-product-name': 'CC All Apps', | ||
'promo-header': 'Buy now and save {{promo-discount}}% off {{promo-product-name}}.', | ||
'promo-discount': '50', | ||
'promo-description': 'For just {{promo-price}}, get 20+...', | ||
'promo-price': 'US$49.99', | ||
}; | ||
describe('test different values', () => { | ||
describe('test different values for parseNestedPlaceholders', () => { | ||
it('should update placeholders', () => { | ||
parseNestedPlaceholders(config); | ||
expect(config.placeholders['promo-header']).to.equal('Buy now and save 50% off CC All Apps.'); | ||
expect(config.placeholders['promo-description']).to.equal('For just US$49.99, get 20+...'); | ||
}); | ||
}); | ||
describe('test createContent', () => { | ||
const el = document.createElement('div'); | ||
it('append action', () => { | ||
const newContent = createContent(el, '{{promo-discount}}', false, false, 'append', []); | ||
expect(newContent.innerHTML).to.equal('50'); | ||
}); | ||
it('replace action', () => { | ||
el.innerHTML = 'Hello World'; | ||
const newContent = createContent(el, '{{promo-discount}}', false, false, 'replace', []); | ||
expect(newContent.innerHTML).to.equal('50'); | ||
}); | ||
}); |