Files
overleaf-cep/services/web/test/frontend/shared/components/notification.test.tsx
T
Rebeka Dekany e2a8bf768b Merge intermediate component wrappers into OL-prefixed components (#34996)
* Merge intermediate component wrappers into OL-prefixed components

* Replace all intermediate wrapper consumers with OL-prefixed components directly

* Fix jsx/js files still importing deleted shim components

* Remove duplicate OLNotification imports left by first pass

* Rename OLTagIcon to TagIcon, remove OL prefix

* Rename OLDropdownMenuItem to DropdownMenuItem, remove OL prefix

* Remove OLNotification, use Notification directly

* Move Notification to the main shared component folder

* Update tag-icon import path out of ol/

* Move TagIcon to the main shared component folder

* Update dropdown-menu-item import path out of ol/

* Move DropdownMenuItem to the main shared component folder

* Fix dropdown-menu-item import path to dropdown/ subfolder

* Remove BS5 alias prefixes from shared components

* Restore notification-list wrapper in Notification component

* Add translation for loading button

* Remove redundant import aliasing

* Resolve conflicts

* Restore notification container `notification-list`

GitOrigin-RevId: 24a5af18599a3e02ac6fd61c09cf5a49ef6e0020
2026-09-17 11:19:34 +00:00

63 lines
1.7 KiB
TypeScript

import { expect } from 'chai'
import { screen, render } from '@testing-library/react'
import Notification from '@/shared/components/notification'
import * as eventTracking from '@/infrastructure/event-tracking'
import sinon from 'sinon'
describe('<Notification />', function () {
let sendMBSpy: sinon.SinonSpy
beforeEach(function () {
sendMBSpy = sinon.spy(eventTracking, 'sendMB')
})
afterEach(function () {
sendMBSpy.restore()
})
it('renders and is not dismissible by default', function () {
render(<Notification type="info" content={<p>A notification</p>} />)
screen.getByText('A notification')
expect(screen.queryByRole('button', { name: 'Close' })).to.be.null
})
it('renders with action', function () {
render(
<Notification
type="info"
content={<p>A notification</p>}
action={<a href="/">Action</a>}
/>
)
screen.getByText('A notification')
screen.getByRole('link', { name: 'Action' })
})
it('renders with close button', function () {
render(
<Notification type="info" content={<p>A notification</p>} isDismissible />
)
screen.getByText('A notification')
screen.getByRole('button', { name: 'Close' })
})
it('renders with title and content passed as HTML', function () {
render(
<Notification
type="info"
content={<p>A notification</p>}
title="A title"
/>
)
screen.getByText('A title')
screen.getByText('A notification')
})
it('renders with content when passed as a string', function () {
render(
<Notification type="info" content="A notification" title="A title" />
)
screen.getByText('A notification')
})
})