featurist / mock-xhr-router

2 stars 2 forks source link

Expectations? #4

Open joshski opened 8 years ago

joshski commented 8 years ago

This is more of a "stub" router than a "mock" router. Not that I care about the name, but I was curious to know if you have you ruled out exposing a mock style API i.e. with expect and verify semantics? If so, why?

joshski commented 8 years ago

I'd like to do this in some rare cases:

pressPayNowButton().then(() =>
   // the app is awaiting an ajax response from the payment server
   // the payment server accepts the request but hangs until told how to respond
   return paymentServer.respondToPost("/pay",
      request => {
         // the test is in control, so it can fail here
         expectRequestToIncludeCorrectPaymentDetails(request)
         return { status: 200 }
      }
   )
)
.then(() => verifyAppShowsPaymentSuccessful())
.then(() => paymentServer.verifyNoPendingRequests()) // paying only once is important