Skip to content

Commit

Permalink
#14 : first UI test !
Browse files Browse the repository at this point in the history
  • Loading branch information
vankeisb committed Nov 23, 2018
1 parent 88fe8d7 commit 2a95ba2
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"hecrj/html-parser": "1.0.1 <= v < 2.0.0"
},
"test-dependencies": {
"elm-explorations/test": "1.1.0 <= v < 2.0.0"
"elm-explorations/test": "1.2.0 <= v < 2.0.0"
}
}
70 changes: 70 additions & 0 deletions tests/UiTests.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module UiTests exposing (..)

import Expect exposing (Expectation)
import Test exposing (..)
import Textarea
import Html
import Html.Attributes as A
import Test.Html.Query exposing (..)
import Test.Html.Selector exposing (..)
import Range exposing (Range)


type Msg
= TextareaMsg Textarea.Msg


type MyStyle
= Style1
| Style2


renderer : List MyStyle -> List (Html.Attribute Msg)
renderer myStyles =
myStyles
|> List.foldl
(\myStyle attrs ->
case myStyle of
Style1 ->
attrs
++ [ A.style "color" "grey"
]

Style2 ->
attrs
++ [ A.style "color" "#C086D0"
]
)
[]

suite: Test
suite =
describe "UI Tests"
[ test "single line, no styles" <|
\_ ->
let
(m,c) =
Textarea.init
{ idPrefix = "my-ta"
, highlighter =
\text ->
[]
, initialText = "foo bar baz"
}

in
Textarea.view
TextareaMsg
(Textarea.attributedRenderer m TextareaMsg renderer)
m
|> fromHtml
|> find [ attribute <| A.attribute "data-from" "0" ]
|> children [ text "f" ]
|> count (Expect.equal 1)
]


--
--makeExpected : String -> List (Range, MyStyle) ->
--makeExpected s =
-- []

0 comments on commit 2a95ba2

Please # to comment.