Skip to content

Commit

Permalink
chore: trying to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fkhadra committed Dec 8, 2024
1 parent cab57ea commit 3d5182e
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 168 deletions.
25 changes: 8 additions & 17 deletions src/addons/use-notification-center/NotificationCenter.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function TestComponent(props: UseNotificationCenterParams) {
return (
<div>
<div style={flex}>
<button onClick={() => toast('hello')}>display notification</button>
<button onClick={markAllAsRead}>markAllAsRead</button>
<button onClick={clear}>clear</button>
<button onClick={() => add({ content })}>addNotification</button>
Expand Down Expand Up @@ -91,25 +92,15 @@ describe('NotificationCenter', () => {
const id = toast('msg');

cy.resolveEntranceAnimation();
cy.findByRole('alert').should('exist');

toast.update(id, {
render: 'msg updated'
});
cy.findAllByText('msg updated').should('exist');
});

it('mark as read a single notification', () => {
const id = toast('msg');
cy.resolveEntranceAnimation();

cy.findByTestId('count').should('contain.text', 1);
cy.findByTestId('unreadCount').should('contain.text', 1);
cy.findByTestId(`read-${id}`).should('contain.text', false);

cy.findByTestId(`markAsRead-${id}`).click();
setTimeout(() => {
toast.update(id, {
render: 'msg updated'
});
}, 0);

cy.findByTestId('unreadCount').should('contain.text', 0);
cy.findByTestId(`read-${id}`).should('contain.text', true);
cy.findAllByText('msg updated').should('exist');
});

describe('with initial state', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Transitions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Default, cssTransition } from '../utils';
import { cssTransition, Default } from '../utils';

const getConfig = (animationName: string, appendPosition = false) => ({
enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__${animationName}-enter`,
Expand Down
3 changes: 2 additions & 1 deletion src/core/containerObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Toast,
ToastContainerProps,
ToastContent,
ToastContentProps,
ToastProps
} from '../types';
import { canBeRendered, getAutoCloseDelay, isFn, isNum, isStr, parseClassName, toToastItem } from '../utils';
Expand Down Expand Up @@ -142,7 +143,7 @@ export function createContainerObserver(
let toastContent = content;

if (isValidElement(content) && !isStr(content.type)) {
toastContent = cloneElement(content as ReactElement, {
toastContent = cloneElement<ToastContentProps>(content as ReactElement<any>, {
closeToast,
toastProps,
data
Expand Down
Loading

0 comments on commit 3d5182e

Please sign in to comment.