beta-program-section.test.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. it('shows link to sessions', async function () {
  17. renderSectionWithUserProvider()
  18. const link = screen.getByRole('link', {
  19. name: 'Manage Beta Program Membership',
  20. })
  21. expect(link.getAttribute('href')).to.equal('/beta/participate')
  22. })
  23. it('shows enrolled status', async function () {
  24. renderSectionWithUserProvider()
  25. screen.getByText('You are enrolled in the Beta Program')
  26. })
  27. it('shows not enrolled status', async function () {
  28. window.metaAttributesCache.set('ol-user', {
  29. betaProgram: false,
  30. })
  31. renderSectionWithUserProvider()
  32. screen.getByText('You are not enrolled in the Beta Program')
  33. screen.getByText(/By joining this program you can have/)
  34. })
  35. })