feat(Sticky): add change event (#8374)

This commit is contained in:
neverland
2021-03-18 09:35:31 +08:00
committed by GitHub
parent 062f5c54b4
commit 61b8cf2dec
4 changed files with 34 additions and 7 deletions
+19
View File
@@ -330,3 +330,22 @@ test('should emit scroll event when visibility changed', async () => {
window.IntersectionObserver = originIntersectionObserver;
});
test('should emit change event when sticky status changed', async () => {
const wrapper = mount(Sticky, {
attrs: {
style: 'height: 10px',
},
});
const mockStickyRect = jest
.spyOn(wrapper.element, 'getBoundingClientRect')
.mockReturnValue({
top: -100,
bottom: -90,
});
await mockScrollTop(100);
expect(wrapper.emitted('change')[0]).toEqual([true]);
mockStickyRect.mockRestore();
});