@@ -600,6 +600,7 @@ fn can_build_site_with_pagination_for_index() {
600
600
601
601
#[ test]
602
602
fn can_build_site_with_pagination_for_taxonomy ( ) {
603
+ let mut nb_a_pages = 0 ;
603
604
let ( _, _tmp_dir, public) = build_site_with_setup ( "test_site" , |mut site| {
604
605
site. config . languages . get_mut ( "en" ) . unwrap ( ) . taxonomies . push ( TaxonomyConfig {
605
606
name : "tags" . to_string ( ) ,
@@ -616,6 +617,10 @@ fn can_build_site_with_pagination_for_taxonomy() {
616
617
617
618
let pages_data = std:: mem:: replace ( & mut library. pages , AHashMap :: new ( ) ) ;
618
619
for ( i, ( _, mut page) ) in pages_data. into_iter ( ) . enumerate ( ) {
620
+ // Discard not rendered pages
621
+ if i % 2 == 0 && page. meta . render {
622
+ nb_a_pages += 1 ;
623
+ }
619
624
page. meta . taxonomies = {
620
625
let mut taxonomies = HashMap :: new ( ) ;
621
626
taxonomies. insert (
@@ -633,7 +638,8 @@ fn can_build_site_with_pagination_for_taxonomy() {
633
638
site. populate_taxonomies ( ) . unwrap ( ) ;
634
639
( site, false )
635
640
} ) ;
636
-
641
+ let nb_a_pagers: usize =
642
+ if nb_a_pages % 2 == 0 { nb_a_pages / 2 } else { ( nb_a_pages / 2 ) + 1 } ;
637
643
assert ! ( & public. exists( ) ) ;
638
644
639
645
assert ! ( file_exists!( public, "index.html" ) ) ;
@@ -661,7 +667,7 @@ fn can_build_site_with_pagination_for_taxonomy() {
661
667
"tags/a/page/1/index.html" ,
662
668
"http-equiv=\" refresh\" content=\" 0; url=https://replace-this-with-your-url.com/tags/a/\" "
663
669
) ) ;
664
- assert ! ( file_contains!( public, "tags/a/index.html" , "Num pagers: 9" ) ) ;
670
+ assert ! ( file_contains!( public, "tags/a/index.html" , & format! ( "Num pagers: {nb_a_pagers}" ) ) ) ;
665
671
assert ! ( file_contains!( public, "tags/a/index.html" , "Page size: 2" ) ) ;
666
672
assert ! ( file_contains!( public, "tags/a/index.html" , "Current index: 1" ) ) ;
667
673
assert ! ( !file_contains!( public, "tags/a/index.html" , "has_prev" ) ) ;
@@ -671,11 +677,13 @@ fn can_build_site_with_pagination_for_taxonomy() {
671
677
"tags/a/index.html" ,
672
678
"First: https://replace-this-with-your-url.com/tags/a/"
673
679
) ) ;
680
+
674
681
assert ! ( file_contains!(
675
682
public,
676
683
"tags/a/index.html" ,
677
- "Last: https://replace-this-with-your-url.com/tags/a/page/9/"
684
+ & format! ( "Last: https://replace-this-with-your-url.com/tags/a/page/{nb_a_pagers}/" )
678
685
) ) ;
686
+
679
687
assert ! ( !file_contains!( public, "tags/a/index.html" , "has_prev" ) ) ;
680
688
681
689
// sitemap contains the pager pages
0 commit comments