mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 08:00:34 +00:00
[new feature] Pagination code review (#328)
* fix: Tabbar icon line-height * [new feature] progress add showPivot prop * [new feature] TabItem support vue-router * [new feature] update document header style * [Doc] add toast english ducoment * [bugfix] Search box-sizing wrong * [Doc] update vant-demo respo * [Doc] translate theme & demo pages * [Doc] add Internationalization document * [bugfix] remove unnecessary props * [fix] optimize clickoutside * [new feature] optimize find-parent * [new feature]: change document title accordinng to language * [new feature] Pagination code review
This commit is contained in:
@@ -15,9 +15,7 @@ describe('Pagination', () => {
|
||||
totalItems: 120,
|
||||
itemsPerPage: 10,
|
||||
showPageSize: 5,
|
||||
value: {
|
||||
currentPage: 2
|
||||
}
|
||||
value: 2
|
||||
}
|
||||
});
|
||||
expect(wrapper.hasClass('van-pagination')).to.be.true;
|
||||
@@ -25,26 +23,25 @@ describe('Pagination', () => {
|
||||
expect(
|
||||
wrapper.find('.van-pagination__item')[0].hasClass('van-pagination__prev')
|
||||
).to.be.true;
|
||||
expect(wrapper.vm.value.currentPage).to.equal(2);
|
||||
expect(wrapper.vm.value).to.equal(2);
|
||||
|
||||
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||
wrapper.find('.van-pagination__next')[0].trigger('click');
|
||||
Vue.nextTick(() => {
|
||||
expect(eventStub.calledWith('input'));
|
||||
expect(eventStub.calledWith('change'));
|
||||
// expect(wrapper.data().currentPage).to.equal(5);
|
||||
done();
|
||||
});
|
||||
expect(wrapper.vm.value).to.equal(2);
|
||||
|
||||
wrapper.vm.value = { currentPage: 12 };
|
||||
wrapper.update();
|
||||
Vue.nextTick(() => {
|
||||
expect(
|
||||
wrapper
|
||||
.find('.van-pagination__next')[0]
|
||||
.hasClass('van-pagination--disabled')
|
||||
).to.be.true;
|
||||
done();
|
||||
wrapper.vm.value = 12;
|
||||
wrapper.update();
|
||||
Vue.nextTick(() => {
|
||||
expect(
|
||||
wrapper
|
||||
.find('.van-pagination__next')[0]
|
||||
.hasClass('van-pagination--disabled')
|
||||
).to.be.true;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,23 +53,26 @@ describe('Pagination', () => {
|
||||
itemsPerPage: 10,
|
||||
showPageSize: 5,
|
||||
forceEllipses: true,
|
||||
value: {
|
||||
currentPage: 1
|
||||
}
|
||||
value: 1
|
||||
}
|
||||
});
|
||||
|
||||
const ellipsesLink = wrapper.find('.van-pagination__page')[5];
|
||||
expect(ellipsesLink.element.textContent.trim()).to.equal('...');
|
||||
expect(ellipsesLink.text().trim()).to.equal('...');
|
||||
|
||||
wrapper.vm.value = { currentPage: 7 };
|
||||
wrapper.vm.value = 7;
|
||||
wrapper.update();
|
||||
Vue.nextTick(() => {
|
||||
// expect(wrapper.find('.van-pagination__item').length).to.equal(2);
|
||||
// expect(wrapper.data().pages.length).to.equal(2);
|
||||
const ellipsesLink = wrapper.find('.van-pagination__page')[0];
|
||||
expect(ellipsesLink.element.textContent.trim()).to.equal('...');
|
||||
done();
|
||||
expect(ellipsesLink.text().trim()).to.equal('...');
|
||||
|
||||
wrapper.vm.value = 12;
|
||||
Vue.nextTick(() => {
|
||||
const pages = wrapper.find('.van-pagination__page');
|
||||
const ellipsesLink = pages[pages.length - 1];
|
||||
expect(ellipsesLink.text().trim()).to.equal('12');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -82,9 +82,7 @@ describe('Pagination', () => {
|
||||
mode: 'simple',
|
||||
totalItems: 120,
|
||||
itemsPerPage: 10,
|
||||
value: {
|
||||
currentPage: 1
|
||||
}
|
||||
value: 1
|
||||
}
|
||||
});
|
||||
expect(wrapper.hasClass('van-pagination')).to.be.true;
|
||||
@@ -103,14 +101,12 @@ describe('Pagination', () => {
|
||||
showPageSize: 5,
|
||||
nextText: '下一页',
|
||||
previousText: '上一页',
|
||||
value: {
|
||||
currentPage: 2
|
||||
}
|
||||
value: 2
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.find('.van-pagination__prev')[0].element.textContent.trim()).to.equal('上一页');
|
||||
expect(wrapper.find('.van-pagination__next')[0].element.textContent.trim()).to.equal('下一页');
|
||||
expect(wrapper.find('.van-pagination__prev')[0].text().trim()).to.equal('上一页');
|
||||
expect(wrapper.find('.van-pagination__next')[0].text().trim()).to.equal('下一页');
|
||||
|
||||
wrapper.vm.value = { currentPage: 18 };
|
||||
wrapper.update();
|
||||
@@ -119,4 +115,20 @@ describe('Pagination', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('create a multi forceEllipses Pagination && max show page size', () => {
|
||||
wrapper = mount(Pagination, {
|
||||
propsData: {
|
||||
mode: 'multi',
|
||||
totalItems: 120,
|
||||
itemsPerPage: 10,
|
||||
showPageSize: 12,
|
||||
forceEllipses: true,
|
||||
value: 1
|
||||
}
|
||||
});
|
||||
|
||||
const ellipsesLink = wrapper.find('.van-pagination__page')[11];
|
||||
expect(ellipsesLink.text().trim()).to.equal('12');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user