From f9db61fa7c596816367345de948fc6c92a1eabbe Mon Sep 17 00:00:00 2001 From: Regis Date: Tue, 13 Dec 2016 10:38:51 -0700 Subject: add more tests for pagination --- .../vue_pagination/pagination_spec.js.es6 | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/javascripts/vue_pagination/pagination_spec.js.es6 b/spec/javascripts/vue_pagination/pagination_spec.js.es6 index 201295ec97e..4a0b60b2e75 100644 --- a/spec/javascripts/vue_pagination/pagination_spec.js.es6 +++ b/spec/javascripts/vue_pagination/pagination_spec.js.es6 @@ -14,7 +14,7 @@ describe('Pagination component', () => { changeChanges.two = two; }; - it('should render', () => { + it('should render and start at page 1', () => { fixture.set('
'); component = new window.gl.VueGlPagination({ @@ -36,4 +36,32 @@ describe('Pagination component', () => { expect(changeChanges.one).toEqual(1); expect(changeChanges.two).toEqual('all'); }); + + it('should change page to 2 and previous should go cak to 1', () => { + fixture.set('
'); + + component = new window.gl.VueGlPagination({ + el: document.querySelector('.test-pagination-container'), + propsData: { + pageInfo: { + totalPages: 10, + nextPage: 2, + previousPage: '', + }, + change, + }, + }); + + expect(component.$el.classList).toContain('gl-pagination'); + + component.changepage({ target: { innerText: '2' } }); + + expect(changeChanges.one).toEqual(2); + expect(changeChanges.two).toEqual('all'); + + component.changepage({ target: { innerText: 'Prev' } }); + + expect(changeChanges.one).toEqual(1); + expect(changeChanges.two).toEqual('all'); + }); }); -- cgit v1.2.1