There are times where I'm working on components that need to yield out data transfer objects (DTO's) for the sake of dividing concerns. For example, if I have some kind of UI component that I want to be reused in multiple contexts. I would extract this presentational component into something non-async leaving a wrapper that handles an async call when it's needed. The async component then would yield out the data of the call. An example usage would be:
Now, for a test, I don't want to have to use the presentation-component
in tests for the call-ajax
component but I need some way of making assertions about the result of the ajax call yielded as data
.
My initial thought is some kind of component/helper made available only to tests that exposes an API for checking usages and what they are called with. Perhaps having something like this in the test:
this.render(hbs`
`);
Although, I'm not sure how to accomplish this.
Are there any suggestions on how I can test the data
object without printing all primitive fields from it and doing DOM lookups?
Aucun commentaire:
Enregistrer un commentaire