[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
+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: {