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

paginated_list_spec.js « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9f819cc4e94fc090ef84aea8312cfd7aae8091ee (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
import { mount } from '@vue/test-utils';
import PaginatedList from '~/vue_shared/components/paginated_list.vue';
import { PREV, NEXT } from '~/vue_shared/components/pagination/constants';

describe('Pagination links component', () => {
  let wrapper;
  let glPaginatedList;

  const template = `
    <template #default="{ listItem }">
      <div class="slot">
        <span class="item">Item Name: {{ listItem.id }}</span>
      </div>
    </template>
  `;

  const props = {
    prevText: PREV,
    nextText: NEXT,
  };

  beforeEach(() => {
    wrapper = mount(PaginatedList, {
      scopedSlots: {
        default: template,
      },
      propsData: {
        list: [{ id: 'foo' }, { id: 'bar' }],
        props,
      },
    });

    [glPaginatedList] = wrapper.vm.$children;
  });

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

  describe('Paginated List Component', () => {
    describe('props', () => {
      // We test attrs and not props because we pass through to child component using v-bind:"$attrs"
      it('should pass prevText to GitLab UI paginated list', () => {
        expect(glPaginatedList.$attrs['prev-text']).toBe(props.prevText);
      });
      it('should pass nextText to GitLab UI paginated list', () => {
        expect(glPaginatedList.$attrs['next-text']).toBe(props.nextText);
      });
    });

    describe('rendering', () => {
      it('it renders the gl-paginated-list', () => {
        expect(wrapper.find('ul.list-group').exists()).toBe(true);
        expect(wrapper.findAll('li.list-group-item').length).toBe(2);
      });
    });
  });
});