diff options
author | Regis <boudinot.regis@yahoo.com> | 2016-12-13 10:38:51 -0700 |
---|---|---|
committer | Regis <boudinot.regis@yahoo.com> | 2016-12-13 10:38:51 -0700 |
commit | f9db61fa7c596816367345de948fc6c92a1eabbe (patch) | |
tree | c3ad2c723b045e506be852e07368b39c0bb14120 /spec | |
parent | 7d2ca647df50f66eba40654b0d52fd8a9aa0d30d (diff) | |
download | gitlab-ce-f9db61fa7c596816367345de948fc6c92a1eabbe.tar.gz |
add more tests for pagination
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/vue_pagination/pagination_spec.js.es6 | 30 |
1 files changed, 29 insertions, 1 deletions
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('<div class="test-pagination-container"></div>'); 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('<div class="test-pagination-container"></div>'); + + 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'); + }); }); |