debian-mirror-gitlab/spec/frontend/snippets/utils/error_spec.js

17 lines
776 B
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { getErrorMessage, UNEXPECTED_ERROR } from '~/snippets/utils/error';
describe('~/snippets/utils/error', () => {
describe('getErrorMessage', () => {
it.each`
input | output
${null} | ${UNEXPECTED_ERROR}
${'message'} | ${'message'}
${new Error('test message')} | ${'test message'}
${{ networkError: 'Network error: test message' }} | ${'Network error: test message'}
${{}} | ${UNEXPECTED_ERROR}
`('with $input, should return "$output"', ({ input, output }) => {
expect(getErrorMessage(input)).toBe(output);
});
});
});