noredink-ui/styleguide/tests/SwitchExampleSpec.elm

37 lines
1.1 KiB
Elm
Raw Normal View History

2022-04-12 21:18:09 +03:00
module SwitchExampleSpec exposing (suite)
import Accessibility.Aria as Aria
2022-04-12 22:45:17 +03:00
import ProgramTest exposing (..)
import Routes exposing (Route)
2022-04-12 21:18:09 +03:00
import Test exposing (..)
2022-04-12 22:45:17 +03:00
import Test.Html.Selector exposing (..)
import TestApp exposing (app)
route : Route
route =
Routes.Doodad "Switch"
2022-04-12 21:18:09 +03:00
suite : Test
suite =
2022-04-12 22:45:17 +03:00
describe "Switch"
[ test "it works" <|
\() ->
app route
|> ensureViewHas [ text "Nri.Ui.Switch" ]
-- switch starts with aria-checked=true and text "On"
|> ensureViewHas
[ attribute (Aria.checked (Just True))
, text "On"
]
-- user can click the first switch
|> check "switch-interactive" "On" False
-- the switch now has aria-checked=false and text "Off"
|> ensureViewHas
[ attribute (Aria.checked (Just False))
, text "Off"
]
2022-04-12 22:45:17 +03:00
|> done
]