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

manifest_row_spec.js « components « dependency_proxy « packages_and_registries « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: be3236d1f9c46e08590a4385634921cd1912f71f (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { GlSprintf } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ListItem from '~/vue_shared/components/registry/list_item.vue';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import Component from '~/packages_and_registries/dependency_proxy/components/manifest_row.vue';
import { MANIFEST_PENDING_DESTRUCTION_STATUS } from '~/packages_and_registries/dependency_proxy/constants';
import { proxyManifests } from 'jest/packages_and_registries/dependency_proxy/mock_data';

describe('Manifest Row', () => {
  let wrapper;

  const defaultProps = {
    manifest: proxyManifests()[0],
  };

  const createComponent = (propsData = defaultProps) => {
    wrapper = shallowMountExtended(Component, {
      propsData,
      stubs: {
        GlSprintf,
        TimeagoTooltip,
        ListItem,
      },
    });
  };

  const findListItem = () => wrapper.findComponent(ListItem);
  const findCachedMessages = () => wrapper.findByTestId('cached-message');
  const findTimeAgoTooltip = () => wrapper.findComponent(TimeagoTooltip);
  const findStatus = () => wrapper.findByTestId('status');

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

  describe('With a manifest on the DEFAULT status', () => {
    beforeEach(() => {
      createComponent();
    });

    it('has a list item', () => {
      expect(findListItem().exists()).toBe(true);
    });

    it('displays the name', () => {
      expect(wrapper.text()).toContain('alpine');
    });

    it('displays the version', () => {
      expect(wrapper.text()).toContain('latest');
    });

    it('displays the cached time', () => {
      expect(findCachedMessages().text()).toContain('Cached');
    });

    it('has a time ago tooltip component', () => {
      expect(findTimeAgoTooltip().props()).toMatchObject({
        time: defaultProps.manifest.createdAt,
      });
    });

    it('does not have a status element displayed', () => {
      expect(findStatus().exists()).toBe(false);
    });
  });

  describe('With a manifest on the PENDING_DESTRUCTION_STATUS', () => {
    const pendingDestructionManifest = {
      manifest: {
        ...defaultProps.manifest,
        status: MANIFEST_PENDING_DESTRUCTION_STATUS,
      },
    };

    beforeEach(() => {
      createComponent(pendingDestructionManifest);
    });

    it('has a list item', () => {
      expect(findListItem().exists()).toBe(true);
    });

    it('has a status element displayed', () => {
      expect(findStatus().exists()).toBe(true);
      expect(findStatus().text()).toBe('Scheduled for deletion');
    });
  });
});