I am currently working on a part of our application that will display a subset of topo data under certain circumstances. I am trying to test part of that functionality but I am currently unable to get my code to run in a test.
I am quite new to the esri stack and particularly front end testing so it is possible I'm doing something wrong or misunderstanding a concept, however a lot of trial and error and Google searching hasn't turned anything up.
At the most basic level my issue is that I can't get the watcher created by a reactiveUtils instance to trigger.
I have a MapView that is passed into my function I then have code that looks like this
reactiveUtils.when(
() => view.stationary === true,
() => {
do stuff
});
I am mocking the view and as such when I pass it in I can confirm that the value of stationary is true. I hoped that would cause the code inside that reactiveUtils to trigger but it does not. I have verified that the value is true at that point and that no code inside is running.
At this stage I'm at a loss. I don't know if it is possible to trigger my mock to start false and then switch true at the right time. I suspect not as the test would finish before that could occur. Equally I don't know how to mock out or otherwise trigger that reactiveUtils.
An option is to pull the code inside, out and test that separately but that then does not encompass everything I want to test. Another option would be to feed in a real view and simulate it being moved. That is a bigger scope than what I am trying to do here.
Can anyone suggest an option for how I can get this to work? Happy to provide more information/code if that will help. There seems to be a general lack of documentation around using things like these in tests, does such documentation exist and if so please could someone point me towards it?