Skip to content

Commit ae780d1

Browse files
committed
test(infinite-scroll): fix infinite scroll top test
1 parent b7624eb commit ae780d1

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

  • core/src/components/infinite-scroll/test/top

core/src/components/infinite-scroll/test/top/index.html

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en" dir="ltr">
33
<head>
44
<meta charset="UTF-8" />
5-
<title>Infinite Scroll - Basic</title>
5+
<title>Infinite Scroll - Top</title>
66
<meta
77
name="viewport"
88
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
@@ -18,7 +18,7 @@
1818
<ion-app>
1919
<ion-header>
2020
<ion-toolbar>
21-
<ion-title>Infinite Scroll - Basic</ion-title>
21+
<ion-title>Infinite Scroll - Top</ion-title>
2222
</ion-toolbar>
2323
</ion-header>
2424

@@ -28,9 +28,9 @@
2828
</ion-infinite-scroll-content>
2929
</ion-infinite-scroll>
3030

31-
<button onclick="toggleInfiniteScroll()" class="expand">Toggle InfiniteScroll</button>
31+
<div id="list"></div>
3232

33-
<ion-list id="list"></ion-list>
33+
<button onclick="toggleInfiniteScroll()" class="expand">Toggle InfiniteScroll</button>
3434
</ion-content>
3535
</ion-app>
3636

@@ -46,17 +46,32 @@
4646
console.log('Loading data...');
4747
await wait(500);
4848
infiniteScroll.complete();
49-
appendItems();
49+
appendNewItems();
5050
// Custom event consumed in the e2e tests
5151
window.dispatchEvent(new CustomEvent('ionInfiniteComplete'));
5252

5353
console.log('Done');
5454
});
5555

56-
function appendItems() {
56+
// Add initial items
57+
function appendInitialItems() {
5758
for (var i = 0; i < 30; i++) {
5859
const el = document.createElement('ion-item');
59-
el.textContent = `${1 + i}`;
60+
el.textContent = `Item ${1 + i}`;
61+
list.appendChild(el);
62+
}
63+
}
64+
65+
// Add newly loaded items with special styling
66+
function appendNewItems() {
67+
const randomColor = '#' + Math.floor(Math.random()*16777215).toString(16).padStart(6, '0');
68+
69+
// Reverse the order of the items to match
70+
// the order of the initial items
71+
for (var i = 29; i >= 0; i--) {
72+
const el = document.createElement('ion-item');
73+
el.textContent = `Item ${i + 1}`;
74+
el.style.borderLeft = `4px solid ${randomColor}`;
6075
list.prepend(el);
6176
}
6277
}
@@ -69,7 +84,7 @@
6984
});
7085
}
7186

72-
appendItems();
87+
appendInitialItems();
7388
</script>
7489
</body>
7590
</html>

0 commit comments

Comments
 (0)