Skip to content

Commit b5a5dcf

Browse files
committed
Improve unit tests for passive event support logic
1 parent e1205d5 commit b5a5dcf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/unit/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// mock passive event listener support and upsupport
2+
(() => {
3+
const originAddListener = window.addEventListener;
4+
let flag;
5+
6+
window.addEventListener = (...args) => {
7+
// try to read passive property and only read once time if it is accessible
8+
if (!flag && args[2] && args[2].passive) {
9+
flag = false;
10+
}
11+
originAddListener.apply(window, args);
12+
};
13+
})();
14+
115
const testsContext = require.context('./specs', true, /\.spec$/);
216
testsContext.keys().forEach(testsContext);
317

0 commit comments

Comments
 (0)