summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/vue_shared/components/table_pagination_spec.js39
1 files changed, 33 insertions, 6 deletions
diff --git a/spec/javascripts/vue_shared/components/table_pagination_spec.js b/spec/javascripts/vue_shared/components/table_pagination_spec.js
index 895e1c585b4..ec5161ef966 100644
--- a/spec/javascripts/vue_shared/components/table_pagination_spec.js
+++ b/spec/javascripts/vue_shared/components/table_pagination_spec.js
@@ -105,21 +105,48 @@ describe('Pagination component', () => {
expect(changeChanges.one).toEqual(1);
});
- it('should do nothing', () => {
+ it('should not call change callback if clicked link is disabled', () => {
+ const spy = jasmine.createSpy('spy');
+
component = new PaginationComponent({
propsData: {
pageInfo: {
- totalPages: 10,
nextPage: 2,
- previousPage: '',
+ page: 1,
+ perPage: 20,
+ previousPage: NaN,
+ total: 84,
+ totalPages: 5,
},
- change,
+ change: spy,
},
}).$mount();
- component.changePage({ target: { innerText: '...' } });
+ component.$el.querySelector('a').click();
- expect(changeChanges.one).toEqual(1);
+ expect(spy).not.toHaveBeenCalled();
+ });
+
+ it('should call change callback when link is clicked', () => {
+ const spy = jasmine.createSpy('spy');
+
+ component = new PaginationComponent({
+ propsData: {
+ pageInfo: {
+ nextPage: 3,
+ page: 2,
+ perPage: 20,
+ previousPage: 1,
+ total: 84,
+ totalPages: 5,
+ },
+ change: spy,
+ },
+ }).$mount();
+
+ component.$el.querySelector('a').click();
+
+ expect(spy).toHaveBeenCalled();
});
});