@@ -279,4 +279,58 @@ describe("calcite-pagination", () => {
279
279
}
280
280
} ) ;
281
281
} ) ;
282
+
283
+ describe ( "navigation methods" , ( ) => {
284
+ let page : E2EPage ;
285
+ beforeEach ( async ( ) => {
286
+ page = await newE2EPage ( ) ;
287
+ await page . setContent (
288
+ `<calcite-pagination start-item="1" total-items="124" page-size="20"></calcite-pagination>` ,
289
+ ) ;
290
+ } ) ;
291
+
292
+ it ( "navigates to last page" , async ( ) => {
293
+ const element = await page . find ( "calcite-pagination" ) ;
294
+ await element . callMethod ( "goTo" , "end" ) ;
295
+ await page . waitForChanges ( ) ;
296
+ const item = await element . getProperty ( "startItem" ) ;
297
+ expect ( item ) . toEqual ( 121 ) ;
298
+ } ) ;
299
+
300
+ it ( "navigates to first page" , async ( ) => {
301
+ const element = await page . find ( "calcite-pagination" ) ;
302
+ await element . callMethod ( "goTo" , "end" ) ;
303
+ await page . waitForChanges ( ) ;
304
+ let item = await element . getProperty ( "startItem" ) ;
305
+ expect ( item ) . toEqual ( 121 ) ;
306
+ await element . callMethod ( "goTo" , "start" ) ;
307
+ await page . waitForChanges ( ) ;
308
+ item = await element . getProperty ( "startItem" ) ;
309
+ expect ( item ) . toEqual ( 1 ) ;
310
+ } ) ;
311
+
312
+ it ( "navigates middle page" , async ( ) => {
313
+ const element = await page . find ( "calcite-pagination" ) ;
314
+ await element . callMethod ( "goTo" , 3 ) ;
315
+ await page . waitForChanges ( ) ;
316
+ const item = await element . getProperty ( "startItem" ) ;
317
+ expect ( item ) . toEqual ( 41 ) ;
318
+ } ) ;
319
+
320
+ it ( "navigates beyond last page" , async ( ) => {
321
+ const element = await page . find ( "calcite-pagination" ) ;
322
+ await element . callMethod ( "goTo" , 20 ) ;
323
+ await page . waitForChanges ( ) ;
324
+ const item = await element . getProperty ( "startItem" ) ;
325
+ expect ( item ) . toEqual ( 121 ) ;
326
+ } ) ;
327
+
328
+ it ( "navigates before first page" , async ( ) => {
329
+ const element = await page . find ( "calcite-pagination" ) ;
330
+ await element . callMethod ( "goTo" , - 1 ) ;
331
+ await page . waitForChanges ( ) ;
332
+ const item = await element . getProperty ( "startItem" ) ;
333
+ expect ( item ) . toEqual ( 1 ) ;
334
+ } ) ;
335
+ } ) ;
282
336
} ) ;
0 commit comments