Module

Elmish.Test.Combinators

Package
purescript-elmish-testing-library
Repository
collegevine/purescript-elmish-testing-library

#within Source

within :: forall m a. Testable m => String -> m a -> m a

Finds an element by the given selector and runs the given computation in the context of that element.

Example:

describe "My component" $
  it "should work" $
    testComponent { init, view, update } do

      within "section:nth-child(1)" do
        find "h2" >> text >>= shouldEqual "First Section"
        clickOn "button"

      within "section:nth-child(2)" do
        find "h2" >> text >>= shouldEqual "Second Section"
        find "input[type=text]" >> change "Some Text"

#(##) Source

Operator alias for Elmish.Test.Combinators.within' (left-associative / precedence 8)

#within' Source

within' :: forall m a. Testable m => Element -> m a -> m a

A more general version of within that accepts an Element instead of a CSS selector.

In its operator form ## this function can be used similarly to postfix function application, for example:

button <- find "button"
button ## click

#(>>) Source

Operator alias for Elmish.Test.Combinators.chainM (left-associative / precedence 8)

#chainM Source

chainM :: forall m a. Testable m => m Element -> m a -> m a

Used in its operator form >>, this function chains two DOM operations together, taking the output of the first operation and making it context of the second one. For example:

buttonInsideDiv <- find "div" >> find "button"
inputValue <- find "input" >> attr "value"

#($$) Source

Operator alias for Elmish.Test.Combinators.chain (left-associative / precedence 8)

#chain Source

chain :: forall m a. Testable m => m a -> Element -> m a

A flipped version of within'. In its operator form $$ this function can be used similarly to function application, for example:

button <- find "button"
click $$ button

#forEach Source

forEach :: forall m. Testable m => m Unit -> Array Element -> m Unit

Runs the given computation multiple times, in the context of each of the given Elements.

findAll "button" >> forEach click

#mapEach Source

mapEach :: forall m a. Testable m => m a -> Array Element -> m (Array a)

Runs the given computation multiple times, in the context of each of the given Elements, and returns their results as an array.

values <- findAll "input" >> mapEach (prop P.value)