Skip to content

Add a way to get the model from a ProgramTest #174

@JasterV

Description

@JasterV

I'm storing some data inside the model that I would like to use on the tests to compute some values.

For example, I'm storing the currentDate inside the model, and later on I need the currentdate to mock an HTTP response.

So I would like to be able to do something like:

start
    |> ProgramTest.withModel
         (\model -> 
               ProgramTest.simulateHttpOk "POST" mockUrl (responseSuccess model.currentDate)
         )
       |> ProgramTest.clickButton "button"
       |> ProgramTest.expectViewHasNot [ Selector.id "test-id" ]

The signature of the function could be something like:

withModel : (model -> ProgramTest model msg effect -> ProgramTest model msg effect) -> ProgramTest model msg effect -> ProgramTest model msg effect

What do you think? If you agree I could even open a PR myself :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions