Fork me on GitHub
#reagent
<
2015-07-19
>
gadfly36100:07:11

@jarrodctaylor I see you made a PR on reagent-template, glad it was just a version problem!

Jarrod Taylor (Clojure team)01:07:57

@gadfly361: Yup update clojurescript.test to 0.3.3 and it all works as desired. Wonderful when someone else has already worked out the solution to something you are stuck on.

gadfly36101:07:54

Haha absolutely

jellea14:07:46

Hey all! Say I have a long string with some line breaks which I want to break apart into some paragraph elements, how would you approach it? I thought I would be able to do it this way, but it gives an error:

(for [paragraph (split content #"\n")]
                [:p paragraph])
Danger: Discarding unexpected node:  <p data-reactid=".3.1.0.0.0.1.2">…</p> react.inc.js:2246

jellea14:07:44

Nevermind! Fixed. It was simply because react doesnt like a <p> in <p>

Jarrod Taylor (Clojure team)15:07:22

If I have a button with an :on-click that calls function button-action I can write a test that directly calls button-action and assert that it preforms as expected. However, I also want to assert that button-action will be called when the particular button is clicked. How is the best way to go about doing that?

colin.yates15:07:26

@jarrodctaylor: my gut reaction is why do you want to assert that - what is the size of the problem you are solving?

colin.yates15:07:13

Personally I always find those sorts of tests very noisy to write and the risk they cover is trivial. For me they end up not being worth the cost of the extra code.

colin.yates15:07:48

if you do still want to then I tend to redefine the button-action to a fn that sets an atom, run the code and check the atom to see what it contains

colin.yates15:07:22

you might also want to look at midje as it has great mocking support

Jarrod Taylor (Clojure team)15:07:25

@colin.yates: I think the why is spawned from having been burned a time or two from similar things in evening / weekend production regressions and knowing that it could have been caught by a test. However, it is hard to disagree that the risk they cover is relatively trivial and in some cases indeed bloats the test code for what is typically a minor benefit.

colin.yates15:07:32

I am sure I am preaching to the choir but I tend to make these hard-to-test things as dumb as possible and move all ‘logic’ to top level fns.

colin.yates15:07:44

so the only thing in the handlers is the fn to call, nothing else.

colin.yates15:07:03

that’s a lie, a great big bold faced lie. I should say it is my intent to do that simple_smile

Jarrod Taylor (Clojure team)15:07:21

Totally agree on the intent. Doesn't the quote go something like "Aim for the stars and only shoot yourself in the foot once in a while"

colin.yates15:07:50

I think ‘aim for the starts and constantly trip over the rocks at your feet’ would be more accurate for my current code 😉