mirror of
https://github.com/youzan/vant.git
synced 2026-01-31 01:01:30 +08:00
[new feature] IndexBar: add sticky prop (#3402)
This commit is contained in:
@@ -13,8 +13,12 @@ const empty = {
|
||||
Vue.component('demo-block', empty);
|
||||
Vue.component('demo-section', empty);
|
||||
|
||||
export default function (Demo: any) {
|
||||
export default function (Demo: any, option: any = {}) {
|
||||
test('renders demo correctly', async () => {
|
||||
if (option.hookBeforeTest) {
|
||||
option.hookBeforeTest();
|
||||
}
|
||||
|
||||
if (Demo.i18n) {
|
||||
Locale.add(Demo.i18n);
|
||||
}
|
||||
@@ -24,5 +28,9 @@ export default function (Demo: any) {
|
||||
await later();
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
||||
if (option.hookAfterTest) {
|
||||
option.hookAfterTest();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,3 +70,13 @@ export function later(delay: number = 0): Promise<void> {
|
||||
export function transitionStub(): void {
|
||||
Vue.component('transition', TransitionStub as any);
|
||||
}
|
||||
|
||||
export function mockGetBoundingClientRect(rect: ClientRect | DOMRect): Function {
|
||||
const originMethod = Element.prototype.getBoundingClientRect;
|
||||
|
||||
Element.prototype.getBoundingClientRect = <any> jest.fn(() => rect);
|
||||
|
||||
return function () {
|
||||
Element.prototype.getBoundingClientRect = originMethod;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user