;; AUTO-GENERATED from spec/tests/hyperscript-upstream-tests.json
;; DO NOT EDIT — regenerate with:
;;   python3 tests/playwright/generate-sx-tests.py --emit-pages

(defcomp ()
  (~docs/page :title "Hyperscript: init (3 tests — 1 runnable)"
    (p :style "color:#57534e;margin-bottom:1rem" "Live cards for the upstream init tests. 1 of 3 are reproducible in-browser; the remainder show their source for reference.")
    (p :style "color:#78716c;font-size:0.875rem;margin-bottom:1rem"
      "Theme: " (a :href "/sx/(applications.(hyperscript.gallery-events))"
        :style "color:#7c3aed" "events"))
    (div :style "display:flex;flex-direction:column"
      (~hyperscript/hs-test-card
  :name "can define an init block inline"
  :html "<div _='init                  set my.foo to 42                end               on click put my.foo into my.innerHTML'></div>"
  :action "div.click()"
  :check "div.innerHTML.should.equal(\"42\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"init then set my.foo to 42 end on click put my.foo into my.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"42\")
  ))")
(~hyperscript/hs-test-card
  :name "can define an init block in a script"
  :html "<script type='text/hyperscript'>  init    set window.foo to 42  end</script>"
  :action "(see body)"
  :check "window.foo.should.equal(42)"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))")
(~hyperscript/hs-test-card
  :name "can initialize immediately"
  :html "<script type='text/hyperscript'>init set window.foo to 10                                init immediately set window.bar to window.foo </script>"
  :action "(see body)"
  :check "window.foo.should.equal(10)"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))"))))
