[bugfix] SwipeCell: should ensure ref exist before get width

This commit is contained in:
陈嘉涵
2019-06-05 10:03:47 +08:00
parent 5dee1eb22f
commit 351e642e6d
4 changed files with 41 additions and 12 deletions
@@ -53,3 +53,11 @@ exports[`drag and show right part 1`] = `
</div>
</div>
`;
exports[`render one side 1`] = `
<div class="van-swipe-cell">
<div class="van-swipe-cell__wrapper" style="transform: translate3d(50px, 0, 0); transition: .6s cubic-bezier(0.18, 0.89, 0.32, 1);">
<div class="van-swipe-cell__left">Left</div>
</div>
</div>
`;
+18
View File
@@ -106,3 +106,21 @@ it('auto calc width', async () => {
restoreMock();
});
it('render one side', async () => {
const restoreMock = mockGetBoundingClientRect({
width: 50
});
const wrapper = mount(SwipeCell, {
scopedSlots: {
left: defaultProps.scopedSlots.left
}
});
await later();
triggerDrag(wrapper, 100, 0);
expect(wrapper).toMatchSnapshot();
restoreMock();
});