[new feature] List 考虑错误情况,增加 error-text 属性 #2567 (#2568)

This commit is contained in:
Rockergmail
2019-01-20 16:25:25 +08:00
committed by neverland
parent be03980fe5
commit c43edf987f
7 changed files with 120 additions and 20 deletions
@@ -3,7 +3,15 @@
exports[`renders demo correctly 1`] = `
<div>
<div>
<p class="page-desc">当即将滚动到元素底部时,会自动加载更多</p>
<div class="page-desc">
<p class="page-desc--text">当即将滚动到元素底部时,会自动加载更多</p>
<div class="page-desc--option van-checkbox">
<div class="van-checkbox__icon van-checkbox__icon--round"><i class="van-icon van-icon-success" style="color:undefined;font-size:undefined;">
<!----></i></div><span class="van-checkbox__label">
模拟加载失败
</span>
</div>
</div>
<div class="van-pull-refresh">
<div class="van-pull-refresh__track" style="transition:0ms;transform:translate3d(0,0px, 0);">
<div class="van-pull-refresh__head">
+29
View File
@@ -29,6 +29,35 @@ test('load event', async () => {
wrapper.destroy();
});
test('error loaded, click error-text and reload', async () => {
const wrapper = mount(List, {
propsData: {
errorText: 'Request failed. Click to reload...',
error: true
}
});
mockOffsetParent(wrapper.vm.$el);
await later();
expect(wrapper.emitted('load')).toBeFalsy();
expect(wrapper.emitted('input')).toBeFalsy();
// 模拟点击error-text的行为
wrapper.setProps({
error: false
});
wrapper.vm.$emit('input', true);
wrapper.vm.$emit('load');
expect(wrapper.vm.$props.error).toBeFalsy();
expect(wrapper.emitted('load')).toBeTruthy();
expect(wrapper.emitted('input')).toBeTruthy();
wrapper.destroy();
});
test('finished', async () => {
const wrapper = mount(List, {
propsData: {