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

tags_header_spec.js « tags « components « harbor_registry « packages_and_registries « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e299a269e3d94ce95a4c7aba76c0097eb063f6b (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
42
43
44
45
46
47
48
49
50
51
52
import { nextTick } from 'vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import TagsHeader from '~/packages_and_registries/harbor_registry/components/tags/tags_header.vue';
import TitleArea from '~/vue_shared/components/registry/title_area.vue';
import { mockArtifactDetail, MOCK_SHA_DIGEST } from '../../mock_data';

describe('Harbor Tags Header', () => {
  let wrapper;

  const findTitle = () => wrapper.findByTestId('title');
  const findTagsCount = () => wrapper.findByTestId('tags-count');

  const mountComponent = ({ propsData }) => {
    wrapper = shallowMountExtended(TagsHeader, {
      propsData,
      stubs: {
        TitleArea,
      },
    });
  };

  const mockPageInfo = {
    page: 1,
    perPage: 20,
    total: 1,
    totalPages: 1,
  };

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

  beforeEach(() => {
    mountComponent({
      propsData: { artifactDetail: mockArtifactDetail, pageInfo: mockPageInfo, tagsLoading: false },
    });
  });

  describe('tags title', () => {
    it('should be artifact digest', () => {
      expect(findTitle().text()).toBe(`sha256:${MOCK_SHA_DIGEST}`);
    });
  });

  describe('tags count', () => {
    it('would has the correct text', async () => {
      await nextTick();

      expect(findTagsCount().props('text')).toBe('1 tag');
    });
  });
});