How to use jest-each - 10 common examples

To help you get started, we’ve selected a few jest-each 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 learningequality / studio / contentcuration / contentcuration / frontend / channelEdit / vuex / contentNode / __tests__ / utils.spec.js View on Github external
},
        [ValidationErrors.COPYRIGHT_HOLDER_REQUIRED],
      ],
      [
        {
          title: 'Title',
          license: 1,
          copyright_holder: 'Copyright holder',
        },
        [],
      ],
    ]).it('validates copyright holder', (node, errors) => {
      expect(validateNodeDetails(node)).toEqual(errors);
    });

    each([
      // description is required for a custom license
      [
        {
          title: 'Title',
          license: 9,
          copyright_holder: 'Copyright holder',
        },
        [ValidationErrors.LICENCE_DESCRIPTION_REQUIRED],
      ],
      [
        {
          title: 'Title',
          license: 9,
          copyright_holder: 'Copyright holder',
          license_description: 'My custom license',
        },
github MisRob / vue-tree-navigation / src / components / utils.spec.js View on Github external
describe('startsWithUrl', () => {
    each([
      [true, '/path', '/path'],
      [true, '/path#element', '/path'],
      [true, '/path/another_path', '/path'],
      [true, '/#element', '/#element'],
      [true, '/path', '/path#element'], // ignores an element
      [false, '/another_path', '/path'],
      [false, '/', '/path'],
    ]).it(
      'returns %s for parent URL %s and URL %s',
      (expected, parentUrl, url) => {
        expect(startsWithUrl(parentUrl, url)).toBe(expected);
      }
    );
  });
github DefinitelyTyped / DefinitelyTyped / types / jest-each / jest-each-tests.ts View on Github external
import each from "jest-each";

const params = [[1, 0, 1], [1, 1, 0], ['1', 'two', 'three']];

each(params).test('', () => {});
each(params).it('', () => {});
each(params).test.only('', () => {});
each(params).it.only('', () => {});
each(params).fit('', () => {});
each(params).test.skip('', () => {});
each(params).it.skip('', () => {});
each(params).xit('', () => {});
each(params).xtest('', () => {});

each(params).describe('', () => {});
each(params).describe.only('', () => {});
each(params).fdescribe('', () => {});
each(params).describe.skip('', () => {});
each(params).xdescribe('', () => {});
github DefinitelyTyped / DefinitelyTyped / types / jest-each / jest-each-tests.ts View on Github external
import each from "jest-each";

const params = [[1, 0, 1], [1, 1, 0], ['1', 'two', 'three']];

each(params).test('', () => {});
each(params).it('', () => {});
each(params).test.only('', () => {});
each(params).it.only('', () => {});
each(params).fit('', () => {});
each(params).test.skip('', () => {});
each(params).it.skip('', () => {});
each(params).xit('', () => {});
each(params).xtest('', () => {});

each(params).describe('', () => {});
each(params).describe.only('', () => {});
each(params).fdescribe('', () => {});
each(params).describe.skip('', () => {});
each(params).xdescribe('', () => {});
github DefinitelyTyped / DefinitelyTyped / types / jest-each / jest-each-tests.ts View on Github external
each(params).test('', () => {});
each(params).it('', () => {});
each(params).test.only('', () => {});
each(params).it.only('', () => {});
each(params).fit('', () => {});
each(params).test.skip('', () => {});
each(params).it.skip('', () => {});
each(params).xit('', () => {});
each(params).xtest('', () => {});

each(params).describe('', () => {});
each(params).describe.only('', () => {});
each(params).fdescribe('', () => {});
each(params).describe.skip('', () => {});
each(params).xdescribe('', () => {});
github DefinitelyTyped / DefinitelyTyped / types / jest-each / jest-each-tests.ts View on Github external
const params = [[1, 0, 1], [1, 1, 0], ['1', 'two', 'three']];

each(params).test('', () => {});
each(params).it('', () => {});
each(params).test.only('', () => {});
each(params).it.only('', () => {});
each(params).fit('', () => {});
each(params).test.skip('', () => {});
each(params).it.skip('', () => {});
each(params).xit('', () => {});
each(params).xtest('', () => {});

each(params).describe('', () => {});
each(params).describe.only('', () => {});
each(params).fdescribe('', () => {});
each(params).describe.skip('', () => {});
each(params).xdescribe('', () => {});
github MisRob / vue-tree-navigation / src / components / utils.spec.js View on Github external
describe('sanitizeElement', () => {
    each([
      [undefined, undefined],
      ['', ''],
      ['#element', '#element'],
      ['#element', 'element'],
    ]).it('returns %s for path %s', (expected, element) => {
      expect(sanitizeElement(element)).toBe(expected);
    });
  });
github SpareBank1 / designsystem / packages / ffe-form-react / src / RadioSwitch.spec.js View on Github external
const wrapper = getWrapper();
        expect(wrapper.find('BaseRadioButton')).toHaveLength(2);

        const leftOne = wrapper.find('BaseRadioButton').first();
        const rightOne = wrapper.find('BaseRadioButton').last();

        expect(leftOne.prop('children')).toBe(defaultProps.leftLabel);
        expect(leftOne.prop('value')).toBe(defaultProps.leftValue);
        expect(leftOne.prop('name')).toBe(defaultProps.name);

        expect(rightOne.prop('children')).toBe(defaultProps.rightLabel);
        expect(rightOne.prop('value')).toBe(defaultProps.rightValue);
        expect(rightOne.prop('name')).toBe(defaultProps.name);
    });

    each([
        [undefined, undefined],
        [null, null],
        ['', ''],
        [defaultProps.leftValue, defaultProps.leftValue],
        [defaultProps.rightValue, defaultProps.rightValue],
    ]).test(
        'returns the correct value of selectedValue when input selected value is %s',
        (selectedValue, expectedSelectedValue) => {
            const wrapper = getWrapper({
                selectedValue: selectedValue,
            });
            expect(wrapper.find('BaseRadioButton')).toHaveLength(2);

            const leftOne = wrapper.find('BaseRadioButton').first();
            const rightOne = wrapper.find('BaseRadioButton').last();
github MisRob / vue-tree-navigation / src / components / utils.spec.js View on Github external
describe('sanitizeRoute', () => {
    each([
      [undefined, undefined],
      ['', ''],
      ['/route', '/route'],
      ['/route', 'route'],
      ['/route', 'route/'],
    ]).it('returns %s for path %s', (expected, route) => {
      expect(sanitizeRoute(route)).toBe(expected);
    });
  });
});
github MisRob / vue-tree-navigation / src / components / utils.spec.js View on Github external
describe('getRelativeUrl', () => {
    each([
      ['', '', ''],
      ['/path', 'http://site.io/path', 'http://site.io'],
      ['/path', 'http://site.io/path', 'http://site.io/'],
      ['/path#element', 'http://site.io/path#element', 'http://site.io'],
      ['/#element', 'http://site.io/#element', 'http://site.io'],
      ['/path', 'http://site.io/#/path', 'http://site.io'],
      ['/path#element', 'http://site.io/#/path#element', 'http://site.io'],
      ['/#element', 'http://site.io/#/#element', 'http://site.io'],
    ]).it('returns %s for URL %s and origin %s', (expected, url, origin) => {
      expect(getRelativeUrl(url, origin)).toBe(expected);
    });
  });

jest-each

Parameterised tests for Jest

MIT
Latest version published 1 year ago

Package Health Score

88 / 100
Full package analysis

Popular jest-each functions