add more tests for pagination

This commit is contained in:
Regis 2016-12-13 10:38:51 -07:00
parent 7d2ca647df
commit f9db61fa7c
2 changed files with 29 additions and 2 deletions

View file

@ -12,7 +12,6 @@
return `has-tooltip ci-status-icon-${this.stage.status.label}`;
},
svg() {
// debugger
return this.svgs[this.match(this.stage.status.icon)];
},
},

View file

@ -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');
});
});