summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_pagination/pagination_spec.js.es6
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/vue_pagination/pagination_spec.js.es6')
-rw-r--r--spec/javascripts/vue_pagination/pagination_spec.js.es630
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');
+ });
});