1

A purescript-halogen component has an eval function defining how it evaluates queries. I'd like to write tests to cover the behaviour of the component; how would I go about doing this?

For instance, if my component has GetValue in its query algebra, I'd like to write a test which creates the component with initial state, evaluates a GetValue query, and asserts that the value received matches what was provided in the initial state. If my component also has a SetValue, I might like to assert that evaluating a GetValue after a SetValue returns what I expect.

I can't find any examples of this sort of testing (I refer to Slamdata's code a lot but the only tests I see there are Selenium tests).

I feel like the solution must lie in Halogen.Component, where functions like queryComponent and initializeComponent reside; I've looked at the Halogen.Driver source to try to understand how to use them but I've been unable to figure it out.

Could someone either point me to an example of testing a Halogen component, or explain how one would be able to create a component, have it evaluate a query, and observe the results?

Paul Hendry
  • 76
  • 1
  • 4
  • This is a bit of an open question really. Halogen was designed with being able to do this sort of thing in mind, but we've not put anything into practice yet - the idea was to use a `g` for the component that allows for easy mocking of effectful actions (so `Aff` is unnecessary) and then using a custom driver to run the component... *waves hands* something. ;) – gb. Sep 24 '16 at 10:04

0 Answers0