Question

I'm currently trying to figure out if there is a way to do a simple future/past comparison ex.

1) Check state of list by getting list length 2) Perform action which if success increments the list 3) Compare the current list length to the past.

But the concepts of Futures seems to get in my way. One would think this is a pretty normal use case.

Q: How would you go about handling past/future comparisons in Angularjs Scenario?

Was it helpful?

Solution

It's kind of longwinded, but you can define custom matchers which understand futures. For example:

angular.scenario.matcher('toBeGreaterThanFuture', function(future) {
  return +this.actual > +future.value;
});

Use like:

listLengthBefore = repeater('.td').count();
// Do some stuff.
listLengthAfter = repeater('.td').count();
expect(listLengthAfter).toBeGreaterThanFuture(listLengthBefore);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top