Commit 56f2dd54 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'vs-backport-parse-boolean-test' into 'master'

Switch to it.each for parseBoolean

See merge request gitlab-org/gitlab!27749
parents 6e4cfc73 6769acb9
......@@ -359,31 +359,16 @@ describe('common_utils', () => {
});
describe('parseBoolean', () => {
const { parseBoolean } = commonUtils;
it('returns true for "true"', () => {
expect(parseBoolean('true')).toEqual(true);
});
it('returns false for "false"', () => {
expect(parseBoolean('false')).toEqual(false);
});
it('returns false for "something"', () => {
expect(parseBoolean('something')).toEqual(false);
});
it('returns false for null', () => {
expect(parseBoolean(null)).toEqual(false);
});
it('is idempotent', () => {
const input = ['true', 'false', 'something', null];
input.forEach(value => {
const result = parseBoolean(value);
expect(parseBoolean(result)).toBe(result);
});
it.each`
input | expected
${'true'} | ${true}
${'false'} | ${false}
${'something'} | ${false}
${null} | ${false}
${true} | ${true}
${false} | ${false}
`('returns $expected for $input', ({ input, expected }) => {
expect(commonUtils.parseBoolean(input)).toBe(expected);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment