Skip to content

Commit

Permalink
Work on unit test for RenderlessPagination component
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbitron committed Nov 10, 2023
1 parent 7ff8351 commit afd0b04
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/unit/RenderlessPagination.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { mount } from '@vue/test-utils';
import RenderlessPagination from '@/RenderlessPagination.vue';

var paginateData = {
current_page: 1,
data: [...Array(10).keys()],
first_page_url: 'https://example.com/pagination?page=1',
from: 1,
last_page: 10,
last_page_url: 'https://example.com/pagination?page=10',
next_page_url: 'https://example.com/pagination?page=2',
path: 'https://example.com/pagination',
per_page: 10,
prev_page_url: null,
to: 10,
total: 100,
};

test('parses paginate data', function () {
const wrapper = mount(RenderlessPagination, {
slots: {
default: '<div></div>',
},
propsData: {
data: paginateData,
},
});

expect(wrapper.vm.isApiResource).toEqual(false);
expect(wrapper.vm.currentPage).toEqual(paginateData.current_page);
expect(wrapper.vm.firstPageUrl).toEqual(paginateData.first_page_url);
expect(wrapper.vm.from).toEqual(paginateData.from);
expect(wrapper.vm.lastPage).toEqual(paginateData.last_page);
expect(wrapper.vm.lastPageUrl).toEqual(paginateData.last_page_url);
expect(wrapper.vm.nextPageUrl).toEqual(paginateData.next_page_url);
expect(wrapper.vm.perPage).toEqual(paginateData.per_page);
expect(wrapper.vm.prevPageUrl).toEqual(paginateData.prev_page_url);
expect(wrapper.vm.to).toEqual(paginateData.to);
expect(wrapper.vm.total).toEqual(paginateData.total);
//expect(wrapper.vm.pageRange).toEqual(1);
});

0 comments on commit afd0b04

Please sign in to comment.