;; 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: remove (14 tests — 9 runnable)"
    (p :style "color:#57534e;margin-bottom:1rem" "Live cards for the upstream remove tests. 9 of 14 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-dom))"
        :style "color:#7c3aed" "dom"))
    (div :style "display:flex;flex-direction:column"
      (~hyperscript/hs-test-card
  :name "can remove class ref on a single div"
  :html "<div class='foo' _='on click remove .foo'></div>"
  :action "div.click()"
  :check "div.classList.contains(\"foo\").should.equal(true) && div.classList.contains(\"foo\").should.equal(false)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-add-class _el-div \"foo\")
    (dom-set-attr _el-div \"_\" \"on click remove .foo\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert (not (dom-has-class? _el-div \"foo\")))
  ))")
(~hyperscript/hs-test-card
  :name "can remove class ref on a single form"
  :html "<form class='foo' _='on click remove .foo'></form>"
  :action "form.click()"
  :check "form.classList.contains(\"foo\").should.equal(true) && form.classList.contains(\"foo\").should.equal(false)"
  :run-src "(fn (sandbox)
  (let ((_el-form (dom-create-element \"form\")))
    (dom-add-class _el-form \"foo\")
    (dom-set-attr _el-form \"_\" \"on click remove .foo\")
    (dom-append sandbox _el-form)
    (hs-activate! _el-form)
    (dom-dispatch _el-form \"click\" nil)
    (assert (not (dom-has-class? _el-form \"foo\")))
  ))")
(~hyperscript/hs-test-card
  :name "can target another div for class ref"
  :html "<div class='foo' id='bar'></div> | <div _='on click remove .foo from #bar'></div>"
  :action "div.click()"
  :check "bar.classList.contains(\"foo\").should.equal(true) && div.classList.contains(\"foo\").should.equal(false) && bar.classList.contains(\"foo\").should.equal(false) && div.classList.contains(\"foo\").should.equal(false)"
  :run-src "(fn (sandbox)
  (let ((_el-bar (dom-create-element \"div\")) (_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-bar \"id\" \"bar\")
    (dom-add-class _el-bar \"foo\")
    (dom-set-attr _el-div \"_\" \"on click remove .foo from #bar\")
    (dom-append sandbox _el-bar)
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert (not (dom-has-class? _el-bar \"foo\")))
    (assert (not (dom-has-class? _el-div \"foo\")))
  ))")
(~hyperscript/hs-test-card
  :name "can remove non-class attributes"
  :html "<div foo='bar' _='on click remove [@foo]'></div>"
  :action "div.click()"
  :check "div.getAttribute(\"foo\").should.equal(\"bar\") && div.hasAttribute(\"foo\").should.equal(false)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click remove [@foo]\")
    (dom-set-attr _el-div \"foo\" \"bar\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert (not (dom-has-attr? _el-div \"foo\")))
  ))")
(~hyperscript/hs-test-card
  :name "can remove elements"
  :html "<div _='on click remove me'></div>"
  :action "div.click()"
  :check "assert.isNotNull(div.parentElement) && assert.isNull(div.parentElement)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click remove me\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert (nil? (dom-parent _el-div)))
  ))")
(~hyperscript/hs-test-card
  :name "can remove other elements"
  :html "<div _='on click remove #that'></div> | <div id='that'></div>"
  :action "div.click()"
  :check "assert.isNotNull(div2.parentElement) && assert.isNull(div2.parentElement)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-that (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click remove #that\")
    (dom-set-attr _el-that \"id\" \"that\")
    (dom-append sandbox _el-div)
    (dom-append sandbox _el-that)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert (nil? (dom-parent _el-that)))
  ))")
(~hyperscript/hs-test-card
  :name "can remove parent element"
  :html "<div id='p1'><button  id='b1' _=\"on click remove my.parentElement\"></button></div> "
  :action "btn.click()"
  :check "assert.isNotNull(div.parentElement) && assert.isNull(div.parentElement)"
  :run-src "(fn (sandbox)
  (let ((_el-p1 (dom-create-element \"div\")) (_el-b1 (dom-create-element \"button\")))
    (dom-set-attr _el-p1 \"id\" \"p1\")
    (dom-set-attr _el-b1 \"id\" \"b1\")
    (dom-set-attr _el-b1 \"_\" \"on click remove my.parentElement\")
    (dom-append sandbox _el-p1)
    (dom-append _el-p1 _el-b1)
    (hs-activate! _el-b1)
    (dom-dispatch _el-p1 \"click\" nil)
    (assert (nil? (dom-parent _el-p1)))
  ))")
(~hyperscript/hs-test-card
  :name "can remove multiple class refs"
  :html "<div class='foo bar doh' _='on click remove .foo .bar'></div>"
  :action "div.click()"
  :check "div.classList.contains(\"foo\").should.equal(true) && div.classList.contains(\"bar\").should.equal(true) && div.classList.contains(\"doh\").should.equal(true) && div.classList.contains(\"foo\").should.equal(false) && div.classList.contains(\"bar\").should.equal(false) && div.classList.contains(\"doh\").should.equal(true)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-add-class _el-div \"foo\")
    (dom-add-class _el-div \"bar\")
    (dom-add-class _el-div \"doh\")
    (dom-set-attr _el-div \"_\" \"on click remove .foo .bar\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert (not (dom-has-class? _el-div \"foo\")))
    (assert (not (dom-has-class? _el-div \"bar\")))
    (assert (dom-has-class? _el-div \"doh\"))
  ))")
(~hyperscript/hs-test-card
  :name "can remove query refs from specific things"
  :html "<div><div id='d1' _='on click remove <p/> from me'><p>foo</p>bar</div><p>doh</p></div>"
  :action "d1.click()"
  :check "div.innerHTML.includes(\"foo\").should.equal(true) && div.innerHTML.includes(\"bar\").should.equal(true) && div.innerHTML.includes(\"doh\").should.equal(true) && div.innerHTML.includes(\"foo\").should.equal(false) && div.innerHTML.includes(\"bar\").should.equal(true) && div.innerHTML.includes(\"doh\").should.equal(true)"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")) (_el-d1 (dom-create-element \"div\")) (_el-p (dom-create-element \"p\")) (_el-p3 (dom-create-element \"p\")))
    (dom-set-attr _el-d1 \"id\" \"d1\")
    (dom-set-attr _el-d1 \"_\" \"on click remove <p/> from me\")
    (dom-set-inner-html _el-p \"foo\")
    (dom-set-inner-html _el-p3 \"doh\")
    (dom-append sandbox _el-div)
    (dom-append _el-div _el-d1)
    (dom-append _el-d1 _el-p)
    (dom-append _el-div _el-p3)
    (hs-activate! _el-d1)
    (dom-dispatch _el-d1 \"click\" nil)
    ;; SKIP check: skip div.innerHTML.includes(\"foo\").should.equal(true)
    ;; SKIP check: skip div.innerHTML.includes(\"bar\").should.equal(true)
    ;; SKIP check: skip div.innerHTML.includes(\"doh\").should.equal(true)
    ;; SKIP check: skip div.innerHTML.includes(\"foo\").should.equal(false)
  ))")
(~hyperscript/hs-test-card
  :name "can filter class removal via the when clause"
  :html "<div id='trigger' _='on click remove .highlight from .item when it matches .old'></div><div id='d1' class='item old highlight'></div><div id='d2' class='item highlight'></div>"
  :action "find('#trigger').dispatchEvent('click')"
  :check "toHaveClass(/highlight/); toHaveClass(/highlight/)"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))")
(~hyperscript/hs-test-card
  :name "can remove CSS properties"
  :html "<div style='color: red; font-weight: bold;' _='on click remove {color} from me'></div>"
  :action "find('div').dispatchEvent('click')"
  :check "toBe(''); toBe('bold')"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))")
(~hyperscript/hs-test-card
  :name "can remove multiple CSS properties"
  :html "<div style='color: red; font-weight: bold; opacity: 0.5;' _='on click remove {color; font-weight} from me'></div>"
  :action "find('div').dispatchEvent('click')"
  :check "toBe(''); toBe(''); toBe('0.5')"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))")
(~hyperscript/hs-test-card
  :name "can remove a value from an array"
  :html "<div _=\"on click
		                      set :arr to [1,2,3,4]
		                      remove 3 from :arr
		                      put :arr as String into me\"></div>"
  :action "find('div').dispatchEvent('click')"
  :check "toHaveText(\"1,2,4\")"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))")
(~hyperscript/hs-test-card
  :name "can remove a value from a set"
  :html "<div _=\"on click
		                      set :s to ['a','b','c'] as Set
		                      remove 'b' from :s
		                      put :s.size into me\"></div>"
  :action "find('div').dispatchEvent('click')"
  :check "toHaveText(\"2\")"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))"))))
