[new feature] IndexBar: add sticky prop (#3402)

This commit is contained in:
neverland
2019-05-30 11:50:09 +08:00
committed by GitHub
parent 74124246f6
commit 82134fe402
14 changed files with 263 additions and 60 deletions
+6 -8
View File
@@ -1,5 +1,5 @@
import SwipeCell from '..';
import { mount, triggerDrag, later } from '../../../test/utils';
import { mount, triggerDrag, later, mockGetBoundingClientRect } from '../../../test/utils';
const THRESHOLD = 0.15;
const defaultProps = {
@@ -13,12 +13,6 @@ const defaultProps = {
}
};
function mockGetBoundingClientRect(vertical) {
Element.prototype.getBoundingClientRect = jest.fn(() => ({
width: 50
}));
}
it('drag and show left part', () => {
const wrapper = mount(SwipeCell, defaultProps);
@@ -98,7 +92,9 @@ it('disabled prop', () => {
});
it('auto calc width', async () => {
mockGetBoundingClientRect();
const restoreMock = mockGetBoundingClientRect({
width: 50
});
const wrapper = mount(SwipeCell, {
scopedSlots: defaultProps.scopedSlots
@@ -107,4 +103,6 @@ it('auto calc width', async () => {
await later();
triggerDrag(wrapper, 100, 0);
expect(wrapper).toMatchSnapshot();
restoreMock();
});