Commit 43d74305 authored by Scott Hampton's avatar Scott Hampton

Use `it.each` for util spec

Utilize `it.each` to make a cleaner spec file for
the util function.
parent ce6d8bae
...@@ -2,44 +2,16 @@ import { formatFilePath, formattedTime } from '~/pipelines/stores/test_reports/u ...@@ -2,44 +2,16 @@ import { formatFilePath, formattedTime } from '~/pipelines/stores/test_reports/u
describe('Test reports utils', () => { describe('Test reports utils', () => {
describe('formatFilePath', () => { describe('formatFilePath', () => {
describe('when file string starts with "./"', () => { it.each`
it('should return the file string without the beginning "./"', () => { file | expected
const result = formatFilePath('./test.js'); ${'./test.js'} | ${'test.js'}
${'/test.js'} | ${'test.js'}
expect(result).toBe('test.js'); ${'.//////////////test.js'} | ${'test.js'}
}); ${'test.js'} | ${'test.js'}
}); ${'mock/path./test.js'} | ${'mock/path./test.js'}
${'./mock/path./test.js'} | ${'mock/path./test.js'}
describe('when file string starts with "/"', () => { `('should format $file to be $expected', ({ file, expected }) => {
it('should return the file string without the beginning "/"', () => { expect(formatFilePath(file)).toBe(expected);
const result = formatFilePath('/test.js');
expect(result).toBe('test.js');
});
});
describe('when file string starts with more than one "/"', () => {
it('should return the file string without any of the beginning "/"', () => {
const result = formatFilePath('.//////////////test.js');
expect(result).toBe('test.js');
});
});
describe('when file string starts without either "." or "/"', () => {
it('should return the file string without change', () => {
const result = formatFilePath('test.js');
expect(result).toBe('test.js');
});
});
describe('when file string contains but does not start with "./"', () => {
it('should return the file string without change', () => {
const result = formatFilePath('mock/path./test.js');
expect(result).toBe('mock/path./test.js');
});
}); });
}); });
......
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