mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-09-21 04:07:54 +03:00
add tests for helpfully disabled select
This commit is contained in:
parent
57e30305a9
commit
9235e41604
@ -1,5 +1,8 @@
|
||||
module Spec.Nri.Ui.Select exposing (spec)
|
||||
|
||||
import Accessibility.Aria as Aria
|
||||
import Accessibility.Key as Key
|
||||
import Accessibility.Role as Role
|
||||
import Html.Attributes as Attributes
|
||||
import Html.Styled
|
||||
import Nri.Ui.Select.V9 as Select
|
||||
@ -61,6 +64,23 @@ spec =
|
||||
, attribute (Attributes.value "My favorite animal is something else")
|
||||
]
|
||||
|> done
|
||||
, test "has the correct attributes when disabled" <|
|
||||
\() ->
|
||||
disabled
|
||||
|> ensureViewHas
|
||||
[ attribute (Aria.disabled True)
|
||||
, attribute Role.listBox
|
||||
, attribute (Key.tabbable True)
|
||||
]
|
||||
|> done
|
||||
|
||||
{- Attempted to simulate click and keydown events on the enabled select element,
|
||||
similar to the approach in tests/Spec/Nri/Ui/Switch.elm
|
||||
Got the following error:
|
||||
|
||||
simulateDomEvent "keydown":
|
||||
Event.expectEvent: I found a node, but it does not listen for "keydown" events like I expected it would.
|
||||
-}
|
||||
]
|
||||
|
||||
|
||||
@ -119,6 +139,33 @@ grouped =
|
||||
|> ProgramTest.start ()
|
||||
|
||||
|
||||
disabled : ProgramTest Model Msg ()
|
||||
disabled =
|
||||
ProgramTest.createSandbox
|
||||
{ init = { favoriteAnimal = Nothing }
|
||||
, update = update
|
||||
, view =
|
||||
\model ->
|
||||
Select.view "Favorite type of animal"
|
||||
[ Select.choices toString
|
||||
(List.map
|
||||
(\animal ->
|
||||
{ label = toString animal
|
||||
, value = animal
|
||||
}
|
||||
)
|
||||
(mammals ++ amphibians ++ [ Other ])
|
||||
)
|
||||
, Select.value model.favoriteAnimal
|
||||
, Select.id selectId
|
||||
, Select.disabled
|
||||
]
|
||||
|> Html.Styled.map SelectFavorite
|
||||
|> Html.Styled.toUnstyled
|
||||
}
|
||||
|> ProgramTest.start ()
|
||||
|
||||
|
||||
selectAnimal : Animal -> ProgramTest a b c -> ProgramTest a b c
|
||||
selectAnimal animal =
|
||||
selectOption selectId "Favorite type of animal" (toString animal) (toString animal)
|
||||
|
Loading…
Reference in New Issue
Block a user