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', () => { ...@@ -359,31 +359,16 @@ describe('common_utils', () => {
}); });
describe('parseBoolean', () => { describe('parseBoolean', () => {
const { parseBoolean } = commonUtils; it.each`
input | expected
it('returns true for "true"', () => { ${'true'} | ${true}
expect(parseBoolean('true')).toEqual(true); ${'false'} | ${false}
}); ${'something'} | ${false}
${null} | ${false}
it('returns false for "false"', () => { ${true} | ${true}
expect(parseBoolean('false')).toEqual(false); ${false} | ${false}
}); `('returns $expected for $input', ({ input, expected }) => {
expect(commonUtils.parseBoolean(input)).toBe(expected);
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);
});
}); });
}); });
......
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