Skip to content

Commit 0cc7e0a

Browse files
committed
add scrollTo mock function
1 parent 5322e0d commit 0cc7e0a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/unit/util.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from "vue";
22

33
export function later(delay = 0) {
4-
return new Promise(resolve => {
4+
return new Promise((resolve) => {
55
if (typeof delay === "number") {
66
setTimeout(() => {
77
resolve();
@@ -13,3 +13,13 @@ export function later(delay = 0) {
1313
}
1414
});
1515
}
16+
17+
/*
18+
* @mockScrollTo
19+
* @desc mock scrollTo function
20+
*/
21+
export function mockScrollTo() {
22+
const fn = jest.fn();
23+
Element.prototype.scrollTo = fn;
24+
return fn;
25+
}

0 commit comments

Comments
 (0)