import std/html.{Attribute, Fragment, Node, Text} import std/option import std/string import std/test.{assert, assert_equal} import swap @test fn a_placeholder_is_its_skeleton_marked_as_loading :: { let skeleton = Node("nav", [Attribute("class", "labels")], [Text("…")]) assert_equal (html.render (swap.placeholder "swap-1" skeleton)) "" } @test fn a_skeleton_of_several_elements_is_wrapped :: { let skeleton = Fragment([Node("p", [], []), Node("p", [], [])]) assert_equal (html.render (swap.placeholder "swap-2" skeleton)) "
x
" match swap.opened page "n1" { Some((first, last)) -> { assert_equal first "x
" assert_equal last "" } , None -> assert False "the page should open" } } @test fn a_head_that_holds_the_script_keeps_it_once :: { let script = swap.script "n1" let page = "{script}x
" match swap.opened page "n1" { Some((first, last)) -> { assert_equal first "{script}x
" assert_equal last "" } , None -> assert False "the page should open" } } @test fn a_head_with_another_nonce_s_script_gets_this_one :: { let page = "{swap.script "old"}" let first = swap.opened page "n1" |> option.map fn split { split.0 } assert_equal first Some("{swap.script "old"}{swap.script "n1"}") } @test fn a_page_splits_at_its_last_body_end :: { let page = ""
let last = swap.opened page "n" |> option.map fn split { split.1 }
assert_equal last Some("