feat: delete collection [FC-0062] (#1333)

* feat: delete collection

* feat: update button status on delete

* test: add tests for collection delete
This commit is contained in:
Navin Karkera
2024-10-08 22:29:06 +05:30
committed by GitHub
parent 75f937e11a
commit 434fea3a95
14 changed files with 409 additions and 111 deletions

View File

@@ -1,17 +1,37 @@
import React from 'react';
import { render } from '@testing-library/react';
import { capitalize } from 'lodash';
import userEvent from '@testing-library/user-event';
import { initializeMocks, render, screen } from '../../testUtils';
import { NOTIFICATION_MESSAGES } from '../../constants';
import ProcessingNotification from '.';
const mockUndo = jest.fn();
const props = {
title: NOTIFICATION_MESSAGES.saving,
isShow: true,
action: {
label: 'Undo',
onClick: mockUndo,
},
};
describe('<ProcessingNotification />', () => {
beforeEach(() => {
initializeMocks();
});
it('renders successfully', () => {
const { getByText } = render(<ProcessingNotification {...props} />);
expect(getByText(capitalize(props.title))).toBeInTheDocument();
render(<ProcessingNotification {...props} close={() => {}} />);
expect(screen.getByText(capitalize(props.title))).toBeInTheDocument();
expect(screen.getByText('Undo')).toBeInTheDocument();
expect(screen.getByRole('alert').querySelector('.processing-notification-hide-close-button')).not.toBeInTheDocument();
userEvent.click(screen.getByText('Undo'));
expect(mockUndo).toBeCalled();
});
it('add hide-close-button class if no close action is passed', () => {
render(<ProcessingNotification {...props} />);
expect(screen.getByText(capitalize(props.title))).toBeInTheDocument();
expect(screen.getByRole('alert').querySelector('.processing-notification-hide-close-button')).toBeInTheDocument();
});
});