beta-program-section.test.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { expect } from 'chai'
  2. import { screen, render } from '@testing-library/react'
  3. import BetaProgramSection from '../../../../../frontend/js/features/settings/components/beta-program-section'
  4. import { UserProvider } from '../../../../../frontend/js/shared/context/user-context'
  5. function renderSectionWithUserProvider() {
  6. render(<BetaProgramSection />, {
  7. wrapper: ({ children }) => <UserProvider>{children}</UserProvider>,
  8. })
  9. }
  10. describe('<BetaProgramSection />', function () {
  11. beforeEach(function () {
  12. window.metaAttributesCache.set('ol-user', {
  13. betaProgram: true,
  14. })
  15. })
  16. afterEach(function () {
  17. window.metaAttributesCache = new Map()
  18. })
  19. it('shows link to sessions', async function () {
  20. renderSectionWithUserProvider()
  21. const link = screen.getByRole('link', {
  22. name: 'Manage Beta Program Membership',
  23. })
  24. expect(link.getAttribute('href')).to.equal('/beta/participate')
  25. })
  26. it('shows enrolled status', async function () {
  27. renderSectionWithUserProvider()
  28. screen.getByText('You are enrolled in the Beta Program')
  29. })
  30. it('shows not enrolled status', async function () {
  31. window.metaAttributesCache.set('ol-user', {
  32. betaProgram: false,
  33. })
  34. renderSectionWithUserProvider()
  35. screen.getByText(/By joining our Beta program you can have early access/)
  36. })
  37. })