stockpile-co / api

The API for Stockpile, an app that manages stuff for organizations.
0 stars 1 forks source link

Improve subscription webhook endpoint tests #308

Closed AdamVig closed 6 years ago

AdamVig commented 7 years ago

Currently, the tests make actual Stripe subscriptions and attempt to change the subscriptions in order to cover all of the behavior that the webhook endpoint supports. This is impossible, however, because some changes require time to elapse before the subscription will change state. It also dramatically slows down the execution of all of the tests when calls to Stripe are added in.

It would be better to pass Stripe to the subscription webhook handler as a parameter or to mock Stripe using a library that allows overriding require(). Either of these approaches would allow the tests to use prebuilt requests from the Stripe API as test data, instead of relying on the state of actual test subscriptions.