debian-mirror-gitlab/spec/javascripts/vue_shared/components/pagination_links_spec.js

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-12-05 23:21:45 +05:30
import Vue from 'vue';
import PaginationLinks from '~/vue_shared/components/pagination_links.vue';
import { s__ } from '~/locale';
import mountComponent from '../../helpers/vue_mount_component_helper';
describe('Pagination links component', () => {
const paginationLinksComponent = Vue.extend(PaginationLinks);
const change = page => page;
const pageInfo = {
page: 3,
perPage: 5,
total: 30,
};
const translations = {
firstText: s__('Pagination|« First'),
prevText: s__('Pagination|Prev'),
nextText: s__('Pagination|Next'),
lastText: s__('Pagination|Last »'),
};
let paginationLinks;
let glPagination;
let destinationComponent;
beforeEach(() => {
2018-12-13 13:39:08 +05:30
paginationLinks = mountComponent(paginationLinksComponent, {
change,
pageInfo,
});
2018-12-05 23:21:45 +05:30
[glPagination] = paginationLinks.$children;
[destinationComponent] = glPagination.$children;
});
afterEach(() => {
paginationLinks.$destroy();
});
it('should provide translated text to GitLab UI pagination', () => {
2018-12-13 13:39:08 +05:30
Object.entries(translations).forEach(entry => {
expect(destinationComponent[entry[0]]).toBe(entry[1]);
});
2018-12-05 23:21:45 +05:30
});
it('should pass change to GitLab UI pagination', () => {
2018-12-13 13:39:08 +05:30
expect(Object.is(glPagination.change, change)).toBe(true);
2018-12-05 23:21:45 +05:30
});
it('should pass page from pageInfo to GitLab UI pagination', () => {
2018-12-13 13:39:08 +05:30
expect(destinationComponent.value).toBe(pageInfo.page);
2018-12-05 23:21:45 +05:30
});
it('should pass per page from pageInfo to GitLab UI pagination', () => {
2018-12-13 13:39:08 +05:30
expect(destinationComponent.perPage).toBe(pageInfo.perPage);
2018-12-05 23:21:45 +05:30
});
it('should pass total items from pageInfo to GitLab UI pagination', () => {
2018-12-13 13:39:08 +05:30
expect(destinationComponent.totalRows).toBe(pageInfo.total);
2018-12-05 23:21:45 +05:30
});
});