From d4a2c9e6fbfae18b305fb8dee9face7de88c2e6d Mon Sep 17 00:00:00 2001 From: Regis Date: Tue, 13 Dec 2016 10:52:07 -0700 Subject: prev next tests for pagination --- .../vue_pagination/pagination_spec.js.es6 | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'spec') diff --git a/spec/javascripts/vue_pagination/pagination_spec.js.es6 b/spec/javascripts/vue_pagination/pagination_spec.js.es6 index 4a0b60b2e75..9c1fdd339c9 100644 --- a/spec/javascripts/vue_pagination/pagination_spec.js.es6 +++ b/spec/javascripts/vue_pagination/pagination_spec.js.es6 @@ -37,7 +37,7 @@ describe('Pagination component', () => { expect(changeChanges.two).toEqual('all'); }); - it('should change page to 2 and previous should go cak to 1', () => { + it('should go to the previous page', () => { fixture.set('
'); component = new window.gl.VueGlPagination({ @@ -45,23 +45,37 @@ describe('Pagination component', () => { propsData: { pageInfo: { totalPages: 10, - nextPage: 2, - previousPage: '', + nextPage: 3, + previousPage: 1, }, change, }, }); - expect(component.$el.classList).toContain('gl-pagination'); - - component.changepage({ target: { innerText: '2' } }); + component.changepage({ target: { innerText: 'Prev' } }); - expect(changeChanges.one).toEqual(2); + expect(changeChanges.one).toEqual(1); expect(changeChanges.two).toEqual('all'); + }); - component.changepage({ target: { innerText: 'Prev' } }); + it('should go to the next page', () => { + fixture.set('
'); - expect(changeChanges.one).toEqual(1); + component = new window.gl.VueGlPagination({ + el: document.querySelector('.test-pagination-container'), + propsData: { + pageInfo: { + totalPages: 10, + nextPage: 5, + previousPage: 3, + }, + change, + }, + }); + + component.changepage({ target: { innerText: 'Next' } }); + + expect(changeChanges.one).toEqual(5); expect(changeChanges.two).toEqual('all'); }); }); -- cgit v1.2.1