@@ -76,6 +76,8 @@ public async Task ListView_Ok()
7676 [ Fact ]
7777 public async Task Pageable_Ok ( )
7878 {
79+ var triggerByPage = false ;
80+ var pageIndex = 0 ;
7981 var items = Enumerable . Range ( 1 , 6 ) . Select ( i => new Product ( )
8082 {
8183 ImageUrl = $ "images/Pic{ i } .jpg",
@@ -84,26 +86,33 @@ public async Task Pageable_Ok()
8486 } ) ;
8587 var cut = Context . RenderComponent < ListView < Product > > ( pb =>
8688 {
87- pb . Add ( a => a . OnQueryAsync , Query ) ;
88- pb . Add ( a => a . Pageable , true ) ;
89+ pb . Add ( a => a . OnQueryAsync , option =>
90+ {
91+ pageIndex = option . PageIndex ;
92+ triggerByPage = option . IsTriggerByPagination ;
93+ return Task . FromResult ( new QueryData < Product > ( )
94+ {
95+ Items = items ,
96+ TotalCount = 6
97+ } ) ;
98+ } ) ;
99+ pb . Add ( a => a . IsPagination , true ) ;
89100 pb . Add ( a => a . PageItems , 2 ) ;
90101 } ) ;
102+ Assert . False ( triggerByPage ) ;
103+ Assert . Equal ( 1 , pageIndex ) ;
91104
92105 var pages = cut . FindAll ( ".page-link" ) ;
93106 Assert . Equal ( 5 , pages . Count ) ;
94107 await cut . InvokeAsync ( ( ) => pages [ 2 ] . Click ( ) ) ;
95-
96- Task < QueryData < Product > > Query ( QueryPageOptions option ) => Task . FromResult ( new QueryData < Product > ( )
97- {
98- Items = items ,
99- TotalCount = 6
100- } ) ;
108+ Assert . True ( triggerByPage ) ;
101109 }
102110
103111 [ Fact ]
104- public void QueryAsync_Ok ( )
112+ public async Task QueryAsync_Ok ( )
105113 {
106114 bool query = false ;
115+ bool page = false ;
107116 var items = Enumerable . Range ( 1 , 6 ) . Select ( i => new Product ( )
108117 {
109118 ImageUrl = $ "images/Pic{ i } .jpg",
@@ -114,6 +123,7 @@ public void QueryAsync_Ok()
114123 {
115124 pb . Add ( a => a . OnQueryAsync , option =>
116125 {
126+ page = option . IsPage ;
117127 query = true ;
118128 var ret = new QueryData < Product > ( )
119129 {
@@ -122,11 +132,12 @@ public void QueryAsync_Ok()
122132 } ;
123133 return Task . FromResult ( ret ) ;
124134 } ) ;
125- pb . Add ( a => a . Pageable , true ) ;
135+ pb . Add ( a => a . IsPagination , true ) ;
126136 pb . Add ( a => a . PageItems , 2 ) ;
127137 } ) ;
128138 Assert . True ( query ) ;
129- cut . InvokeAsync ( ( ) => cut . Instance . QueryAsync ( ) ) ;
139+ Assert . True ( page ) ;
140+ await cut . InvokeAsync ( ( ) => cut . Instance . QueryAsync ( ) ) ;
130141 }
131142
132143 [ Fact ]
@@ -159,7 +170,7 @@ public void Collapsible_Ok()
159170 } ;
160171 return Task . FromResult ( ret ) ;
161172 } ) ;
162- pb . Add ( a => a . Pageable , true ) ;
173+ pb . Add ( a => a . IsPagination , true ) ;
163174 pb . Add ( a => a . PageItems , 2 ) ;
164175 pb . Add ( a => a . OnListViewItemClick , p =>
165176 {
@@ -209,7 +220,7 @@ public void IsAccordion_Ok()
209220 } ;
210221 return Task . FromResult ( ret ) ;
211222 } ) ;
212- pb . Add ( a => a . Pageable , true ) ;
223+ pb . Add ( a => a . IsPagination , true ) ;
213224 pb . Add ( a => a . PageItems , 2 ) ;
214225 } ) ;
215226 var collapse = cut . FindComponent < Collapse > ( ) ;
@@ -246,7 +257,7 @@ public void CollapsedGroupCallback_Ok()
246257 } ;
247258 return Task . FromResult ( ret ) ;
248259 } ) ;
249- pb . Add ( a => a . Pageable , true ) ;
260+ pb . Add ( a => a . IsPagination , true ) ;
250261 pb . Add ( a => a . PageItems , 2 ) ;
251262 } ) ;
252263 Assert . True ( callback ) ;
@@ -281,7 +292,7 @@ public void OnCollapseChanged_Ok()
281292 expect = item ;
282293 return Task . CompletedTask ;
283294 } ) ;
284- pb . Add ( a => a . Pageable , true ) ;
295+ pb . Add ( a => a . IsPagination , true ) ;
285296 pb . Add ( a => a . PageItems , 2 ) ;
286297 } ) ;
287298
0 commit comments