Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
[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',
},
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);
}
);
});
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('', () => {});
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('', () => {});
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('', () => {});
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('', () => {});
describe('sanitizeElement', () => {
each([
[undefined, undefined],
['', ''],
['#element', '#element'],
['#element', 'element'],
]).it('returns %s for path %s', (expected, element) => {
expect(sanitizeElement(element)).toBe(expected);
});
});
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();
describe('sanitizeRoute', () => {
each([
[undefined, undefined],
['', ''],
['/route', '/route'],
['/route', 'route'],
['/route', 'route/'],
]).it('returns %s for path %s', (expected, route) => {
expect(sanitizeRoute(route)).toBe(expected);
});
});
});
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);
});
});