summaryrefslogtreecommitdiff
path: root/spec/frontend/packages_and_registries/harbor_registry/components/list/harbor_list_spec.js
blob: f018eff58c9f6780f91f0b3bcdc21ccb196024f9 (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
import { shallowMount } from '@vue/test-utils';
import HarborList from '~/packages_and_registries/harbor_registry/components/list/harbor_list.vue';
import HarborListRow from '~/packages_and_registries/harbor_registry/components/list/harbor_list_row.vue';
import RegistryList from '~/packages_and_registries/shared/components/registry_list.vue';
import { harborListResponse } from '../../mock_data';

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

  const findHarborListRow = () => wrapper.findAll(HarborListRow);

  const mountComponent = (props) => {
    wrapper = shallowMount(HarborList, {
      stubs: { RegistryList },
      propsData: {
        images: harborListResponse.repositories,
        pageInfo: harborListResponse.pageInfo,
        ...props,
      },
    });
  };

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

  describe('list', () => {
    it('contains one list element for each image', () => {
      mountComponent();

      expect(findHarborListRow().length).toBe(harborListResponse.repositories.length);
    });

    it('passes down the metadataLoading prop', () => {
      mountComponent({ metadataLoading: true });
      expect(findHarborListRow().at(0).props('metadataLoading')).toBe(true);
    });
  });
});