mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 02:02:31 -05:00
aa480a2663
[web] migrate from window attributes to getMeta GitOrigin-RevId: 3dcf1ab6b01155e5e4abeb3e78d0fa9053e055bc
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { expect } from 'chai'
|
|
import { screen, render } from '@testing-library/react'
|
|
import BetaProgramSection from '../../../../../frontend/js/features/settings/components/beta-program-section'
|
|
import { UserProvider } from '../../../../../frontend/js/shared/context/user-context'
|
|
|
|
function renderSectionWithUserProvider() {
|
|
render(<BetaProgramSection />, {
|
|
wrapper: ({ children }) => <UserProvider>{children}</UserProvider>,
|
|
})
|
|
}
|
|
|
|
describe('<BetaProgramSection />', function () {
|
|
beforeEach(function () {
|
|
window.metaAttributesCache.set('ol-user', {
|
|
betaProgram: true,
|
|
})
|
|
})
|
|
|
|
it('shows link to sessions', async function () {
|
|
renderSectionWithUserProvider()
|
|
|
|
const link = screen.getByRole('link', {
|
|
name: 'Manage Beta Program Membership',
|
|
})
|
|
|
|
expect(link.getAttribute('href')).to.equal('/beta/participate')
|
|
})
|
|
|
|
it('shows enrolled status', async function () {
|
|
renderSectionWithUserProvider()
|
|
screen.getByText('You are enrolled in the Beta Program')
|
|
})
|
|
|
|
it('shows not enrolled status', async function () {
|
|
window.metaAttributesCache.set('ol-user', {
|
|
betaProgram: false,
|
|
})
|
|
renderSectionWithUserProvider()
|
|
screen.getByText('You are not enrolled in the Beta Program')
|
|
screen.getByText(/By joining this program you can have/)
|
|
})
|
|
})
|