UNPKG

light-bolt11-decoder

Version:

<a href="https://nbd.wtf"><img align="right" height="196" src="https://user-images.githubusercontent.com/1653275/194609043-0add674b-dd40-41ed-986c-ab4a2e053092.png" /></a>

42 lines (34 loc) 1.21 kB
// @flow function assertElement(element) { if (!(element instanceof HTMLElement)) { throw new Error('Must pass a DOM element to find/findAll(element, styledComponent)"'); } } function assertStyledComponent(styledComponent) { if ( !(styledComponent.styledComponentId && typeof styledComponent.styledComponentId === 'string') ) { throw new Error( `${styledComponent.displayName || styledComponent.name || 'Component'} is not a styled component.` ); } } function enzymeFind(wrapper /* : Object */, styledComponent /* : Object */) { assertStyledComponent(styledComponent); return wrapper.find(`.${styledComponent.styledComponentId}`); } function find(element /* : Element */, styledComponent /* : Object */) { assertElement(element); assertStyledComponent(styledComponent); return element.querySelector(`.${styledComponent.styledComponentId}`); } function findAll(element /* : Element */, styledComponent /* : Object */) { assertElement(element); assertStyledComponent(styledComponent); return element.querySelectorAll(`.${styledComponent.styledComponentId}`); } exports.enzymeFind = enzymeFind; exports.find = find; exports.findAll = findAll;