Re: [elm-discuss] Writing tests on elm-lang/html data structures

2016-07-17 Thread Noah Hall
Yep, if you want to use karma

On Sun, Jul 17, 2016 at 6:40 PM, Conrad Dean  wrote:
> By that do you mean write the test suite in JS and call elm with ports?
>
> On Sat, Jul 16, 2016 at 5:22 PM, Noah Hall  wrote:
>>
>> It has a native function to grab the internal node representation, so
>> you'll have to clone it and replace some of the refereneces to instead
>> talk about your package name.
>>
>> One caveat is that I don't remember if it works with Markdown right
>> now, since Markdown uses a custom renderer which has a different
>> internal representation.
>>
>> You might be better off writing tests using karma or something for
>> now, actually. Or just implement the representation of the call to the
>> markdown renderer.
>>
>> On Sat, Jul 16, 2016 at 11:04 PM, Conrad Dean 
>> wrote:
>> > oh this looks great!  how do i install/vendor it?
>> >
>> > On Sat, Jul 16, 2016 at 4:49 PM, Noah Hall  wrote:
>> >>
>> >> We've been using this ->
>> >> https://github.com/eeue56/elm-server-side-renderer for testing that in
>> >> 0.17.
>> >>
>> >>
>> >> On Saturday, July 16, 2016, Conrad Dean 
>> >> wrote:
>> >>>
>> >>> I want to write tests for https://github.com/evancz/elm-markdown , but
>> >>> I'm having problems comparing Html objects.
>> >>>
>> >>> There's something about the internals of a VirtualDom/Html object that
>> >>> are preventing me from testing if two html nodes are equal and I was
>> >>> wondering if someone could get me up to speed with how to strip that
>> >>> stuff
>> >>> out so that I'm just comparing either the raw HTML strings, or more
>> >>> basic
>> >>> Html type objects.
>> >>>
>> >>> Here's my test and error message from running my ElmTest suite:
>> >>>
>> >>> module MarkdownSpec exposing (all)
>> >>>
>> >>> import ElmTest exposing (..)
>> >>>
>> >>> import Html exposing (Html, Attribute)
>> >>> import Markdown exposing (toHtml)
>> >>>
>> >>> all : Test
>> >>> all =
>> >>> suite "MAKR DOEN"
>> >>> , test "simple html"
>> >>> <| assertHtmlEqual (Html.text "sup") (Html.text "sup")
>> >>> , test "basic MD"
>> >>> <| assertHtmlEqual (toHtml [] "sup") (Html.text "sup")
>> >>> ]
>> >>>
>> >>> assertHtmlEqual: Html msg -> Html msg -> Assertion
>> >>> assertHtmlEqual a b = assertEqual a b
>> >>>
>> >>>
>> >>> Error:
>> >>>
>> >>> $ elm make test/TestRunner.elm --output _build/test.js && node
>> >>> _build/test.js
>> >>> Success! Compiled 2 modules.
>> >>> Successfully generated _build/test.js
>> >>> /Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:567
>> >>> throw new Error(
>> >>> ^
>> >>>
>> >>> Error: Ran into a `Debug.crash` in module `ElmTest.Runner.Console`
>> >>>
>> >>> This was caused by the `case` expression between lines 28 and 33.
>> >>> One of the branches ended with a crash and the following value got
>> >>> through:
>> >>>
>> >>> False
>> >>>
>> >>> The message provided by the code author is:
>> >>>
>> >>>   3 suites run, containing 5 tests
>> >>>   1 suites and 4 tests passed
>> >>>   2 suites and 1 tests failed
>> >>>
>> >>> Test Suite: very tests: FAILED
>> >>>   Test Suite: A Test Suite: all tests passed
>> >>>   Test Suite: MAKR DOEN: FAILED
>> >>> Addition: passed.
>> >>> simple html: passed.
>> >>> basic MD: FAILED. Expected: { type = "custom", facts = {}, model =
>> >>> {
>> >>> options = { githubFlavored = Just { tables = False, breaks = False },
>> >>> defaultHighlighting = Nothing, sanitize = False, smartypants = False
>> >>> },
>> >>> markdown = "sup" }, impl = { render = , diff =
>> >>>  } }; got: { type = "text", text = "sup" }
>> >>> at /Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:567:9
>> >>> at _elm_community$elm_test$ElmTest_Runner_Console$runDisplay
>> >>> (/Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:7778:9)
>> >>> at _elm_community$elm_test$ElmTest_Runner_Console$runSuite
>> >>> (/Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:7793:11)
>> >>> at Object.
>> >>> (/Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:8061:8)
>> >>> at Object.
>> >>> (/Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:8096:4)
>> >>> at Module._compile (module.js:435:26)
>> >>> at Object.Module._extensions..js (module.js:442:10)
>> >>> at Module.load (module.js:356:32)
>> >>> at Function.Module._load (module.js:311:12)
>> >>> at Function.Module.runMain (module.js:467:10)
>> >>>
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google
>> >>> Groups
>> >>> "Elm Discuss" group.
>> >>> To unsubscribe from this group and stop receiving emails from it, send
>> >>> an
>> >>> email to elm-discuss+unsubscr...@googlegroups.com.
>> >>> For more options, visit https://groups.google.com/d/optout.
>> >>
>> >> --
>> >> You received this message because you are subscribed to 

Re: [elm-discuss] Writing tests on elm-lang/html data structures

2016-07-16 Thread Noah Hall
We've been using this -> https://github.com/eeue56/elm-server-side-renderer
for testing that in 0.17.

On Saturday, July 16, 2016, Conrad Dean  wrote:

> I want to write tests for https://github.com/evancz/elm-markdown , but
> I'm having problems comparing Html objects.
>
> There's something about the internals of a VirtualDom/Html object that are
> preventing me from testing if two html nodes are equal and I was wondering
> if someone could get me up to speed with how to strip that stuff out so
> that I'm just comparing either the raw HTML strings, or more basic Html
> type objects.
>
> *Here's my test and error message from running my ElmTest suite:*
>
> module MarkdownSpec exposing (all)
>
> import ElmTest exposing (..)
>
> import Html exposing (Html, Attribute)
> import Markdown exposing (toHtml)
>
> all : Test
> all =
> suite "MAKR DOEN"
> , test "simple html"
> <| assertHtmlEqual (Html.text "sup") (Html.text "sup")
> , test "basic MD"
> <| assertHtmlEqual (toHtml [] "sup") (Html.text "sup")
> ]
>
> assertHtmlEqual: Html msg -> Html msg -> Assertion
> assertHtmlEqual a b = assertEqual a b
>
>
> *Error:*
>
> $ elm make test/TestRunner.elm --output _build/test.js && node
> _build/test.js
> Success! Compiled 2 modules.
> Successfully generated _build/test.js
> /Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:567
> throw new Error(
> ^
>
> Error: Ran into a `Debug.crash` in module `ElmTest.Runner.Console`
>
> This was caused by the `case` expression between lines 28 and 33.
> One of the branches ended with a crash and the following value got through:
>
> False
>
> The message provided by the code author is:
>
>   3 suites run, containing 5 tests
>   1 suites and 4 tests passed
>   2 suites and 1 tests failed
>
> Test Suite: very tests: FAILED
>   Test Suite: A Test Suite: all tests passed
>   Test Suite: MAKR DOEN: FAILED
> Addition: passed.
> simple html: passed.
> basic MD: FAILED. Expected: { type = "custom", facts = {}, model = {
> options = { githubFlavored = Just { tables = False, breaks = False },
> defaultHighlighting = Nothing, sanitize = False, smartypants = False },
> markdown = "sup" }, impl = { render = , diff =
>  } }; got: { type = "text", text = "sup" }
> at /Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:567:9
> at _elm_community$elm_test$ElmTest_Runner_Console$runDisplay
> (/Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:7778:9)
> at _elm_community$elm_test$ElmTest_Runner_Console$runSuite
> (/Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:7793:11)
> at Object.
> (/Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:8061:8)
> at Object.
> (/Users/conrad/dev/foss/elm/elm-markdown/_build/test.js:8096:4)
> at Module._compile (module.js:435:26)
> at Object.Module._extensions..js (module.js:442:10)
> at Module.load (module.js:356:32)
> at Function.Module._load (module.js:311:12)
> at Function.Module.runMain (module.js:467:10)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.