common.spec.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {
  2. createFakeRecurly,
  3. defaultSubscription,
  4. } from '../../fixtures/recurly-mock'
  5. import { PaymentProvider } from '../../../../../../frontend/js/features/subscription/context/payment-context'
  6. import { plans } from '../../fixtures/plans'
  7. describe('common recurly validations', function () {
  8. beforeEach(function () {
  9. const plan = plans.find(({ planCode }) => planCode === 'collaborator')
  10. if (!plan) {
  11. throw new Error('No plan was found while running the test!')
  12. }
  13. cy.window().then(win => {
  14. win.metaAttributesCache = new Map()
  15. win.metaAttributesCache.set('ol-countryCode', '')
  16. win.metaAttributesCache.set('ol-recurlyApiKey', '1234')
  17. win.metaAttributesCache.set('ol-recommendedCurrency', 'USD')
  18. win.metaAttributesCache.set('ol-plan', plan)
  19. win.metaAttributesCache.set('ol-planCode', plan.planCode)
  20. win.metaAttributesCache.set('ol-showCouponField', true)
  21. win.recurly = createFakeRecurly(defaultSubscription)
  22. cy.interceptEvents()
  23. })
  24. })
  25. it('initializes recurly', function () {
  26. cy.window().then(win => {
  27. cy.spy(win.recurly, 'configure')
  28. cy.spy(win.recurly.Pricing, 'Subscription')
  29. })
  30. cy.mount(<PaymentProvider publicKey="0000" />)
  31. cy.window().then(win => {
  32. expect(win.recurly.configure).to.be.calledOnce
  33. expect(win.recurly.Pricing.Subscription).to.be.calledOnce
  34. })
  35. })
  36. })