Commit Graph

9 Commits

Author SHA1 Message Date
Daniel Lockyer
b226065c04
Added mailgun-client test to ensure config values are prioritised over settings
- this is the current functionality of the code, as it has always been,
  but this test ensures we prioritise the values in the config over
  those in settings
2022-08-11 09:10:49 +02:00
Daniel Lockyer
f9b90a3cfe
Added test to check sending emails when Mailgun is not configured
- this tests the early-return path linked to Mailgun not being
  configured
2022-08-11 09:10:49 +02:00
Daniel Lockyer
ddbee90c1c
Fixed bug when checking email batch size
- even though we don't do anything yet, the code was calling `.length`
  on an object, which is `undefined`
- this fixes that by checking the length of the keys
- also moves the code block down so we can early-return if mailgun is
  not configured
2022-08-11 09:10:49 +02:00
Daniel Lockyer
5d177c2a11
Added optional chaining to mailgun-client package
- this helps keep the code clean
2022-08-11 09:10:49 +02:00
Daniel Lockyer
3e6416431e
Added test to ensure events are only fetched if configured
refs https://github.com/TryGhost/Toolbox/issues/363

- this adds coverage for a branch in the code, and ensures we don't
  fetch any events if mailgun is not configured
2022-08-11 08:19:03 +02:00
Daniel Lockyer
8a32efac1f
Added further tests to mailgun-client package
refs https://github.com/TryGhost/Toolbox/issues/363

- this copies over tests from `email-analytics-provider-mailgun` that
  are more relevant here
- there is now duplication in tests across the two packages but this
  will be resolved soon
2022-08-10 19:02:53 +02:00
Daniel Lockyer
9401d835ce
Moved Mailgun settings test to mailgun-client
- this test checks that the mailgun client respects the changes in
  settings, which is something that we used to ask
  `email-analytics-provider-mailgun` to do when the mailgun client was
  made in that package
- since then, we've pulled it out, so we should move the test to the
  `mailgun-client` library
2022-08-10 18:24:35 +02:00
Daniel Lockyer
98bd5423fa
Added private getConfig function to Mailgun client lib
- the code to get the mailgun info from the config/settings will be used in
  multiple places so this pulls it out into a function
2022-08-10 17:43:19 +02:00
Daniel Lockyer
bf254b9c6a Extracted Mailgun client to separate package
refs https://github.com/TryGhost/Toolbox/issues/363

- this commit pulls all code involving the Mailgun client SDK into one
  new package called `mailgun-client`
- this means we should be able to replace `mailgun-js` (deprecated) with
  `mailgun.js` (the new, official one) without editing code all over the
  place
- this also lays some groundwork for better testing of smaller
  components
2022-08-10 17:12:37 +02:00