mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-18 19:21:29 +03:00
e2907d9ba2
* Use elm-css 16.0.0 * 💀 Ui.Checkbox V1 and V2 * s/Css.Foreign/Css.Global/g * 💀 Nri.Ui.Styles.V1 * 💀 BannerAlert.V1 * 💀 Modal.V1 * 💀 Dropdown.V1 * 💀 Select.V1 and V2 * 💀 Alert.V1 * 💀 Button.V1 and V2 * 💀 Divider.V1 * 💀 Icon.V1 and V2 * 💀 Outline.V1 * 💀 SegmentedControl.V1-V5 * 💀 TextArea.V1 and V2 * 💀 TextInput.V1 * delete the rest of the modules * actually more deletions * InputStyles v1 is unused * move to src-0.18 * do the 0.19 upgrade * select options are addressable by index * elm-css 16 * update scripts * elm-format * Update V2.elm * put the nbsp back * elm-format validation for both versions
68 lines
1.8 KiB
Elm
68 lines
1.8 KiB
Elm
module Spec.Nri.Ui.Select exposing (spec)
|
|
|
|
import Expect exposing (Expectation)
|
|
import Html
|
|
import Html.Attributes as Attr
|
|
import Html.Styled
|
|
import Nri.Ui.Select.V5
|
|
import Test exposing (..)
|
|
import Test.Html.Query as Query
|
|
import Test.Html.Selector exposing (..)
|
|
|
|
|
|
spec : Test
|
|
spec =
|
|
describe "view"
|
|
[ describe "V5"
|
|
(viewSuite
|
|
(\config ->
|
|
{ choices = config.choices, current = config.current, id = Nothing, valueToString = identity }
|
|
|> Nri.Ui.Select.V5.view
|
|
|> Html.Styled.toUnstyled
|
|
)
|
|
)
|
|
]
|
|
|
|
|
|
viewSuite :
|
|
({ choices : List { label : String, value : String }, current : String } -> Html.Html msg)
|
|
-> List Test
|
|
viewSuite view =
|
|
[ test "shows all options" <|
|
|
\() ->
|
|
viewTest
|
|
view
|
|
"Tacos"
|
|
[ "Tacos", "Burritos", "Enchiladas" ]
|
|
|> Query.find [ tag "select" ]
|
|
|> Query.findAll [ tag "option" ]
|
|
|> Query.count (Expect.equal 3)
|
|
, test "selects the current option" <|
|
|
\() ->
|
|
viewTest
|
|
view
|
|
"Burritos"
|
|
[ "Tacos", "Burritos", "Enchiladas" ]
|
|
|> Query.find
|
|
[ tag "option"
|
|
, attribute <| Attr.selected True
|
|
]
|
|
|> Query.has [ text "Burritos" ]
|
|
]
|
|
|
|
|
|
viewTest :
|
|
({ choices : List { label : a, value : a }, current : b } -> Html.Html msg)
|
|
-> b
|
|
-> List a
|
|
-> Query.Single msg
|
|
viewTest view selected items =
|
|
Query.fromHtml
|
|
(Html.div []
|
|
[ view
|
|
{ choices = List.map (\x -> { label = x, value = x }) items
|
|
, current = selected
|
|
}
|
|
]
|
|
)
|