UNPKG

fonteva-design-guide

Version:

## Dev, Build and Test

44 lines (37 loc) 1.34 kB
import { createElement } from 'lwc'; import SUMMARY from 'c/pfmOrderTotals'; describe('c-pfm-order-totals', () => { let element; beforeEach(() => { element = createElement('c-pfm-order-totals', { is: SUMMARY }); }); 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('total', () => { element.items = [ { name: 'foo', total: 5 }, { name: 'bar', total: 10 } ]; element.currencyIsoCode = 'USD'; document.body.appendChild(element); return Promise.resolve().then(() => { const pfmCurrency = element.shadowRoot.querySelector('c-pfm-currency[data-name="total"]'); expect(pfmCurrency.val).toBe(15); }); }); it('no items', () => { element.items = []; element.currencyIsoCode = 'USD'; document.body.appendChild(element); return Promise.resolve().then(() => { const pfmCurrency = element.shadowRoot.querySelector('c-pfm-currency[data-name="total"]'); expect(pfmCurrency.val).toBe(0); }); }); });