⚡️ Declara un favicon vacío si la página no tiene
Evita que el navegador pida `/favicon.ico` en cada página, una ruta inexistente que acababa en una página 404 completa.
This commit is contained in:
parent
779e98eeb0
commit
8377ddb4c6
9 changed files with 40 additions and 9 deletions
|
|
@ -169,7 +169,7 @@ async fn flex_without_display_adds_no_class_of_its_own() {
|
|||
let html = container.render(&mut cx).await.into_string();
|
||||
|
||||
assert!(html.contains(r#"class="own""#));
|
||||
assert!(cx.render_assets().into_string().is_empty());
|
||||
assert!(cx.responsive_styles().is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ async fn grid_without_display_adds_no_class_of_its_own() {
|
|||
let html = container.render(&mut cx).await.into_string();
|
||||
|
||||
assert!(html.contains(r#"class="own""#));
|
||||
assert!(cx.render_assets().into_string().is_empty());
|
||||
assert!(cx.responsive_styles().is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
|
|||
19
tests/html_assets_favicon.rs
Normal file
19
tests/html_assets_favicon.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
// Empty icon declared when the page has none.
|
||||
const DEFAULT_ICON: &str = r#"<link rel="icon" href="data:,">"#;
|
||||
|
||||
#[pagetop::test]
|
||||
async fn pages_without_favicon_declare_an_empty_icon() {
|
||||
// Without any declared icon, browsers would request `/favicon.ico` on every page.
|
||||
let assets = Context::default().render_assets().into_string();
|
||||
assert!(assets.contains(DEFAULT_ICON));
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn a_declared_favicon_replaces_the_default_icon() {
|
||||
let mut cx = Context::default().with_assets(Favicon::new().with_icon("/app/icon.png"));
|
||||
let assets = cx.render_assets().into_string();
|
||||
assert!(assets.contains("/app/icon.png"));
|
||||
assert!(!assets.contains(DEFAULT_ICON));
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ async fn default_flex_item_adds_nothing() {
|
|||
let html = html! { span (props.unpack(&mut cx)) {} }.into_string();
|
||||
|
||||
assert_eq!(html, "<span></span>");
|
||||
assert!(cx.render_assets().into_string().is_empty());
|
||||
assert!(cx.responsive_styles().is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ async fn default_grid_item_adds_nothing() {
|
|||
let html = html! { span (props.unpack(&mut cx)) {} }.into_string();
|
||||
|
||||
assert_eq!(html, "<span></span>");
|
||||
assert!(cx.render_assets().into_string().is_empty());
|
||||
assert!(cx.responsive_styles().is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ async fn default_margin_adds_nothing() {
|
|||
let html = html! { span (props.unpack(&mut cx)) {} }.into_string();
|
||||
|
||||
assert_eq!(html, "<span></span>");
|
||||
assert!(cx.render_assets().into_string().is_empty());
|
||||
assert!(cx.responsive_styles().is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -17,7 +17,7 @@ async fn default_padding_adds_nothing() {
|
|||
let html = html! { span (props.unpack(&mut cx)) {} }.into_string();
|
||||
|
||||
assert_eq!(html, "<span></span>");
|
||||
assert!(cx.render_assets().into_string().is_empty());
|
||||
assert!(cx.responsive_styles().is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
@ -147,7 +147,7 @@ async fn padding_auto_is_ignored() {
|
|||
let html = html! { span (props.unpack(&mut cx)) {} }.into_string();
|
||||
|
||||
assert_eq!(html, "<span></span>");
|
||||
assert!(cx.render_assets().into_string().is_empty());
|
||||
assert!(cx.responsive_styles().is_empty());
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
|
|
|
|||
|
|
@ -485,14 +485,15 @@ async fn render_assets_includes_style_tag_with_responsive_styles() {
|
|||
"flex-basis",
|
||||
"100%",
|
||||
));
|
||||
let baseline = Context::default().render_assets().into_string();
|
||||
assert_eq!(
|
||||
cx.render_assets().into_string(),
|
||||
"<style>.col{flex-basis:100%}</style>"
|
||||
format!("{baseline}<style>.col{{flex-basis:100%}}</style>")
|
||||
);
|
||||
}
|
||||
|
||||
#[pagetop::test]
|
||||
async fn render_assets_omits_style_tag_when_no_responsive_styles() {
|
||||
let mut cx = Context::default();
|
||||
assert_eq!(cx.render_assets().into_string(), "");
|
||||
assert!(!cx.render_assets().into_string().contains("<style"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue