Add test for default behavior

Unable to test containsForm behavior since that means triggering an event that is not registered
This commit is contained in:
Brian J. Cardiff 2022-07-05 17:18:26 -03:00
parent f8f5f6f081
commit 2bed33181b

View File

@ -2,6 +2,7 @@ module Spec.Nri.Ui.Menu exposing (spec)
import Html.Attributes as Attributes
import Html.Styled as HtmlStyled
import Json.Encode as Encode
import Nri.Ui.ClickableText.V3 as ClickableText
import Nri.Ui.Menu.V3 as Menu
import ProgramTest exposing (ProgramTest, ensureViewHas, ensureViewHasNot)
@ -32,6 +33,15 @@ spec =
|> clickMenuButton
|> ensureViewHasNot (menuContentSelector menuContent)
|> ProgramTest.done
, test "Close on tab key" <|
\() ->
program []
-- Menu opens on mouse click and closes on tab key
|> clickMenuButton
|> ensureViewHas (menuContentSelector menuContent)
|> pressTabKey
|> ensureViewHasNot (menuContentSelector menuContent)
|> ProgramTest.done
]
@ -122,3 +132,20 @@ clickMenuButton =
]
)
Event.click
pressTabKey : ProgramTest model msg effect -> ProgramTest model msg effect
pressTabKey =
ProgramTest.simulateDomEvent
(Query.find
[ Selector.class "Container"
]
)
(Event.custom
"keydown"
(Encode.object
[ ( "keyCode", Encode.int 9 )
, ( "shiftKey", Encode.bool False )
]
)
)