debian-mirror-gitlab/spec/frontend/blob/components/blob_content_error_spec.js

61 lines
2.2 KiB
JavaScript
Raw Normal View History

2020-03-13 15:44:24 +05:30
import { shallowMount } from '@vue/test-utils';
2020-05-24 23:13:21 +05:30
import { GlSprintf } from '@gitlab/ui';
2020-10-24 23:57:45 +05:30
import BlobContentError from '~/blob/components/blob_content_error.vue';
2020-05-24 23:13:21 +05:30
import { BLOB_RENDER_ERRORS } from '~/blob/components/constants';
2020-03-13 15:44:24 +05:30
describe('Blob Content Error component', () => {
let wrapper;
2020-05-24 23:13:21 +05:30
function createComponent(props = {}) {
2020-03-13 15:44:24 +05:30
wrapper = shallowMount(BlobContentError, {
propsData: {
2020-05-24 23:13:21 +05:30
...props,
},
stubs: {
GlSprintf,
2020-03-13 15:44:24 +05:30
},
});
}
afterEach(() => {
wrapper.destroy();
});
2020-05-24 23:13:21 +05:30
describe('collapsed and too large blobs', () => {
it.each`
2020-07-28 23:09:34 +05:30
error | reason | options
${BLOB_RENDER_ERRORS.REASONS.COLLAPSED} | ${'it is larger than 1.00 MiB'} | ${[BLOB_RENDER_ERRORS.OPTIONS.LOAD.text, BLOB_RENDER_ERRORS.OPTIONS.DOWNLOAD.text]}
${BLOB_RENDER_ERRORS.REASONS.TOO_LARGE} | ${'it is larger than 10.00 MiB'} | ${[BLOB_RENDER_ERRORS.OPTIONS.DOWNLOAD.text]}
2020-05-24 23:13:21 +05:30
`('renders correct reason for $error.id', ({ error, reason, options }) => {
createComponent({
viewerError: error.id,
});
expect(wrapper.text()).toContain(reason);
options.forEach(option => {
expect(wrapper.text()).toContain(option);
});
});
});
describe('external blob', () => {
it.each`
storageType | reason | options
${'lfs'} | ${BLOB_RENDER_ERRORS.REASONS.EXTERNAL.text.lfs} | ${[BLOB_RENDER_ERRORS.OPTIONS.DOWNLOAD.text]}
${'build_artifact'} | ${BLOB_RENDER_ERRORS.REASONS.EXTERNAL.text.build_artifact} | ${[BLOB_RENDER_ERRORS.OPTIONS.DOWNLOAD.text]}
${'default'} | ${BLOB_RENDER_ERRORS.REASONS.EXTERNAL.text.default} | ${[BLOB_RENDER_ERRORS.OPTIONS.DOWNLOAD.text]}
`('renders correct reason for $storageType blob', ({ storageType, reason, options }) => {
createComponent({
viewerError: BLOB_RENDER_ERRORS.REASONS.EXTERNAL.id,
blob: {
externalStorage: storageType,
},
});
expect(wrapper.text()).toContain(reason);
options.forEach(option => {
expect(wrapper.text()).toContain(option);
});
});
2020-03-13 15:44:24 +05:30
});
});