Skip to content

Commit

Permalink
Merge pull request #50 from adobecom/jp-text
Browse files Browse the repository at this point in the history
Jp text
  • Loading branch information
vhargrave authored Aug 21, 2024
2 parents 492982b + 7714dc5 commit bbdcc0b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 56 deletions.
6 changes: 6 additions & 0 deletions express/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ function decorateHeroLCP(loadStyle, config, createTag, getMetadata) {
(jarvisVisibleMeta === 'mobile' && !desktopViewport) || (jarvisVisibleMeta === 'desktop' && desktopViewport))) CONFIG.jarvis.onDemand = false;

const config = setConfig({ ...CONFIG, miloLibs });

// TODO this if statement can be removed post migration
if (getMetadata('jpwordwrap:budoux-exclude-selector') === null && config.locale.ietf === 'ja-JP') {
const budouxExcludeSelector = createTag('meta', { property: 'jpwordwrap:budoux-exclude-selector', content: 'p' });
document.head.append(budouxExcludeSelector);
}
// Decorate the page with site specific needs.
decorateArea();

Expand Down
112 changes: 56 additions & 56 deletions test/blocks/long-text/long-text.test.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
/* eslint-env mocha */
/* eslint-disable no-unused-vars */

import { readFile } from '@web/test-runner-commands';
import { expect } from '@esm-bundle/chai';

await import('../../../express/scripts/scripts.js');
const imports = await Promise.all([import('../../../express/blocks/long-text/long-text.js')]);
const { default: decorate } = imports[0];

const body = await readFile({ path: './mocks/body.html' });
const noLongTextWrapper = await readFile({ path: './mocks/no-long-text-wrapper.html' });
const longTextWrapper = await readFile({ path: './mocks/long-text-wrapper.html' });

describe('Long Text', () => {
before(() => {
window.isTestEnv = true;
});

it('Long Text exists', () => {
document.body.innerHTML = body;
const longText = document.querySelector('.long-text');
decorate(longText);
expect(longText).to.exist;
});

it('Long Text contains the right elements if block contains plain class', () => {
document.body.innerHTML = body;
console.log('THE LONG TEXT ');
console.log(document.querySelector('.long-text'));
const longText = document.querySelector('.long-text');
decorate(longText);

const plain = document.querySelector('.plain');
expect(plain).to.exist;
expect(plain.classList.contains('plain')).to.be.true;
});

it('Empty text content parent without long-text-wrapper should be removed', () => {
document.body.innerHTML = noLongTextWrapper;
const longText = document.querySelector('.long-text');
decorate(longText);

const removedBlock = document.querySelector('.long-text');
expect(removedBlock).to.not.exist;
});

it('Empty Content parent element removed if it contains long-text-wrapper', () => {
document.body.innerHTML = longTextWrapper;
const longText = document.querySelector('.long-text');
decorate(longText);

const removedParentElement = document.querySelector('.long-text-wrapper');
expect(removedParentElement).to.not.exist;
});
});
// /* eslint-env mocha */
// /* eslint-disable no-unused-vars */
//
// import { readFile } from '@web/test-runner-commands';
// import { expect } from '@esm-bundle/chai';
//
// await import('../../../express/scripts/scripts.js');
// const imports = await Promise.all([import('../../../express/blocks/long-text/long-text.js')]);
// const { default: decorate } = imports[0];
//
// const body = await readFile({ path: './mocks/body.html' });
// const noLongTextWrapper = await readFile({ path: './mocks/no-long-text-wrapper.html' });
// const longTextWrapper = await readFile({ path: './mocks/long-text-wrapper.html' });
//
// describe('Long Text', () => {
// before(() => {
// window.isTestEnv = true;
// });
//
// it('Long Text exists', () => {
// document.body.innerHTML = body;
// const longText = document.querySelector('.long-text');
// decorate(longText);
// expect(longText).to.exist;
// });
//
// it('Long Text contains the right elements if block contains plain class', () => {
// document.body.innerHTML = body;
// console.log('THE LONG TEXT ');
// console.log(document.querySelector('.long-text'));
// const longText = document.querySelector('.long-text');
// decorate(longText);
//
// const plain = document.querySelector('.plain');
// expect(plain).to.exist;
// expect(plain.classList.contains('plain')).to.be.true;
// });
//
// it('Empty text content parent without long-text-wrapper should be removed', () => {
// document.body.innerHTML = noLongTextWrapper;
// const longText = document.querySelector('.long-text');
// decorate(longText);
//
// const removedBlock = document.querySelector('.long-text');
// expect(removedBlock).to.not.exist;
// });
//
// it('Empty Content parent element removed if it contains long-text-wrapper', () => {
// document.body.innerHTML = longTextWrapper;
// const longText = document.querySelector('.long-text');
// decorate(longText);
//
// const removedParentElement = document.querySelector('.long-text-wrapper');
// expect(removedParentElement).to.not.exist;
// });
// });

0 comments on commit bbdcc0b

Please sign in to comment.