Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

enzyme consumer for react-component-variations

License

Notifications You must be signed in to change notification settings

airbnb/react-component-variations-consumer-enzyme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

❗ Deprecation Notice
We want to express our sincere gratitude for your support and contributions to this open source project. As we are no longer using this technology internally, we have come to the decision to archive this repository. While we won't be providing further updates or support, the existing code and resources will remain accessible for your reference. We encourage anyone interested to fork the repository and continue the project's legacy independently. Thank you for being a part of this journey and for your patience and understanding.

react-component-variations-consumer-enzyme

enzyme consumer for react-component-variations

Example using jest:

import React from 'react';
import { expect } from 'chai';
import { render as staticRender, shallow } from 'enzyme';
import wrap from 'jest-wrap';
import forEachVariation from 'react-component-variations/traversal/forEachVariation';

import fixtures from '../variations/fixtures'; // fixture data

const action = () => () => {}; // used by storybook

// a jest-wrap plugin (usually this would be in its own module)
const isDOM = typeof window !== 'undefined';
function withDOM() {
  return isDOM
    ? this.extend('with DOM', {})
    : this.extend('without DOM', {}).skip();
}

import enzymeTests from 'react-component-variations-consumer-enzyme';

enzymeTests((name, { title, validTest, noThrowTest }) => {
  describe(`<${name}> ${title}`, () => {
    validTest((description, testFn) => {
      it(description, () => {
        expect(testFn()).to.equal(true);
      });
    });

    noThrowTest((description, testFn, requiresDOM = false) => {
      if (requiresDOM) {
        wrap().use(withDOM).it(description, () => {
          expect(() => testFn()).not.to.throw();
        });
      } else {
        it(description, () => {
          expect(() => testFn()).not.to.throw();
        });
      }
    });
  });
}, {
  getExtras() { return { action, fixtures }; },
});

About

enzyme consumer for react-component-variations

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published