mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-21 12:41:39 +03:00
💀 Switch test that requires setup
This commit is contained in:
parent
3e1ba460fb
commit
540c10452d
@ -1,45 +0,0 @@
|
|||||||
module Spec.Nri.Ui.Switch exposing (spec)
|
|
||||||
|
|
||||||
import Accessibility.Widget as Widget
|
|
||||||
import Html.Styled as HtmlStyled
|
|
||||||
import Nri.Ui.Switch.V1 as Switch
|
|
||||||
import ProgramTest exposing (..)
|
|
||||||
import Test exposing (..)
|
|
||||||
import Test.Html.Selector as Selector
|
|
||||||
|
|
||||||
|
|
||||||
spec : Test
|
|
||||||
spec =
|
|
||||||
describe "Nri.Ui.Switch.V1"
|
|
||||||
[ test "it works" <|
|
|
||||||
\() ->
|
|
||||||
program
|
|
||||||
[ Switch.label (HtmlStyled.text "Switch")
|
|
||||||
, Switch.onSwitch identity
|
|
||||||
, Switch.id "switch"
|
|
||||||
]
|
|
||||||
True
|
|
||||||
-- switch starts with aria-checked=true and displays the label
|
|
||||||
|> ensureViewHas
|
|
||||||
[ Selector.attribute (Widget.checked (Just True))
|
|
||||||
, Selector.text "Switch"
|
|
||||||
]
|
|
||||||
-- user can click the first switch
|
|
||||||
|> check "switch" "Switch" False
|
|
||||||
-- the switch now has aria-checked=false
|
|
||||||
|> ensureViewHas
|
|
||||||
[ Selector.attribute (Widget.checked (Just False))
|
|
||||||
, Selector.text "Switch"
|
|
||||||
]
|
|
||||||
|> done
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
program : List (Switch.Attribute Bool) -> Bool -> ProgramTest Bool Bool ()
|
|
||||||
program attributes init =
|
|
||||||
ProgramTest.createSandbox
|
|
||||||
{ init = init
|
|
||||||
, update = \msg model -> msg
|
|
||||||
, view = \isOpen -> Switch.view attributes isOpen |> HtmlStyled.toUnstyled
|
|
||||||
}
|
|
||||||
|> ProgramTest.start ()
|
|
Loading…
Reference in New Issue
Block a user