Fork me on GitHub
#hoplon
<
2017-08-28
>
thedavidmeister02:08:43

@flyboarder after playing around with some specs for things that use dom elements last night, i think it could also be cool to define a :hoplon/element that has a generator for dom elements and goog.dom.isElement as predicate

thedavidmeister02:08:24

i made a bit of a start:

thedavidmeister02:08:26

(spec/def :wheel.dom/element
 (spec/spec
  goog.dom/isElement
  :gen
  (constantly
   (gen/fmap
    apply
    (gen/elements [h/div h/span h/p])))))

thedavidmeister02:08:42

eventually it could do all sorts of things like building nested structures and including text and attributes

thedavidmeister02:08:14

then you can use spec/exercise to generate example DOM for testing application logic

thedavidmeister02:08:24

a bunch of my tests started throwing #object[Error Error: Index out of bounds]

thedavidmeister02:08:31

i wonder if it has to do with the newer cljs

flyboarder02:08:44

Testing fine for me?

thedavidmeister02:08:09

yeah in my own project

thedavidmeister02:08:22

just started failing previously passing tests in master

thedavidmeister02:08:39

so i have to assume its the new snapshot coming in

flyboarder02:08:51

Cljs snapshot?

thedavidmeister03:08:42

as in, new version of hoplon, so new version of cljs

thedavidmeister03:08:04

it's alright, i'll keep poking around

thedavidmeister03:08:34

; we need to handle dynamic length cells
  (let [c (j/cell ["1" "2" "3"])
        el (h/div
            (h/for-tpl [n c]
             (h/div n)))]
   (is (= ["1" "2" "3"]
        (find-text el)))
   (reset! c ["1" "2"])
   (is (= ["1" "2"]
        (find-text el))))))

thedavidmeister03:08:52

ERROR in (??for-tpl) (cljs$core$IIndexed$_nth$arity$2@file:5422:41)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[Error Error: Index out of bounds]