mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Fix PremiumFeaturesLink tests
GitOrigin-RevId: 32f5b8eecb94074f39622e21833aba0e6ce7feb0
This commit is contained in:
parent
2ca51e82cd
commit
8d04297f21
1 changed files with 25 additions and 13 deletions
|
@ -1,9 +1,14 @@
|
|||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { fireEvent, render, screen, within } from '@testing-library/react'
|
||||
import { fireEvent, screen, within } from '@testing-library/react'
|
||||
import * as eventTracking from '../../../../../../frontend/js/infrastructure/event-tracking'
|
||||
import PremiumFeaturesLink from '../../../../../../frontend/js/features/subscription/components/dashboard/premium-features-link'
|
||||
import * as useLocationModule from '../../../../../../frontend/js/shared/hooks/use-location'
|
||||
import {
|
||||
cleanUpContext,
|
||||
renderWithSubscriptionDashContext,
|
||||
} from '../../helpers/render-with-subscription-dash-context'
|
||||
import { annualActiveSubscription } from '../../fixtures/subscriptions'
|
||||
|
||||
describe('<PremiumFeaturesLink />', function () {
|
||||
const originalLocation = window.location
|
||||
|
@ -16,7 +21,6 @@ describe('<PremiumFeaturesLink />', function () {
|
|||
]
|
||||
|
||||
beforeEach(function () {
|
||||
window.metaAttributesCache = new Map()
|
||||
sendMBSpy = sinon.spy(eventTracking, 'sendMB')
|
||||
this.locationStub = sinon.stub(useLocationModule, 'useLocation').returns({
|
||||
assign: sinon.stub(),
|
||||
|
@ -25,24 +29,32 @@ describe('<PremiumFeaturesLink />', function () {
|
|||
})
|
||||
|
||||
afterEach(function () {
|
||||
window.metaAttributesCache = new Map()
|
||||
sendMBSpy.restore()
|
||||
this.locationStub.restore()
|
||||
cleanUpContext()
|
||||
})
|
||||
|
||||
describe('without an active valid subscription', function () {
|
||||
it('returns an empty container', function () {
|
||||
const { container } = renderWithSubscriptionDashContext(
|
||||
<PremiumFeaturesLink />
|
||||
)
|
||||
expect(container.firstChild).to.be.null
|
||||
})
|
||||
})
|
||||
|
||||
for (const variant of variants) {
|
||||
describe(`${variant.name} variant`, function () {
|
||||
beforeEach(function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'features-page': variant.name,
|
||||
})
|
||||
})
|
||||
afterEach(function () {
|
||||
window.metaAttributesCache.delete('ol-splitTestVariants')
|
||||
})
|
||||
|
||||
it('renders the premium features link and sends analytics event', function () {
|
||||
render(<PremiumFeaturesLink />)
|
||||
renderWithSubscriptionDashContext(<PremiumFeaturesLink />, {
|
||||
metaTags: [
|
||||
{ name: 'ol-subscription', value: annualActiveSubscription },
|
||||
{
|
||||
name: 'ol-splitTestVariants',
|
||||
value: { 'features-page': variant.name },
|
||||
},
|
||||
],
|
||||
})
|
||||
const premiumText = screen.getByText('Get the most out of your', {
|
||||
exact: false,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue