use islands_core::{page_shell, page_shell_static, Manifest};
#[test]
fn static_shell_loads_core_but_no_page_module() {
let manifest = Manifest::default();
let html = page_shell_static("Dashboard", "<main>hi</main>", &manifest, "", false);
assert!(
html.contains("import core_init from \"/static/islands-core/islands_core.js\""),
"core module must load:\n{html}"
);
assert!(
!html.contains("page_init"),
"static shell must not import a page module:\n{html}"
);
assert!(html.contains("/static/css/base.css"), "base css linked:\n{html}");
assert!(
!html.contains("<link rel=\"stylesheet\" href=\"/static/counter"),
"static shell links no per-page css:\n{html}"
);
assert!(html.contains("<main>hi</main>"), "body is spliced in:\n{html}");
}
#[test]
fn interactive_shell_loads_both_core_and_page() {
let manifest = Manifest::default();
let html = page_shell(
"Home",
"<main>hi</main>",
"counter/page-home",
&manifest,
"",
false,
);
assert!(html.contains("import core_init from"), "core loads:\n{html}");
assert!(html.contains("import page_init from"), "page loads:\n{html}");
}
#[test]
fn asset_prefix_is_applied_to_static_shell() {
let manifest = Manifest::default();
let html = page_shell_static("Dashboard", "", &manifest, "https://cdn.example", false);
assert!(
html.contains("https://cdn.example/static/islands-core/islands_core.js"),
"asset prefix prepended to core URL:\n{html}"
);
}