1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import { GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import LfsViewer from '~/repository/components/blob_viewers/lfs_viewer.vue';
describe('LFS Viewer', () => {
let wrapper;
const DEFAULT_BLOB_DATA = {
name: 'file_name.js',
rawPath: '/some/file/path',
};
const createComponent = (blobData = {}) => {
wrapper = shallowMount(LfsViewer, {
propsData: { blob: { ...DEFAULT_BLOB_DATA, ...blobData } },
stubs: { GlSprintf },
});
};
const findLink = () => wrapper.findComponent(GlLink);
beforeEach(() => createComponent());
it('renders the correct text', () => {
expect(wrapper.text()).toBe(
'This content could not be displayed because it is stored in LFS. You can download it instead.',
);
});
it('renders download link', () => {
const { rawPath, name } = DEFAULT_BLOB_DATA;
expect(findLink().attributes()).toMatchObject({
target: '_blank',
href: rawPath,
download: name,
});
});
it('renders the correct link href when stored externally', () => {
const externalStorageUrl = 'https://cdn.test.com/project/some/file.js?token=1234';
createComponent({ externalStorageUrl });
expect(findLink().attributes('href')).toBe(externalStorageUrl);
});
});
|