diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-07-07 14:27:01 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-07-07 18:09:02 +0100 |
commit | 9803579e2599cb1e560b5f5a654baab8d485bf11 (patch) | |
tree | 40f54270b09de61983ab89741236fd6c5e6d2128 /spec | |
parent | 87d90b5b5e2fa6d0eed469db61878b942afdbee7 (diff) | |
download | gitlab-ce-9803579e2599cb1e560b5f5a654baab8d485bf11.tar.gz |
Prevent default click since we change the url manually
Adds tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/vue_shared/components/table_pagination_spec.js | 39 |
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(); }); }); |