Closed umaar closed 6 years ago
I am not sure of this use case...
We should test things in the way they are used, (e.g. the harness), any sub-widgets in a harnessed widgets get stubbed out (as is appropriate for a unit type of test), the only thing that remains is their properties and listeners that were rendered by the harnessed widget. The APIs of .callListener()
which will execute the method (which is a property of a widget). This should trigger any business logic in the enclosing widget. These can be access by key
or by index (including deep indexes).
Validating some property should be done through an expected render. We have specifically discouraged cherry picking of individual properties, because they tend to give the end developer a false sense of only positive test cases and therefore miss any unexpected properties or values. If there is a use case where cherry picking is really desired, you can use the .getRender()
which will return the render structure of DNodes
which can be introspected in a similar way to the above.
I don't think that this is a valid use case when testing generated VDom structures for a widget render. It is perfectly valid to assert that a widget has a property that is a "widget", similar to a render property.
Enhancement
Imagine code like this:
From a unit test, I would like to do something like:
Or something similar.