SubscriptionEmailHandlerTests.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const SandboxedModule = require('sandboxed-module')
  2. const sinon = require('sinon')
  3. const { expect } = require('chai')
  4. const modulePath =
  5. '../../../../app/src/Features/Subscription/SubscriptionEmailHandler'
  6. describe('SubscriptionEmailHandler', function () {
  7. beforeEach(function () {
  8. this.userId = '123456789abcde'
  9. this.email = 'test@test.com'
  10. this.SubscriptionEmailHandler = SandboxedModule.require(modulePath, {
  11. requires: {
  12. '../Email/EmailHandler': (this.EmailHandler = {
  13. promises: {
  14. sendEmail: sinon.stub().resolves({}),
  15. },
  16. }),
  17. '../User/UserGetter': (this.UserGetter = {
  18. promises: {
  19. getUser: sinon
  20. .stub()
  21. .resolves({ _id: this.userId, email: 'test@test.com' }),
  22. },
  23. }),
  24. },
  25. })
  26. })
  27. it('sends trail onboarding email', async function () {
  28. await this.SubscriptionEmailHandler.sendTrialOnboardingEmail(this.userId)
  29. expect(this.EmailHandler.promises.sendEmail.lastCall.args).to.deep.equal([
  30. 'trialOnboarding',
  31. {
  32. to: this.email,
  33. sendingUser_id: this.userId,
  34. },
  35. ])
  36. })
  37. })