-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show expiration modal on dashboard and search page (#1206)
Co-authored-by: Maham Akif <[email protected]>
- Loading branch information
1 parent
7bef328
commit 6aaebbb
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
71 changes: 71 additions & 0 deletions
71
src/components/expired-subscription-modal/tests/ExpiredSubscriptionModal.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import ExpiredSubscriptionModal from '../index'; | ||
import { useSubscriptions } from '../../app/data'; | ||
import { renderWithRouter } from '../../../utils/tests'; | ||
|
||
jest.mock('../../app/data', () => ({ | ||
...jest.requireActual('../../app/data'), | ||
useSubscriptions: jest.fn(), | ||
})); | ||
|
||
describe('<ExpiredSubscriptionModal />', () => { | ||
beforeEach(() => { | ||
useSubscriptions.mockReturnValue({ | ||
data: { | ||
customerAgreement: { | ||
hasCustomLicenseExpirationMessaging: false, | ||
expiredSubscriptionModalMessaging: null, | ||
urlForExpiredModal: null, | ||
hyperLinkTextForExpiredModal: null, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
test('does not renderwithrouter if `hasCustomLicenseExpirationMessaging` is false', () => { | ||
const { container } = renderWithRouter(<ExpiredSubscriptionModal />); | ||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
|
||
test('renderwithrouters modal with messaging when `hasCustomLicenseExpirationMessaging` is true', () => { | ||
useSubscriptions.mockReturnValue({ | ||
data: { | ||
customerAgreement: { | ||
hasCustomLicenseExpirationMessaging: true, | ||
expiredSubscriptionModalMessaging: 'Your subscription has expired.', | ||
urlForExpiredModal: '/renew', | ||
hyperLinkTextForExpiredModal: 'Click here to renew', | ||
}, | ||
}, | ||
}); | ||
|
||
renderWithRouter(<ExpiredSubscriptionModal />); | ||
|
||
expect(screen.getByText('Your subscription has expired.')).toBeInTheDocument(); | ||
expect(screen.getByText('Click here to renew')).toBeInTheDocument(); | ||
expect(screen.getByRole('link', { name: 'Click here to renew' })).toHaveAttribute('href', '/renew'); | ||
}); | ||
|
||
test('does not renderwithrouter modal if no customer agreement data is present', () => { | ||
useSubscriptions.mockReturnValue({ data: { customerAgreement: null } }); | ||
const { container } = renderWithRouter(<ExpiredSubscriptionModal />); | ||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
|
||
test('renderwithrouters close button in modal', () => { | ||
useSubscriptions.mockReturnValue({ | ||
data: { | ||
customerAgreement: { | ||
hasCustomLicenseExpirationMessaging: true, | ||
expiredSubscriptionModalMessaging: 'Subscription expired', | ||
urlForExpiredModal: '/renew', | ||
hyperLinkTextForExpiredModal: 'Renew', | ||
}, | ||
}, | ||
}); | ||
|
||
renderWithRouter(<ExpiredSubscriptionModal />); | ||
expect(screen.getByRole('button', { name: /close/i })).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters