Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions cypress/component/NotificationsProvider.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react'
import { Button } from '@toptal/picasso-button'
import { useNotifications } from '@toptal/picasso-notification'
import { NotificationsProvider } from '@toptal/picasso-provider'
import type { NotificationsProviderProps } from '@toptal/picasso-provider'

const TRIGGER_TEST_ID = 'trigger'
const NOTIFICATION_TEST_ID = 'notification-item'
const NOTIFICATIONS_TO_FIRE = 6

const Trigger = () => {
const { showInfo } = useNotifications()

const handleClick = () => {
for (let index = 0; index < NOTIFICATIONS_TO_FIRE; index++) {
showInfo(<span data-testid={NOTIFICATION_TEST_ID}>Notification</span>)
}
}

return (
<Button data-testid={TRIGGER_TEST_ID} onClick={handleClick}>
Open notifications
</Button>
)
}

const Example = (props: Omit<NotificationsProviderProps, 'children'>) => (
<NotificationsProvider {...props}>
<Trigger />
</NotificationsProvider>
)

describe('NotificationsProvider', () => {
it('caps at the default maxNotifications when no prop is set', () => {
cy.mount(<Example />)

cy.getByTestId(TRIGGER_TEST_ID).click()

cy.getByTestId(NOTIFICATION_TEST_ID).should('have.length', 5)
})

it('caps at the configured maxNotifications', () => {
cy.mount(<Example maxNotifications={2} />)

cy.getByTestId(TRIGGER_TEST_ID).click()

cy.getByTestId(NOTIFICATION_TEST_ID).should('have.length', 2)
})
})

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions packages/picasso-provider/src/Picasso/story/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,3 @@ page
title: 'PicassoLight with FixViewport and FontsLoader',
takeScreenshot: false,
})
.addExample('Picasso/story/LightWithNotificationsAndFavicon.example.tsx', {
title: 'PicassoLight with notifications and favicon',
takeScreenshot: false,
})
Loading