diff --git a/t/08-local-footer.test b/t/08-local-footer.test new file mode 100644 index 0000000..56f1d02 --- /dev/null +++ b/t/08-local-footer.test @@ -0,0 +1,17 @@ +#! /bin/bash +cat <<--- +This test checks that a local footer can be included with +"fancyindex_header ... local" +-- +use pup + +cat > "${TESTDIR}/footer" <yes +EOF + +nginx_start 'fancyindex_footer "/footer" local;' + +T=$(fetch / | pup -p body 'div#customfooter' text{}) +[[ $T == yes ]] || fail 'Custom header missing' + +nginx_is_running || fail 'Nginx died' diff --git a/t/09-local-header.test b/t/09-local-header.test new file mode 100644 index 0000000..ac1358b --- /dev/null +++ b/t/09-local-header.test @@ -0,0 +1,17 @@ +#! /bin/bash +cat <<--- +This test checks that a local header can be included with +"fancyindex_header ... local" +-- +use pup + +cat > "${TESTDIR}/header" <yes +EOF + +nginx_start 'fancyindex_header "/header" local;' + +T=$(fetch / | pup -p body 'div#customheader' text{}) +[[ $T == yes ]] || fail 'Custom header missing' + +nginx_is_running || fail 'Nginx died' diff --git a/t/10-local-headerfooter.test b/t/10-local-headerfooter.test new file mode 100644 index 0000000..0750d1b --- /dev/null +++ b/t/10-local-headerfooter.test @@ -0,0 +1,26 @@ +#! /bin/bash +cat <<--- +This test checks that both a local header and footer can be included with +"fancyindex_{header,footer} ... local" +-- +use pup + +cat > "${TESTDIR}/header" <yes +EOF +cat > "${TESTDIR}/footer" <yes +EOF + +nginx_start 'fancyindex_header "/header" local; + fancyindex_footer "/footer" local;' + +P=$(fetch /) + +H=$(pup -p body 'div#customheader' text{} <<< "$P") +[[ $H == yes ]] || fail 'Custom header missing' + +F=$(pup -p body 'div#customfooter' text{} <<< "$P") +[[ $F == yes ]] || fail 'Custom footer missing' + +nginx_is_running || fail 'Nginx died' diff --git a/t/11-local-footer-nested.test b/t/11-local-footer-nested.test new file mode 100644 index 0000000..b259290 --- /dev/null +++ b/t/11-local-footer-nested.test @@ -0,0 +1,31 @@ +#! /bin/bash +cat <<--- +This test checks that local footers are correctly included in presence of +directives in nested locations: + + fancyindex_footer local; + location /sub { + fancyindex_footer local; + } + +-- +use pup + +echo '
yes
' > "${TESTDIR}/top-footer" +echo '
yes
' > "${TESTDIR}/sub-footer" + +nginx_start 'fancyindex_footer "/top-footer" local; + location /child-directory { + fancyindex_footer "/sub-footer" local; + }' + +T=$(fetch /) +echo "$T" > "$TESTDIR/top.html" +[[ $(pup -p body 'div#topfooter' text{} <<< "$T") = yes ]] || fail 'Custom header missing at /' +[[ -z $(pup -p body 'div#subfooter' text{} <<< "$T") ]] || fail 'Wrong header at /' + +T=$(fetch /child-directory/) +[[ $(pup -p body 'div#subfooter' text{} <<< "$T") = yes ]] || fail 'Custom header missing at /sub/' +[[ -z $(pup -p body 'div#topfooter' text{} <<< "$T") ]] || fail 'Wrong header at /sub/' + +nginx_is_running || fail 'Nginx died'