fonteva-design-guide
Version:
## Dev, Build and Test
64 lines (49 loc) • 2.3 kB
JavaScript
import { createElement } from 'lwc';
import COLUMN from 'c/pfmColumn';
import TILE from 'c/pfmTile';
describe('c-pfm-base', () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
while (document.body.firstChild) {
document.body.removeChild(document.body.firstChild);
}
});
it('checking spacing', () => {
const test1 = createElement('c-pfm-column', { is: TILE });
const test2 = createElement('c-pfm-column', { is: TILE });
test1.padding = 'horizontal:medium, vertical:large';
test1.margin = 'top:large, bottom:large';
test2.padding = true;
test2.margin = true;
document.body.appendChild(test1);
document.body.appendChild(test2);
// Verify that text is body
const pHTxt = test1.shadowRoot.querySelector('.pfm-p-horizontal_medium');
const pVTxt = test1.shadowRoot.querySelector('.pfm-p-vertical_large');
const mTTxt = test1.shadowRoot.querySelector('.pfm-m-top_large');
const mBTxt = test1.shadowRoot.querySelector('.pfm-m-bottom_large');
const pBoolean = test2.shadowRoot.querySelector('.pfm-p-horizontal_small');
const mBoolean = test2.shadowRoot.querySelector('.pfm-m-horizontal_small');
expect(pHTxt).not.toBeNull();
expect(pVTxt).not.toBeNull();
expect(mTTxt).not.toBeNull();
expect(mBTxt).not.toBeNull();
expect(pBoolean).not.toBeNull();
expect(mBoolean).not.toBeNull();
});
it('checking show/hide', () => {
const sBlock = createElement('c-pfm-tile', { is: TILE });
const hBlock = createElement('c-pfm-tile', { is: TILE });
sBlock.showAt = 'medium';
hBlock.hideAt = 'medium';
document.body.appendChild(sBlock);
document.body.appendChild(hBlock);
// Verify that text is body
const showAt = sBlock.shadowRoot.querySelector('.slds-show_medium');
const hideAt = hBlock.shadowRoot.querySelector('.slds-hide_medium');
// return Promise.resolve().then(() => {
expect(showAt).not.toBeNull();
expect(hideAt).not.toBeNull();
// });
});
});