katowulf / mockfirebase

Firebase mock library for writing unit tests (experimental)
157 stars 40 forks source link

Add an `onFlush` callback for hooking to ngMock.timeout, sinon fake-timers, etc. #89

Open jamestalmage opened 8 years ago

jamestalmage commented 8 years ago

Something like:

ref.onFlush(function(){
  $timeout.flush();
  // or
  clock.tick();
});

Need to think through the API, and how it would interact with autoFlush, etc.

Just putting the idea out there.

bendrucker commented 8 years ago

Any reason why this would be needed over just monkey patching flush?

jamestalmage commented 8 years ago

I don't know, it just popped in my head while reading #87.

I'd need to actually try it on a project first, and see if it had utility. It does seem I commonly $timeout.flush() after ref.set, but not sure what the implication would be.

We could certainly make this easier to toggle on and off than a monkey patch would be.

Like I said, just spitting out an idea.