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:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user