How to use the @stylable/dom-test-kit.StylableDOMUtilCompat function in @stylable/dom-test-kit

To help you get started, we’ve selected a few @stylable/dom-test-kit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wix / wix-ui-backoffice / src / components / Heading / Heading.driver.ts View on Github external
export const headingDriverFactory = (factoryParams: ComponentFactory): HeadingDriver => {
  const coreTextDriver = textDriverFactory(factoryParams);
  const stylableDOMUtil = new StylableDOMUtilCompat(style);
  const { element } = factoryParams;

  return {
    ...coreTextDriver,
    getAppearance: () => stylableDOMUtil.getStyleState(element, 'appearance') as Appearance,
    isLight: () => stylableDOMUtil.hasStyleState(element, 'light'),
  };
};
github wix / wix-ui-backoffice / src / components / core / CoreText / Text.driver.ts View on Github external
export const textDriverFactory: DriverFactory = ({element}) => {
  const stylableDOMUtil = new StylableDOMUtilCompat(style);

  return {
    /** check if element exists */
    exists: () => !!element,
    /** check if component has ellipsis */
    hasEllipsis: () => stylableDOMUtil.hasStyleState(element, 'ellipsis'),
    /** check if element has title attribute */
    hasTitleAttribute: () => element.getAttribute('title') !== null,
    /** check if element has title attribute */
    getTitle: () => (element as HTMLElement).title,
    /** get the rendered tag name */
    getTagName: () => element.tagName.toLowerCase(),
    /** get the rendered content */
    getText: () => element.innerHTML
  };
};
github wix / wix-ui-backoffice / src / components / Badge / Badge.driver.ts View on Github external
export const badgeDriverFactory = (factoryParams: ComponentFactory): BadgeDriver => {
  const { element, eventTrigger } = factoryParams;
  const stylableDOMUtil = new StylableDOMUtilCompat(style, element);

  return {
    /** checks if element exists */
    exists: () => !!element,
    /** returns elements innerHtml */
    getContent: () => element.innerHTML,
    /** returns elements text */
    text: () => element.textContent,
    getType: () => stylableDOMUtil.getStyleState(element, 'type') as Type,
    getSkin: () => stylableDOMUtil.getStyleState(element, 'skin') as Skin,
    getSize: () => stylableDOMUtil.getStyleState(element, 'size') as Size,
    isUppercase: () => stylableDOMUtil.getStyleState(element, 'uppercase') === 'true',
    hasClickCursor: () => stylableDOMUtil.getStyleState(element, 'clickable') === 'true',
    getPrefixIcon: () => stylableDOMUtil.select('.prefix'),
    getSuffixIcon: () => stylableDOMUtil.select('.suffix'),
    click: () => eventTrigger.click(element)

@stylable/dom-test-kit

Stylable DOM testing utilities

MIT
Latest version published 5 months ago

Package Health Score

63 / 100
Full package analysis