;; 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: call (6 tests — 6 runnable)"
    (p :style "color:#57534e;margin-bottom:1rem" "Live cards for the upstream call tests. 6 of 6 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-control))"
        :style "color:#7c3aed" "control"))
    (div :style "display:flex;flex-direction:column"
      (~hyperscript/hs-test-card
  :name "can call javascript instance functions"
  :html "<div id='d1' _='on click call document.getElementById(\"d1\") then                                          put it into window.results'></div>"
  :action "d1.click()"
  :check "value.should.equal(d1)"
  :run-src "(fn (sandbox)
  (let ((_el-d1 (dom-create-element \"div\")))
    (dom-set-attr _el-d1 \"id\" \"d1\")
    (dom-set-attr _el-d1 \"_\" \"on click call document.getElementById(\\\"d1\\\") then put it into window.results\")
    (dom-append sandbox _el-d1)
    (hs-activate! _el-d1)
    (dom-dispatch _el-d1 \"click\" nil)
    ;; SKIP check: skip value.should.equal(d1)
  ))")
(~hyperscript/hs-test-card
  :name "can call global javascript functions"
  :html "<div _='on click call globalFunction(\"foo\")'></div>"
  :action "div.click()"
  :check "\"foo\".should.equal(calledWith)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click call globalFunction(\\\"foo\\\")\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip \"foo\".should.equal(calledWith)
  ))")
(~hyperscript/hs-test-card
  :name "can call no argument functions"
  :html "<div _='on click call globalFunction()'></div>"
  :action "div.click()"
  :check "called.should.equal(true)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click call globalFunction()\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip called.should.equal(true)
  ))")
(~hyperscript/hs-test-card
  :name "can call functions w/ underscores"
  :html "<div _='on click call global_function()'></div>"
  :action "div.click()"
  :check "called.should.equal(true)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click call global_function()\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip called.should.equal(true)
  ))")
(~hyperscript/hs-test-card
  :name "can call functions w/ dollar signs"
  :html "<div _='on click call $()'></div>"
  :action "div.click()"
  :check "called.should.equal(true)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click call $()\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip called.should.equal(true)
  ))")
(~hyperscript/hs-test-card
  :name "call functions that return promises are waited on"
  :html "<div _='on click call promiseAnInt() then put it into my.innerHTML'></div>"
  :action "div.click()"
  :check "div.innerText.should.equal(\"\") && div.innerText.should.equal(\"42\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click call promiseAnInt() then put it into my.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    ;; SKIP check: skip div.innerText.should.equal(\"\")
    ;; SKIP check: skip div.innerText.should.equal(\"42\")
  ))"))))
