Skip to content

Commit

Permalink
Merge dc26fe4 into c51bb53
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng committed Aug 3, 2019
2 parents c51bb53 + dc26fe4 commit 431f07f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
6 changes: 5 additions & 1 deletion lib/autoscrollto.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

;(function(root, factory) {
if (typeof exports !== 'undefined') {
/* istanbul ignore next */
return factory(exports);
} else {
/* istanbul ignore next */
factory(root['AutoScrollTo'] || (root['AutoScrollTo'] = {}));
}
})(this, function(exports) {
Expand Down Expand Up @@ -73,9 +73,11 @@
try {
list = JSON.parse(list);
} catch (e) {
/* istanbul ignore next */
list = [];
}
if (!Array.isArray(list)) {
/* istanbul ignore next */
list = [];
}
for (var i = 0; i < list.length; i++) {
Expand Down Expand Up @@ -103,9 +105,11 @@
try {
list = JSON.parse(list);
} catch (e) {
/* istanbul ignore next */
list = [];
}
if (!Array.isArray(list)) {
/* istanbul ignore next */
list = [];
}
var value = 0;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lib/*.js"
],
"devDependencies": {
"dom-event-simulate": "^1.1.1",
"eslint": "*",
"eslint-plugin-mocha": "^4.11.0",
"git-contributor": "*",
Expand Down
18 changes: 15 additions & 3 deletions test/autoscrollto.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('./test/autoscrollto.test.js', () => {
.initWindow({
width: 375,
height: 600,
deviceScaleFactor: 2
deviceScaleFactor: 2,
});
});

Expand All @@ -38,7 +38,19 @@ describe('./test/autoscrollto.test.js', () => {
it('render should be ok', () => {
return driver
.getUrl(`${BASE_URL}`)
.sleep(5000);
.sleep(1000)
.execute('window.scrollTo(0, 600)')
.sleep(1000)
.getUrl(`${BASE_URL}`)
.sleep(1000)
.execute('window.scrollTo(0, 600)')
.sleep(1000);
});

it('render should be ok', () => {
return driver
.getUrl(`${BASE_URL}`)
.sleep(3000);
});
});
});
});
12 changes: 7 additions & 5 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
section-12
</div>
</div>
<script src="../node_modules/dom-event-simulate/lib/dom-event-simulate.js"></script>
<script>
const isOnline = !!~location.host.indexOf('github');
const script = document.createElement('script');
Expand All @@ -73,13 +74,14 @@
head.appendChild(script);
</script>
<script>
const { AutoScrollTo: Auto } = window.AutoScrollTo;
const autoScroll = new Auto({
pageNumber: 5,
});
setTimeout(() => {
const { AutoScrollTo: Auto } = window.AutoScrollTo;
const autoScroll = new Auto({
pageNumber: 5,
});

autoScroll.scrollTo();
}, 1000);
}, 100);
</script>
</body>
</html>

0 comments on commit 431f07f

Please sign in to comment.