[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

View File

@@ -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();
}
});
}

View File

@@ -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;
};
}