Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lfs_viewer_spec.js « blob_viewers « components « repository « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5caeb85834d964c1188438df8d53823bc5ab48c3 (plain)
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
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 = () => {
    wrapper = shallowMount(LfsViewer, {
      propsData: { blob: { ...DEFAULT_BLOB_DATA } },
      stubs: { GlSprintf },
    });
  };

  const findLink = () => wrapper.findComponent(GlLink);

  beforeEach(() => createComponent());

  afterEach(() => wrapper.destroy());

  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,
    });
  });
});